1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-12-28 20:10:11 +00:00

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.
This commit is contained in:
Harvey Tindall 2021-01-03 21:13:37 +00:00
parent 75d12b4a5c
commit 29fafba035
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2
6 changed files with 19 additions and 39 deletions

View File

@ -81,9 +81,8 @@
"requires_restart": true, "requires_restart": true,
"type": "select", "type": "select",
"options": [ "options": [
"Bootstrap (Light)",
"Jellyfin (Dark)", "Jellyfin (Dark)",
"Custom CSS" "Default (Light)"
], ],
"value": "Jellyfin (Dark)", "value": "Jellyfin (Dark)",
"description": "Default appearance for all users." "description": "Default appearance for all users."
@ -179,14 +178,6 @@
"value": "Your account has been created. Click below to continue to Jellyfin.", "value": "Your account has been created. Click below to continue to Jellyfin.",
"description": "Displayed when a user creates an account" "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": { "url_base": {
"name": "URL Base", "name": "URL Base",
"required": false, "required": false,
@ -685,14 +676,6 @@
"value": "", "value": "",
"description": "Location of stored user profiles (encompasses template and configuration and displayprefs) (json)" "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": { "html_templates": {
"name": "Custom HTML Template Directory", "name": "Custom HTML Template Directory",
"required": false, "required": false,

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" class="light-theme"> <html lang="en" class="{{ .cssClass }}">
<head> <head>
<link rel="stylesheet" type="text/css" href="css/base.css"> <link rel="stylesheet" type="text/css" href="css/base.css">

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" class="light-theme"> <html lang="en" class="{{ .cssClass }}">
<head> <head>
<link rel="stylesheet" type="text/css" href="css/base.css"> <link rel="stylesheet" type="text/css" href="css/base.css">
{{ template "header.html" . }} {{ template "header.html" . }}

22
main.go
View File

@ -51,8 +51,7 @@ type appContext struct {
configBase settings configBase settings
dataPath string dataPath string
localPath string localPath string
cssFile string cssClass string
bsVersion int
jellyfinLogin bool jellyfinLogin bool
users []User users []User
invalidTokens []string invalidTokens []string
@ -362,14 +361,6 @@ func start(asDaemon, firstCall bool) {
app.debug.Printf("Loaded config file \"%s\"", app.configPath) 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.debug.Println("Loading storage")
app.storage.invite_path = app.config.Section("files").Key("invites").String() 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) json.Unmarshal(configBase, &app.configBase)
themes := map[string]string{ themes := map[string]string{
"Jellyfin (Dark)": fmt.Sprintf("bs%d-jf.css", app.bsVersion), "Jellyfin (Dark)": "dark-theme",
"Bootstrap (Light)": fmt.Sprintf("bs%d.css", app.bsVersion), "Default (Light)": "light-theme",
"Custom CSS": "", }
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 { 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) secret, err := generateSecret(16)
if err != nil { if err != nil {
app.err.Fatal(err) app.err.Fatal(err)

View File

@ -5,8 +5,12 @@ export function toggleTheme() {
} }
export function loadTheme() { 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.add('dark-theme');
document.documentElement.classList.remove('light-theme'); document.documentElement.classList.remove('light-theme');
} else if (theme == "light") {
document.documentElement.classList.add('light-theme');
document.documentElement.classList.remove('dark-theme');
} }
} }

View File

@ -18,6 +18,7 @@ func (app *appContext) AdminPage(gc *gin.Context) {
ombiEnabled := app.config.Section("ombi").Key("enabled").MustBool(false) ombiEnabled := app.config.Section("ombi").Key("enabled").MustBool(false)
gcHTML(gc, http.StatusOK, "admin.html", gin.H{ gcHTML(gc, http.StatusOK, "admin.html", gin.H{
"urlBase": app.URLBase, "urlBase": app.URLBase,
"cssClass": app.cssClass,
"contactMessage": "", "contactMessage": "",
"email_enabled": emailEnabled, "email_enabled": emailEnabled,
"notifications": notificationsEnabled, "notifications": notificationsEnabled,
@ -39,6 +40,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
} }
gcHTML(gc, http.StatusOK, "form-loader.html", gin.H{ gcHTML(gc, http.StatusOK, "form-loader.html", gin.H{
"urlBase": app.URLBase, "urlBase": app.URLBase,
"cssClass": app.cssClass,
"contactMessage": app.config.Section("ui").Key("contact_message").String(), "contactMessage": app.config.Section("ui").Key("contact_message").String(),
"helpMessage": app.config.Section("ui").Key("help_message").String(), "helpMessage": app.config.Section("ui").Key("help_message").String(),
"successMessage": app.config.Section("ui").Key("success_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), "validate": app.config.Section("password_validation").Key("enabled").MustBool(false),
"requirements": app.validator.getCriteria(), "requirements": app.validator.getCriteria(),
"email": email, "email": email,
"bs5": app.config.Section("ui").Key("bs5").MustBool(false),
"username": !app.config.Section("email").Key("no_username").MustBool(false), "username": !app.config.Section("email").Key("no_username").MustBool(false),
"lang": app.storage.lang.Form["strings"], "lang": app.storage.lang.Form["strings"],
}) })
} else { } else {
gcHTML(gc, 404, "invalidCode.html", gin.H{ gcHTML(gc, 404, "invalidCode.html", gin.H{
"bs5": app.config.Section("ui").Key("bs5").MustBool(false), "bs5": app.config.Section("ui").Key("bs5").MustBool(false),
"cssFile": app.cssFile, "cssFile": app.cssClass,
"contactMessage": app.config.Section("ui").Key("contact_message").String(), "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) { func (app *appContext) NoRouteHandler(gc *gin.Context) {
gcHTML(gc, 404, "404.html", gin.H{ gcHTML(gc, 404, "404.html", gin.H{
"bs5": app.config.Section("ui").Key("bs5").MustBool(false), "bs5": app.config.Section("ui").Key("bs5").MustBool(false),
"cssFile": app.cssFile, "cssFile": app.cssClass,
"contactMessage": app.config.Section("ui").Key("contact_message").String(), "contactMessage": app.config.Section("ui").Key("contact_message").String(),
}) })
} }