From 7fc48f21fc29103c8e20d5130ffdb2721cee1d3b Mon Sep 17 00:00:00 2001 From: kez Date: Sat, 13 Aug 2022 05:02:39 -0700 Subject: [PATCH] Create system for adding data attributes to Base body --- auth/web.go | 11 ++++++++--- misc/handlers.go | 1 + viewutil/base.html | 2 +- viewutil/err.go | 1 + viewutil/viewutil.go | 4 +++- web/mutators.go | 11 ++++++++--- web/readers.go | 8 +++++++- 7 files changed, 29 insertions(+), 9 deletions(-) diff --git a/auth/web.go b/auth/web.go index 4237a71..479b002 100644 --- a/auth/web.go +++ b/auth/web.go @@ -39,7 +39,7 @@ func handlerUserList(w http.ResponseWriter, rq *http.Request) { lc := l18n.FromRequest(rq) w.Header().Set("Content-Type", mime.TypeByExtension(".html")) w.WriteHeader(http.StatusOK) - w.Write([]byte(viewutil.Base(viewutil.MetaFrom(w, rq), lc.Get("ui.users_title"), UserList(lc)))) + w.Write([]byte(viewutil.Base(viewutil.MetaFrom(w, rq), lc.Get("ui.users_title"), UserList(lc), []string{}))) } func handlerLock(w http.ResponseWriter, rq *http.Request) { @@ -57,6 +57,7 @@ func handlerRegister(w http.ResponseWriter, rq *http.Request) { viewutil.MetaFrom(w, rq), lc.Get("auth.register_title"), Register(rq), + []string{}, ), ) return @@ -81,6 +82,7 @@ func handlerRegister(w http.ResponseWriter, rq *http.Request) { err.Error(), lc.Get("auth.try_again"), ), + []string{}, ), ) return @@ -111,7 +113,7 @@ func handlerLogout(w http.ResponseWriter, rq *http.Request) { } _, _ = io.WriteString( w, - viewutil.Base(viewutil.MetaFrom(w, rq), lc.Get("auth.logout_title"), Logout(can, lc)), + viewutil.Base(viewutil.MetaFrom(w, rq), lc.Get("auth.logout_title"), Logout(can, lc), []string{}), ) } else if rq.Method == http.MethodPost { user.LogoutFromRequest(w, rq) @@ -131,6 +133,7 @@ func handlerLogin(w http.ResponseWriter, rq *http.Request) { viewutil.MetaFrom(w, rq), lc.Get("auth.login_title"), Login(lc), + []string{}, ), ) } else if rq.Method == http.MethodPost { @@ -142,7 +145,7 @@ func handlerLogin(w http.ResponseWriter, rq *http.Request) { if err != nil { w.Header().Set("Content-Type", "text/html;charset=utf-8") w.WriteHeader(http.StatusInternalServerError) - _, _ = io.WriteString(w, viewutil.Base(viewutil.MetaFrom(w, rq), err.Error(), LoginError(err.Error(), lc))) + _, _ = io.WriteString(w, viewutil.Base(viewutil.MetaFrom(w, rq), err.Error(), LoginError(err.Error(), lc), []string{})) return } http.Redirect(w, rq, "/", http.StatusSeeOther) @@ -189,6 +192,7 @@ func handlerTelegramLogin(w http.ResponseWriter, rq *http.Request) { err.Error(), lc.Get("auth.go_login"), ), + []string{}, ), ) return @@ -209,6 +213,7 @@ func handlerTelegramLogin(w http.ResponseWriter, rq *http.Request) { err.Error(), lc.Get("auth.go_login"), ), + []string{}, ), ) return diff --git a/misc/handlers.go b/misc/handlers.go index 951bd13..49c2897 100644 --- a/misc/handlers.go +++ b/misc/handlers.go @@ -125,6 +125,7 @@ func handlerAbout(w http.ResponseWriter, rq *http.Request) { viewutil.MetaFrom(w, rq), title, AboutHTML(lc), + []string{}, )) if err != nil { log.Println(err) diff --git a/viewutil/base.html b/viewutil/base.html index 4363416..a55c558 100644 --- a/viewutil/base.html +++ b/viewutil/base.html @@ -15,7 +15,7 @@ {{range .HeadElements}}{{.}}{{end}} - +