diff --git a/res/template/filesystem.html b/res/template/filesystem.html index 920a544..1059e40 100644 --- a/res/template/filesystem.html +++ b/res/template/filesystem.html @@ -20,7 +20,6 @@ - {{ template "opengraph" .OGData }}

@@ -86,13 +91,24 @@ const handle_picker = async e => {


-
Button
- - -
Highlighted button
+
+
Highlight
+ +
-
Danger button
+ {#if highlight_info} +

+ The highlight colour is used for highlighting selected buttons and + other elements. It's also used as the page's theme colour, this + affects things like the embed colour in Discord and the colour of + the address bar in some web browsers. +

+ {/if} +
Button and input
+ + +
Delete button
Background
diff --git a/svelte/src/filesystem/edit_window/EditWindow.svelte b/svelte/src/filesystem/edit_window/EditWindow.svelte index 6d79718..2ac6090 100644 --- a/svelte/src/filesystem/edit_window/EditWindow.svelte +++ b/svelte/src/filesystem/edit_window/EditWindow.svelte @@ -125,7 +125,7 @@ const save = async (keep_editing = false) => { } - +
+ + diff --git a/webcontroller/filesystem.go b/webcontroller/filesystem.go index 15f4295..69bab93 100644 --- a/webcontroller/filesystem.go +++ b/webcontroller/filesystem.go @@ -12,6 +12,8 @@ import ( "github.com/julienschmidt/httprouter" ) +const defaultThemeColour = "#220735" + func (wc *WebController) serveDirectory(w http.ResponseWriter, r *http.Request, p httprouter.Params) { var err error var td = wc.newTemplateData(w, r) @@ -51,15 +53,35 @@ func (wc *WebController) serveDirectory(w http.ResponseWriter, r *http.Request, } } +func urlEncodePath(path string) string { + var split = strings.Split(path, "/") + for i := range split { + split[i] = url.PathEscape(split[i]) + } + return strings.Join(split, "/") +} + +func findThemeColour(f pixelapi.FilesystemPath) string { + // We walk the patch backward because lower entries can override the + // properties of higher entries + for i := len(f.Path) - 1; i >= 0; i-- { + if f.Path[i].Properties["branding_enabled"] != "true" && + f.Path[i].Properties["brand_highlight_color"] != "" { + return f.Path[i].Properties["brand_highlight_color"] + } + } + return defaultThemeColour +} + func (wc *WebController) metadataFromFilesystem(f pixelapi.FilesystemPath) (og ogData) { var ( base = f.Path[f.BaseIndex] name = base.Name - filetype = base.Type - filepath = url.PathEscape(f.Path[0].ID + base.Path) - pageurl = wc.config.WebsiteAddress + "/d/" + filepath - fileurl = wc.config.WebsiteAddress + "/api/filesystem/" + filepath - thumbnailurl = wc.config.WebsiteAddress + "/api/filesystem/" + filepath + "?thumbnail" + filetype = base.FileType + filepath = urlEncodePath(base.Path) + pageurl = wc.config.WebsiteAddress + "/d" + filepath + fileurl = wc.config.WebsiteAddress + "/api/filesystem" + filepath + thumbnailurl = wc.config.WebsiteAddress + "/api/filesystem" + filepath + "?thumbnail" ) og.addProp("og:title", name) @@ -72,6 +94,7 @@ func (wc *WebController) metadataFromFilesystem(f pixelapi.FilesystemPath) (og o og.addName("twitter:title", name) og.addName("twitter:site", "@Fornax96") og.addName("twitter:domain", "pixeldrain.com") + og.addName("theme-color", findThemeColour(f)) if strings.HasPrefix(filetype, "image") { og.addProp("og:type", "article") diff --git a/webcontroller/misc.go b/webcontroller/misc.go index 28e819a..88e9928 100644 --- a/webcontroller/misc.go +++ b/webcontroller/misc.go @@ -36,7 +36,8 @@ func (wc *WebController) serveShareXConfig(w http.ResponseWriter, r *http.Reques "Body": "MultipartFormData", "FileFormName": "file", "URL": "https://pixeldrain.com/u/$json:id$", - "ThumbnailURL": "https://pixeldrain.com/api/file/$json:id$/thumbnail" + "ThumbnailURL": "https://pixeldrain.com/api/file/$json:id$/thumbnail", + "DeletionURL": "https://pixeldrain.com/u/$json:id$" } `, base64.StdEncoding.EncodeToString([]byte(