Some optimizations. Improve font loading and embed global.css directly
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
|
||||
function uploadText() {
|
||||
var text = $("#textarea").val();
|
||||
if(!text.endsWith("\n")){
|
||||
text += "\n";
|
||||
}
|
||||
|
||||
var blob = new Blob([text], {type: "text/plain"});
|
||||
|
||||
startFileUpload(blob);
|
||||
|
@@ -13,13 +13,27 @@
|
||||
font-family: 'Ubuntu';
|
||||
font-style: normal;
|
||||
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-family: 'Lato';
|
||||
font-style: normal;
|
||||
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 */
|
||||
|
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" "Not Found"}}
|
||||
{{template "user_style" .}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" "Internal Server Error"}}
|
||||
{{template "user_style" .}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" "File Manager"}}
|
||||
{{template "user_style" .}}
|
||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||
<style>
|
||||
.file_manager {
|
||||
|
@@ -3,6 +3,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" "Login"}}
|
||||
{{template "user_style" .}}
|
||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||
</head>
|
||||
<body>
|
||||
|
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" "Logging out..."}}
|
||||
{{template "user_style" .}}
|
||||
</head>
|
||||
<body>
|
||||
<div id='body' class="body">
|
||||
|
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" "Register"}}
|
||||
{{template "user_style" .}}
|
||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||
</head>
|
||||
|
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" "Files"}}
|
||||
{{template "user_style" .}}
|
||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||
</head>
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" .Username}}
|
||||
{{template "user_style" .}}
|
||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||
</head>
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" "Lists"}}
|
||||
{{template "user_style" .}}
|
||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||
</head>
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" .Username}}
|
||||
{{template "user_style" .}}
|
||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||
</head>
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" "API Documentation"}}
|
||||
{{template "user_style" .}}
|
||||
<style>
|
||||
.api_doc_details{
|
||||
border-top: 1px solid;
|
||||
|
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" "File Not Found"}}
|
||||
{{template "user_style" .}}
|
||||
</head>
|
||||
<body>
|
||||
<div id="body">
|
||||
|
@@ -5,7 +5,9 @@
|
||||
<title>{{.Title}}</title>
|
||||
<meta charset="UTF-8"/>
|
||||
<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/layout.css"/>
|
||||
<link rel="stylesheet" href="/res/style/listview.css"/>
|
||||
|
@@ -2,7 +2,6 @@
|
||||
<title>{{.}} ~ PixelDrain</title>
|
||||
<meta charset="UTF-8"/>
|
||||
<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="shortcut icon" href="/res/img/tray32.png"/>
|
||||
<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>
|
||||
<head>
|
||||
{{template "meta_tags" "Upload History"}}
|
||||
{{template "user_style" .}}
|
||||
<script src="res/script/jquery.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"/>
|
||||
|
@@ -3,6 +3,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" "Free file sharing service"}}
|
||||
{{template "user_style" .}}
|
||||
<script src="/res/script/jquery-2.1.4.min.js"></script>
|
||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||
</head>
|
||||
|
@@ -3,6 +3,7 @@
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" "Text Upload"}}
|
||||
{{template "user_style" .}}
|
||||
<link rel="stylesheet" href="/res/style/viewer.css"/>
|
||||
<script src="/res/script/jquery-2.1.4.min.js"></script>
|
||||
<style>
|
||||
|
@@ -15,6 +15,7 @@ import (
|
||||
type TemplateData struct {
|
||||
Authenticated bool
|
||||
Username string
|
||||
UserStyle template.CSS
|
||||
APIEndpoint template.URL
|
||||
PixelAPI *pixelapi.PixelAPI
|
||||
|
||||
@@ -27,6 +28,7 @@ func (wc *WebController) newTemplateData(w http.ResponseWriter, r *http.Request)
|
||||
var t = &TemplateData{
|
||||
Authenticated: false,
|
||||
Username: "",
|
||||
UserStyle: userStyle(r),
|
||||
APIEndpoint: template.URL(wc.conf.APIURLExternal),
|
||||
URLQuery: r.URL.Query(),
|
||||
}
|
||||
|
@@ -2,15 +2,11 @@ package webcontroller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
func (wc *WebController) globalCSSHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||
w.Header().Add("Content-Type", "text/css; charset=utf-8")
|
||||
|
||||
func userStyle(r *http.Request) (style template.CSS) {
|
||||
var selectedStyle PixeldrainStyleSheet
|
||||
|
||||
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 highlightColorDark = "672867"
|
||||
|
||||
var response = fmt.Sprintf(
|
||||
return template.CSS(fmt.Sprintf(
|
||||
`:root {
|
||||
--text_color: %s;
|
||||
--input_color: %s;
|
||||
@@ -57,8 +53,7 @@ func (wc *WebController) globalCSSHandler(w http.ResponseWriter, r *http.Request
|
||||
--shadow_color: %s;
|
||||
--shadow_spread: %s;
|
||||
--shadow_intensity: %s;
|
||||
}
|
||||
`,
|
||||
}`,
|
||||
selectedStyle.TextColor.CSSString(),
|
||||
selectedStyle.InputColor.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(),
|
||||
fmt.Sprintf("%dpx", selectedStyle.ShadowSpread),
|
||||
fmt.Sprintf("%dpx", selectedStyle.ShadowIntensity),
|
||||
)
|
||||
|
||||
strings.NewReader(response).WriteTo(w)
|
||||
))
|
||||
}
|
||||
|
||||
type PixeldrainStyleSheet struct {
|
@@ -44,7 +44,6 @@ func New(r *httprouter.Router, prefix string, conf *conf.PixelWebConfig) *WebCon
|
||||
// General navigation
|
||||
r.GET(p+"/" /* */, wc.serveTemplate("home", false))
|
||||
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+"/history" /* */, wc.serveTemplate("history_cookies", false))
|
||||
r.GET(p+"/u/:id" /* */, wc.serveFileViewer)
|
||||
|
Reference in New Issue
Block a user