Some optimizations. Improve font loading and embed global.css directly
This commit is contained in:
@@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
function uploadText() {
|
function uploadText() {
|
||||||
var text = $("#textarea").val();
|
var text = $("#textarea").val();
|
||||||
|
if(!text.endsWith("\n")){
|
||||||
|
text += "\n";
|
||||||
|
}
|
||||||
|
|
||||||
var blob = new Blob([text], {type: "text/plain"});
|
var blob = new Blob([text], {type: "text/plain"});
|
||||||
|
|
||||||
startFileUpload(blob);
|
startFileUpload(blob);
|
||||||
|
@@ -13,13 +13,27 @@
|
|||||||
font-family: 'Ubuntu';
|
font-family: 'Ubuntu';
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
src: local('Ubuntu Regular'), local('Ubuntu-Regular'), local('Ubuntu'), url(/res/misc/Ubuntu-R.ttf) format('truetype');
|
font-display: auto;
|
||||||
|
src:
|
||||||
|
local('Ubuntu'),
|
||||||
|
local('Ubuntu Regular'),
|
||||||
|
local('Ubuntu, Regular'),
|
||||||
|
local('Ubuntu-Regular'),
|
||||||
|
url(/res/misc/Ubuntu-R.ttf) format('truetype');
|
||||||
}
|
}
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'Lato';
|
font-family: 'Lato';
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: 100;
|
font-weight: 100;
|
||||||
src: local('Lato Hairline'), local('Lato-Hairline'), url(/res/misc/Lato-Hairline.ttf) format('truetype');
|
font-display: auto;
|
||||||
|
src:
|
||||||
|
local('Lato Thin'),
|
||||||
|
local('Lato, Thin'),
|
||||||
|
local('Lato-Thin'),
|
||||||
|
local('Lato Hairline'),
|
||||||
|
local('Lato, Hairline'),
|
||||||
|
local('Lato-Hairline'),
|
||||||
|
url(/res/misc/Lato-Hairline.ttf) format('truetype');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Page rendering configuration */
|
/* Page rendering configuration */
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" "Not Found"}}
|
{{template "meta_tags" "Not Found"}}
|
||||||
|
{{template "user_style" .}}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" "Internal Server Error"}}
|
{{template "meta_tags" "Internal Server Error"}}
|
||||||
|
{{template "user_style" .}}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" "File Manager"}}
|
{{template "meta_tags" "File Manager"}}
|
||||||
|
{{template "user_style" .}}
|
||||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||||
<style>
|
<style>
|
||||||
.file_manager {
|
.file_manager {
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" "Login"}}
|
{{template "meta_tags" "Login"}}
|
||||||
|
{{template "user_style" .}}
|
||||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" "Logging out..."}}
|
{{template "meta_tags" "Logging out..."}}
|
||||||
|
{{template "user_style" .}}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id='body' class="body">
|
<div id='body' class="body">
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" "Register"}}
|
{{template "meta_tags" "Register"}}
|
||||||
|
{{template "user_style" .}}
|
||||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||||
<script src='https://www.google.com/recaptcha/api.js'></script>
|
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||||
</head>
|
</head>
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" "Files"}}
|
{{template "meta_tags" "Files"}}
|
||||||
|
{{template "user_style" .}}
|
||||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" .Username}}
|
{{template "meta_tags" .Username}}
|
||||||
|
{{template "user_style" .}}
|
||||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" "Lists"}}
|
{{template "meta_tags" "Lists"}}
|
||||||
|
{{template "user_style" .}}
|
||||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" .Username}}
|
{{template "meta_tags" .Username}}
|
||||||
|
{{template "user_style" .}}
|
||||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" "API Documentation"}}
|
{{template "meta_tags" "API Documentation"}}
|
||||||
|
{{template "user_style" .}}
|
||||||
<style>
|
<style>
|
||||||
.api_doc_details{
|
.api_doc_details{
|
||||||
border-top: 1px solid;
|
border-top: 1px solid;
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" "File Not Found"}}
|
{{template "meta_tags" "File Not Found"}}
|
||||||
|
{{template "user_style" .}}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="body">
|
<div id="body">
|
||||||
|
@@ -5,7 +5,9 @@
|
|||||||
<title>{{.Title}}</title>
|
<title>{{.Title}}</title>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
<link rel="stylesheet" href="/global.css"/>
|
<style>
|
||||||
|
{{.UserStyle}}
|
||||||
|
</style>
|
||||||
<link rel="stylesheet" href="/res/style/viewer.css"/>
|
<link rel="stylesheet" href="/res/style/viewer.css"/>
|
||||||
<link rel="stylesheet" href="/res/style/layout.css"/>
|
<link rel="stylesheet" href="/res/style/layout.css"/>
|
||||||
<link rel="stylesheet" href="/res/style/listview.css"/>
|
<link rel="stylesheet" href="/res/style/listview.css"/>
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
<title>{{.}} ~ PixelDrain</title>
|
<title>{{.}} ~ PixelDrain</title>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
<link rel="stylesheet" href="/global.css"/>
|
|
||||||
<link rel="stylesheet" href="/res/style/layout.css"/>
|
<link rel="stylesheet" href="/res/style/layout.css"/>
|
||||||
<link rel="shortcut icon" href="/res/img/tray32.png"/>
|
<link rel="shortcut icon" href="/res/img/tray32.png"/>
|
||||||
<meta name="theme-color" content="#9FCF6C"/>
|
<meta name="theme-color" content="#9FCF6C"/>
|
5
res/template/fragments/user_style.html
Normal file
5
res/template/fragments/user_style.html
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{{define "user_style"}}
|
||||||
|
<style>
|
||||||
|
{{.UserStyle}}
|
||||||
|
</style>
|
||||||
|
{{end}}
|
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" "Upload History"}}
|
{{template "meta_tags" "Upload History"}}
|
||||||
|
{{template "user_style" .}}
|
||||||
<script src="res/script/jquery.js"></script>
|
<script src="res/script/jquery.js"></script>
|
||||||
<script src="res/script/jquery-cookie.js"></script>
|
<script src="res/script/jquery-cookie.js"></script>
|
||||||
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"/>
|
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"/>
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" "Free file sharing service"}}
|
{{template "meta_tags" "Free file sharing service"}}
|
||||||
|
{{template "user_style" .}}
|
||||||
<script src="/res/script/jquery-2.1.4.min.js"></script>
|
<script src="/res/script/jquery-2.1.4.min.js"></script>
|
||||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||||
</head>
|
</head>
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "meta_tags" "Text Upload"}}
|
{{template "meta_tags" "Text Upload"}}
|
||||||
|
{{template "user_style" .}}
|
||||||
<link rel="stylesheet" href="/res/style/viewer.css"/>
|
<link rel="stylesheet" href="/res/style/viewer.css"/>
|
||||||
<script src="/res/script/jquery-2.1.4.min.js"></script>
|
<script src="/res/script/jquery-2.1.4.min.js"></script>
|
||||||
<style>
|
<style>
|
||||||
|
@@ -15,6 +15,7 @@ import (
|
|||||||
type TemplateData struct {
|
type TemplateData struct {
|
||||||
Authenticated bool
|
Authenticated bool
|
||||||
Username string
|
Username string
|
||||||
|
UserStyle template.CSS
|
||||||
APIEndpoint template.URL
|
APIEndpoint template.URL
|
||||||
PixelAPI *pixelapi.PixelAPI
|
PixelAPI *pixelapi.PixelAPI
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ func (wc *WebController) newTemplateData(w http.ResponseWriter, r *http.Request)
|
|||||||
var t = &TemplateData{
|
var t = &TemplateData{
|
||||||
Authenticated: false,
|
Authenticated: false,
|
||||||
Username: "",
|
Username: "",
|
||||||
|
UserStyle: userStyle(r),
|
||||||
APIEndpoint: template.URL(wc.conf.APIURLExternal),
|
APIEndpoint: template.URL(wc.conf.APIURLExternal),
|
||||||
URLQuery: r.URL.Query(),
|
URLQuery: r.URL.Query(),
|
||||||
}
|
}
|
||||||
|
@@ -2,15 +2,11 @@ package webcontroller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/julienschmidt/httprouter"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (wc *WebController) globalCSSHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
func userStyle(r *http.Request) (style template.CSS) {
|
||||||
w.Header().Add("Content-Type", "text/css; charset=utf-8")
|
|
||||||
|
|
||||||
var selectedStyle PixeldrainStyleSheet
|
var selectedStyle PixeldrainStyleSheet
|
||||||
|
|
||||||
if cookie, err := r.Cookie("style"); err != nil {
|
if cookie, err := r.Cookie("style"); err != nil {
|
||||||
@@ -32,7 +28,7 @@ func (wc *WebController) globalCSSHandler(w http.ResponseWriter, r *http.Request
|
|||||||
// var highlightColor = "843384"
|
// var highlightColor = "843384"
|
||||||
// var highlightColorDark = "672867"
|
// var highlightColorDark = "672867"
|
||||||
|
|
||||||
var response = fmt.Sprintf(
|
return template.CSS(fmt.Sprintf(
|
||||||
`:root {
|
`:root {
|
||||||
--text_color: %s;
|
--text_color: %s;
|
||||||
--input_color: %s;
|
--input_color: %s;
|
||||||
@@ -57,8 +53,7 @@ func (wc *WebController) globalCSSHandler(w http.ResponseWriter, r *http.Request
|
|||||||
--shadow_color: %s;
|
--shadow_color: %s;
|
||||||
--shadow_spread: %s;
|
--shadow_spread: %s;
|
||||||
--shadow_intensity: %s;
|
--shadow_intensity: %s;
|
||||||
}
|
}`,
|
||||||
`,
|
|
||||||
selectedStyle.TextColor.CSSString(),
|
selectedStyle.TextColor.CSSString(),
|
||||||
selectedStyle.InputColor.CSSString(),
|
selectedStyle.InputColor.CSSString(),
|
||||||
selectedStyle.InputColor.Add(0, 0, -.1).CSSString(),
|
selectedStyle.InputColor.Add(0, 0, -.1).CSSString(),
|
||||||
@@ -80,9 +75,7 @@ func (wc *WebController) globalCSSHandler(w http.ResponseWriter, r *http.Request
|
|||||||
selectedStyle.ShadowColor.CSSString(),
|
selectedStyle.ShadowColor.CSSString(),
|
||||||
fmt.Sprintf("%dpx", selectedStyle.ShadowSpread),
|
fmt.Sprintf("%dpx", selectedStyle.ShadowSpread),
|
||||||
fmt.Sprintf("%dpx", selectedStyle.ShadowIntensity),
|
fmt.Sprintf("%dpx", selectedStyle.ShadowIntensity),
|
||||||
)
|
))
|
||||||
|
|
||||||
strings.NewReader(response).WriteTo(w)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PixeldrainStyleSheet struct {
|
type PixeldrainStyleSheet struct {
|
@@ -44,7 +44,6 @@ func New(r *httprouter.Router, prefix string, conf *conf.PixelWebConfig) *WebCon
|
|||||||
// General navigation
|
// General navigation
|
||||||
r.GET(p+"/" /* */, wc.serveTemplate("home", false))
|
r.GET(p+"/" /* */, wc.serveTemplate("home", false))
|
||||||
r.GET(p+"/favicon.ico" /* */, wc.serveFile("/favicon.ico"))
|
r.GET(p+"/favicon.ico" /* */, wc.serveFile("/favicon.ico"))
|
||||||
r.GET(p+"/global.css" /* */, wc.globalCSSHandler)
|
|
||||||
r.GET(p+"/api" /* */, wc.serveTemplate("apidoc", false))
|
r.GET(p+"/api" /* */, wc.serveTemplate("apidoc", false))
|
||||||
r.GET(p+"/history" /* */, wc.serveTemplate("history_cookies", false))
|
r.GET(p+"/history" /* */, wc.serveTemplate("history_cookies", false))
|
||||||
r.GET(p+"/u/:id" /* */, wc.serveFileViewer)
|
r.GET(p+"/u/:id" /* */, wc.serveFileViewer)
|
||||||
|
Reference in New Issue
Block a user