diff options
author | KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> | 2021-10-05 18:49:08 -0300 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:52:40 -0700 |
commit | 83d8bc02be90950f0661f56f8d4b12d330dbfdcc (patch) | |
tree | 72039e2e93c13ac67bcd92f0249d8843c8e3b7e1 /main.go | |
parent | e490998c196e5c7a64e8903a500078f5c98e3dad (diff) |
apply theme on load using a cookie
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -96,10 +96,6 @@ func main() { } for _, f := range themes { - if f.Name() == "default.css" { - continue - } - if e := path.Ext(f.Name()); e == ".css" { Themes = append(Themes, strings.TrimSuffix(f.Name(), e)) } @@ -633,7 +629,11 @@ func main() { adminData.Themes = &Themes - err := t.ExecuteTemplate(w, "layout", adminData) + if cookie, err := r.Cookie("theme"); err == nil { + adminData.ThemeCookie = strings.SplitN(cookie.String(), "=", 2)[1] + } + + err = t.ExecuteTemplate(w, "layout", adminData) if err != nil { // TODO: actual error handling log.Printf("mod page: %s\n", err) @@ -673,8 +673,11 @@ func main() { adminData.PostBlacklist = GetRegexBlacklistDB(db) adminData.Themes = &Themes + if cookie, err := r.Cookie("theme"); err == nil { + adminData.ThemeCookie = strings.SplitN(cookie.String(), "=", 2)[1] + } - err := t.ExecuteTemplate(w, "layout", adminData) + err = t.ExecuteTemplate(w, "layout", adminData) if err != nil { // TODO: actual error handling log.Printf("mod page: %s\n", err) |