create new css link to smoothly transition between themes

Previously, directly editing the <link> tag with the new file would
cause the page to have no stylesheet for a moment while the new file is
downloaded. A new element is now appended below the original instead,
which smoothens out the transition.
This commit is contained in:
Harvey Tindall
2020-08-19 14:31:41 +01:00
parent ec7609ed8c
commit 56478e96c9
2 changed files with 26 additions and 4 deletions
+13 -2
View File
@@ -94,7 +94,14 @@ func setGinLogger(router *gin.Engine, debugMode bool) {
}
func main() {
// app encompasses essentially all useful functions.
app := new(appContext)
/*
set default config, data and local paths
also, confusing naming here. data_path is not the internal 'data' directory, rather the users .config/jfa-go folder.
local_path is the internal 'data' directory.
*/
userConfigDir, _ := os.UserConfigDir()
app.data_path = filepath.Join(userConfigDir, "jfa-go")
app.config_path = filepath.Join(app.data_path, "config.ini")
@@ -111,6 +118,8 @@ func main() {
debug := flag.Bool("debug", false, "Enables debug logging and exposes pprof.")
flag.Parse()
// attempt to apply command line flags correctly
if app.config_path == *configPath && app.data_path != *dataPath {
app.data_path = *dataPath
app.config_path = filepath.Join(app.data_path, "config.ini")
@@ -121,7 +130,7 @@ func main() {
app.data_path = *dataPath
}
// Env variables are necessary because syscall.Exec for self-restarts doesn't doesn't work with arguments for some reason.
// env variables are necessary because syscall.Exec for self-restarts doesn't doesn't work with arguments for some reason.
if v := os.Getenv("JFA_CONFIGPATH"); v != "" {
app.config_path = v
@@ -158,14 +167,16 @@ func main() {
}
app.info.Printf("Copied default configuration to \"%s\"", app.config_path)
}
var debugMode bool
var address string
if app.loadConfig() != nil {
app.err.Fatalf("Failed to load config file \"%s\"", app.config_path)
}
app.version = app.config.Section("jellyfin").Key("version").String()
// read from config...
debugMode = app.config.Section("ui").Key("debug").MustBool(false)
// then from flag
if *debug {
debugMode = true
}