From 68c6b2f50a87e9f3cf8600c679312ca059c83289 Mon Sep 17 00:00:00 2001 From: Azareal Date: Wed, 4 Mar 2020 20:09:39 +1000 Subject: [PATCH] reduce header tmpl size avoid calling function twice in APIMe --- routes/api.go | 5 +++-- templates/header.html | 27 +++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/routes/api.go b/routes/api.go index c6718674..8390824e 100644 --- a/routes/api.go +++ b/routes/api.go @@ -237,10 +237,11 @@ type MeSite struct { // TODO: Decouple site settings into a different API? I'd like to avoid having too many requests, if possible, maybe we can use a different name for this? func APIMe(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError { // TODO: Don't make this too JSON dependent so that we can swap in newer more efficient formats - w.Header().Set("Content-Type", "application/json") + h := w.Header() + h.Set("Content-Type", "application/json") // We don't want an intermediary accidentally caching this // TODO: Use this header anywhere with a user check? - w.Header().Set("Cache-Control", "private") + h.Set("Cache-Control", "private") me := JsonMe{(&user).Me(), MeSite{c.Site.MaxRequestSize}} jsonBytes, err := json.Marshal(me) diff --git a/templates/header.html b/templates/header.html index 2b5c6660..fbcb65ef 100644 --- a/templates/header.html +++ b/templates/header.html @@ -5,24 +5,24 @@ {{range .Header.Stylesheets}} {{end}} {{range .Header.PreScriptsAsync}} - {{end}} - - + {{end}} + + {{range .Header.ScriptsAsync}} - {{end}} - + {{end}} + {{range .Header.Scripts}} - {{end}} - - {{if .Header.MetaDesc}}{{end}} + {{end}} + + {{if .Header.MetaDesc}}{{end}} {{/** TODO: Have page / forum / topic level tags and descriptions below as-well **/}} - + - {{if .OGDesc}} - {{end}} - {{if .GoogSiteVerify}}{{end}} + {{if .OGDesc}} + {{end}} + {{if .GoogSiteVerify}}{{end}} @@ -39,8 +39,7 @@ - -
+
{{/****/}} {{/** TODO: Make this a separate template and load it via the theme docks, here for now so we can rapidly prototype the Nox theme **/}}