reduce header tmpl size

avoid calling function twice in APIMe
This commit is contained in:
Azareal 2020-03-04 20:09:39 +10:00
parent 28daeee702
commit 68c6b2f50a
2 changed files with 16 additions and 16 deletions

View File

@ -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)

View File

@ -5,14 +5,14 @@
{{range .Header.Stylesheets}}
<link href="/s/{{.}}" rel="stylesheet" type="text/css">{{end}}
{{range .Header.PreScriptsAsync}}
<script async type="text/javascript" src="/s/{{.}}"></script>{{end}}
<script async src="/s/{{.}}"></script>{{end}}
<meta property="x-loggedin" content="{{.CurrentUser.Loggedin}}"/>
<script type="text/javascript" src="/s/init.js?i=10"></script>
<script src="/s/init.js?i=10"></script>
{{range .Header.ScriptsAsync}}
<script async type="text/javascript" src="/s/{{.}}"></script>{{end}}
<script type="text/javascript" src="/s/jquery-3.1.1.min.js"></script>
<script async src="/s/{{.}}"></script>{{end}}
<script src="/s/jquery-3.1.1.min.js"></script>
{{range .Header.Scripts}}
<script type="text/javascript" src="/s/{{.}}"></script>{{end}}
<script src="/s/{{.}}"></script>{{end}}
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
{{if .Header.MetaDesc}}<meta name="description" content="{{.Header.MetaDesc}}"/>{{end}}
{{/** TODO: Have page / forum / topic level tags and descriptions below as-well **/}}
@ -39,8 +39,7 @@
<li class="menu_left menu_hamburger" title="{{lang "menu_hamburger_tooltip"}}"><a></a></li>
</ul>
</div>
</div>
<div style="clear:both;"></div>
</div><div style="clear:both;"></div>
</nav>
<div class="right_of_nav">{{/**<!--{{dock "rightOfNav" .Header }}-->**/}}
{{/** TODO: Make this a separate template and load it via the theme docks, here for now so we can rapidly prototype the Nox theme **/}}