From 29fafba035c87203844fab506efb7ae11f4021df Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Sun, 3 Jan 2021 21:13:37 +0000 Subject: [PATCH] remove custom css and bootstrap related options i may reimplement custom css later as an additive version where their file is loaded on top of a17t.css later, but for now its not a priority. --- config/config-base.json | 19 +------------------ html/admin.html | 2 +- html/form.html | 2 +- main.go | 22 +++++++--------------- ts/modules/theme.ts | 6 +++++- views.go | 7 ++++--- 6 files changed, 19 insertions(+), 39 deletions(-) diff --git a/config/config-base.json b/config/config-base.json index 476b7dd..9d5c920 100644 --- a/config/config-base.json +++ b/config/config-base.json @@ -81,9 +81,8 @@ "requires_restart": true, "type": "select", "options": [ - "Bootstrap (Light)", "Jellyfin (Dark)", - "Custom CSS" + "Default (Light)" ], "value": "Jellyfin (Dark)", "description": "Default appearance for all users." @@ -179,14 +178,6 @@ "value": "Your account has been created. Click below to continue to Jellyfin.", "description": "Displayed when a user creates an account" }, - "bs5": { - "name": "Use Bootstrap 5", - "required": false, - "requires_restart": true, - "type": "bool", - "value": false, - "description": "Use the Bootstrap 5 Alpha. Looks better and removes the need for jQuery, so the page should load faster." - }, "url_base": { "name": "URL Base", "required": false, @@ -685,14 +676,6 @@ "value": "", "description": "Location of stored user profiles (encompasses template and configuration and displayprefs) (json)" }, - "custom_css": { - "name": "Custom CSS", - "required": false, - "requires_restart": true, - "type": "text", - "value": "", - "description": "Location of custom bootstrap CSS." - }, "html_templates": { "name": "Custom HTML Template Directory", "required": false, diff --git a/html/admin.html b/html/admin.html index 21a8040..5b01907 100644 --- a/html/admin.html +++ b/html/admin.html @@ -1,5 +1,5 @@ - + diff --git a/html/form.html b/html/form.html index d224b30..eb2271d 100644 --- a/html/form.html +++ b/html/form.html @@ -1,5 +1,5 @@ - + {{ template "header.html" . }} diff --git a/main.go b/main.go index b041bca..689dfcf 100644 --- a/main.go +++ b/main.go @@ -51,8 +51,7 @@ type appContext struct { configBase settings dataPath string localPath string - cssFile string - bsVersion int + cssClass string jellyfinLogin bool users []User invalidTokens []string @@ -362,14 +361,6 @@ func start(asDaemon, firstCall bool) { app.debug.Printf("Loaded config file \"%s\"", app.configPath) - if app.config.Section("ui").Key("bs5").MustBool(false) { - app.cssFile = "bs5-jf.css" - app.bsVersion = 5 - } else { - app.cssFile = "bs4-jf.css" - app.bsVersion = 4 - } - app.debug.Println("Loading storage") app.storage.invite_path = app.config.Section("files").Key("invites").String() @@ -420,14 +411,15 @@ func start(asDaemon, firstCall bool) { json.Unmarshal(configBase, &app.configBase) themes := map[string]string{ - "Jellyfin (Dark)": fmt.Sprintf("bs%d-jf.css", app.bsVersion), - "Bootstrap (Light)": fmt.Sprintf("bs%d.css", app.bsVersion), - "Custom CSS": "", + "Jellyfin (Dark)": "dark-theme", + "Default (Light)": "light-theme", + } + if app.config.Section("ui").Key("theme").String() == "Bootstrap (Light)" { + app.config.Section("ui").Key("theme").SetValue("Default (Light)") } if val, ok := themes[app.config.Section("ui").Key("theme").String()]; ok { - app.cssFile = val + app.cssClass = val } - app.debug.Printf("Using css file \"%s\"", app.cssFile) secret, err := generateSecret(16) if err != nil { app.err.Fatal(err) diff --git a/ts/modules/theme.ts b/ts/modules/theme.ts index 9b9075d..60d4e64 100644 --- a/ts/modules/theme.ts +++ b/ts/modules/theme.ts @@ -5,8 +5,12 @@ export function toggleTheme() { } export function loadTheme() { - if (localStorage.getItem('theme') == "dark") { + const theme = localStorage.getItem("theme"); + if (theme == "dark") { document.documentElement.classList.add('dark-theme'); document.documentElement.classList.remove('light-theme'); + } else if (theme == "light") { + document.documentElement.classList.add('light-theme'); + document.documentElement.classList.remove('dark-theme'); } } diff --git a/views.go b/views.go index 40e70b1..fd7e803 100644 --- a/views.go +++ b/views.go @@ -18,6 +18,7 @@ func (app *appContext) AdminPage(gc *gin.Context) { ombiEnabled := app.config.Section("ombi").Key("enabled").MustBool(false) gcHTML(gc, http.StatusOK, "admin.html", gin.H{ "urlBase": app.URLBase, + "cssClass": app.cssClass, "contactMessage": "", "email_enabled": emailEnabled, "notifications": notificationsEnabled, @@ -39,6 +40,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) { } gcHTML(gc, http.StatusOK, "form-loader.html", gin.H{ "urlBase": app.URLBase, + "cssClass": app.cssClass, "contactMessage": app.config.Section("ui").Key("contact_message").String(), "helpMessage": app.config.Section("ui").Key("help_message").String(), "successMessage": app.config.Section("ui").Key("success_message").String(), @@ -46,14 +48,13 @@ func (app *appContext) InviteProxy(gc *gin.Context) { "validate": app.config.Section("password_validation").Key("enabled").MustBool(false), "requirements": app.validator.getCriteria(), "email": email, - "bs5": app.config.Section("ui").Key("bs5").MustBool(false), "username": !app.config.Section("email").Key("no_username").MustBool(false), "lang": app.storage.lang.Form["strings"], }) } else { gcHTML(gc, 404, "invalidCode.html", gin.H{ "bs5": app.config.Section("ui").Key("bs5").MustBool(false), - "cssFile": app.cssFile, + "cssFile": app.cssClass, "contactMessage": app.config.Section("ui").Key("contact_message").String(), }) } @@ -62,7 +63,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) { func (app *appContext) NoRouteHandler(gc *gin.Context) { gcHTML(gc, 404, "404.html", gin.H{ "bs5": app.config.Section("ui").Key("bs5").MustBool(false), - "cssFile": app.cssFile, + "cssFile": app.cssClass, "contactMessage": app.config.Section("ui").Key("contact_message").String(), }) }