diff --git a/res/static/style/layout.css b/res/static/style/layout.css index 1dfcd5a..771752e 100644 --- a/res/static/style/layout.css +++ b/res/static/style/layout.css @@ -204,7 +204,7 @@ section { padding: 4px; margin: 0.2em 15px 0.2em 15px; font-family: 'Open Sans Light', sans-serif; - font-weight: light; + font-weight: lighter; font-size: 1.5em; overflow: hidden; text-overflow: ellipsis; diff --git a/res/template/admin.html b/res/template/admin.html index 4fd8672..696d7d7 100644 --- a/res/template/admin.html +++ b/res/template/admin.html @@ -9,8 +9,8 @@ window.api_endpoint = '{{.APIEndpoint}}'; window.server_hostname = "{{.Hostname}}"; - - + + {{template "menu" .}} diff --git a/res/template/directory_upload.html b/res/template/directory_upload.html index 57f2194..3958e78 100644 --- a/res/template/directory_upload.html +++ b/res/template/directory_upload.html @@ -7,8 +7,8 @@ window.api_endpoint = '{{.APIEndpoint}}'; window.user = {{.User}}; - - + + diff --git a/res/template/file_viewer_svelte.html b/res/template/file_viewer_svelte.html index 6117566..3788b97 100644 --- a/res/template/file_viewer_svelte.html +++ b/res/template/file_viewer_svelte.html @@ -28,8 +28,8 @@ window.user_authenticated = {{.Authenticated}}; - - + + {{template "analytics"}} diff --git a/res/template/filesystem.html b/res/template/filesystem.html index 79a1282..7bf6446 100644 --- a/res/template/filesystem.html +++ b/res/template/filesystem.html @@ -27,8 +27,8 @@ window.api_endpoint = '{{.APIEndpoint}}'; - - + + diff --git a/res/template/fragments/meta_tags.html b/res/template/fragments/meta_tags.html index 7bd25be..a2330bb 100644 --- a/res/template/fragments/meta_tags.html +++ b/res/template/fragments/meta_tags.html @@ -4,7 +4,7 @@ - + diff --git a/res/template/home.html b/res/template/home.html index 525799b..a2cf5cc 100644 --- a/res/template/home.html +++ b/res/template/home.html @@ -14,9 +14,6 @@ box-shadow: inset 0 0 2px 0 var(--shadow_color); border: none; } - header>h1 { - color: #ffffff; - } - - + + {{template "menu" .}} diff --git a/res/template/text_upload.html b/res/template/text_upload.html index ca9a8ba..7205bde 100644 --- a/res/template/text_upload.html +++ b/res/template/text_upload.html @@ -7,8 +7,8 @@ - - + + {{template "analytics"}} diff --git a/res/template/user_buckets.html b/res/template/user_buckets.html index af8ff33..64d45ca 100644 --- a/res/template/user_buckets.html +++ b/res/template/user_buckets.html @@ -4,8 +4,8 @@ {{template "meta_tags" "Buckets"}} - - + + {{template "menu" .}} diff --git a/res/template/user_file_manager.html b/res/template/user_file_manager.html index e8de41a..7f0790e 100644 --- a/res/template/user_file_manager.html +++ b/res/template/user_file_manager.html @@ -6,8 +6,8 @@ - - + + diff --git a/res/template/user_home.html b/res/template/user_home.html index a1b0505..ba5ceb4 100644 --- a/res/template/user_home.html +++ b/res/template/user_home.html @@ -8,8 +8,8 @@ window.user = {{.User}}; window.server_hostname = "{{.Hostname}}"; - - + + diff --git a/svelte/src/home_page/HomePage.svelte b/svelte/src/home_page/HomePage.svelte index f119bbb..0d8f8e0 100644 --- a/svelte/src/home_page/HomePage.svelte +++ b/svelte/src/home_page/HomePage.svelte @@ -85,4 +85,8 @@ import UploadWidget from "./UploadWidget.svelte"; background-image: url("/res/img/header_orbitron.webp"); } } +header>h1{ + color: #ffffff; + margin: 40px 10px 40px 10px; +} diff --git a/webcontroller/file_preview.go b/webcontroller/file_preview.go index a4e4aa5..b83ecd3 100644 --- a/webcontroller/file_preview.go +++ b/webcontroller/file_preview.go @@ -2,7 +2,6 @@ package webcontroller import ( "io" - "io/ioutil" "net/http" "strings" @@ -44,7 +43,7 @@ func (wc *WebController) serveFilePreview(w http.ResponseWriter, r *http.Request } defer body.Close() - bodyBytes, err := ioutil.ReadAll(body) + bodyBytes, err := io.ReadAll(body) if err != nil { log.Error("Can't read text file for preview: %s", err) w.Write([]byte("An error occurred while reading this file.")) diff --git a/webcontroller/templates.go b/webcontroller/templates.go index 6b9b0f7..830ad4f 100644 --- a/webcontroller/templates.go +++ b/webcontroller/templates.go @@ -4,7 +4,6 @@ import ( "encoding/base64" "fmt" "html/template" - "io/ioutil" "net/http" "net/url" "os" @@ -33,9 +32,6 @@ type TemplateData struct { Title string OGData ogData - // The cache ID is used to invalidate caches when the webserver is restarted - CacheID int64 - Other interface{} URLQuery url.Values @@ -53,7 +49,6 @@ func (wc *WebController) newTemplateData(w http.ResponseWriter, r *http.Request) // Use the user's IP address for making requests PixelAPI: wc.api.RealIP(util.RemoteAddress(r)).RealAgent(r.UserAgent()), - CacheID: wc.cacheID, Hostname: template.HTML(wc.hostname), URLQuery: r.URL.Query(), } @@ -129,6 +124,7 @@ func (tm *TemplateManager) ParseTemplates(silent bool) { // Import template functions tpl.Funcs(template.FuncMap{ + "cacheID": tm.cacheID, "isBrave": tm.isBrave, "debugMode": tm.debugMode, "apiUrl": tm.apiURL, @@ -172,7 +168,7 @@ func (tm *TemplateManager) ParseTemplates(silent bool) { return nil } - if file, err = ioutil.ReadFile(path); err != nil { + if file, err = os.ReadFile(path); err != nil { return err } @@ -214,6 +210,15 @@ func (tm *TemplateManager) Get() *template.Template { // Template functions. These can be called from within the template to execute // more specialized actions +// The cache ID is used to invalidate caches when the webserver is restarted. +// It's rounded to a full hour to prevent cached from being emptied too often if +// the server is regularly restarted +var cacheID = time.Now().Unix() / 3600 + +func (tm *TemplateManager) cacheID() int64 { + return cacheID +} + func (tm *TemplateManager) isBrave(useragent string) bool { return strings.Contains(useragent, "Brave") } diff --git a/webcontroller/web_controller.go b/webcontroller/web_controller.go index 6498d22..37e346e 100644 --- a/webcontroller/web_controller.go +++ b/webcontroller/web_controller.go @@ -36,9 +36,6 @@ type WebController struct { // page-specific variables captchaSiteKey string - // The cache ID is used to invalidate caches when the webserver is restarted - cacheID int64 - httpClient *http.Client // API client to use for all requests. If the user is authenticated you @@ -69,7 +66,6 @@ func New( websiteAddress: websiteAddress, sessionCookieDomain: sessionCookieDomain, proxyAPIRequests: proxyAPIRequests, - cacheID: time.Now().Unix() / 3600, httpClient: &http.Client{Timeout: time.Minute * 10}, api: pixelapi.New(apiURLInternal), }