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? // 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 { 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 // 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 // We don't want an intermediary accidentally caching this
// TODO: Use this header anywhere with a user check? // 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}} me := JsonMe{(&user).Me(), MeSite{c.Site.MaxRequestSize}}
jsonBytes, err := json.Marshal(me) jsonBytes, err := json.Marshal(me)

View File

@ -5,24 +5,24 @@
{{range .Header.Stylesheets}} {{range .Header.Stylesheets}}
<link href="/s/{{.}}" rel="stylesheet" type="text/css">{{end}} <link href="/s/{{.}}" rel="stylesheet" type="text/css">{{end}}
{{range .Header.PreScriptsAsync}} {{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}}" /> <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}} {{range .Header.ScriptsAsync}}
<script async type="text/javascript" src="/s/{{.}}"></script>{{end}} <script async src="/s/{{.}}"></script>{{end}}
<script type="text/javascript" src="/s/jquery-3.1.1.min.js"></script> <script src="/s/jquery-3.1.1.min.js"></script>
{{range .Header.Scripts}} {{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" /> <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}} {{if .Header.MetaDesc}}<meta name="description" content="{{.Header.MetaDesc}}"/>{{end}}
{{/** TODO: Have page / forum / topic level tags and descriptions below as-well **/}} {{/** TODO: Have page / forum / topic level tags and descriptions below as-well **/}}
<meta property="og:type" content="website" /> <meta property="og:type" content="website"/>
<meta property="og:site_name" content="{{.Header.Site.Name}}"> <meta property="og:site_name" content="{{.Header.Site.Name}}">
<meta property="og:title" content="{{.Title}} | {{.Header.Site.Name}}"> <meta property="og:title" content="{{.Title}} | {{.Header.Site.Name}}">
<meta name="twitter:title" content="{{.Title}} | {{.Header.Site.Name}}" /> <meta name="twitter:title" content="{{.Title}} | {{.Header.Site.Name}}" />
{{if .OGDesc}}<meta property="og:description" content="{{.OGDesc}}" /> {{if .OGDesc}}<meta property="og:description" content="{{.OGDesc}}"/>
<meta property="twitter:description" content="{{.OGDesc}}" />{{end}} <meta property="twitter:description" content="{{.OGDesc}}"/>{{end}}
{{if .GoogSiteVerify}}<meta name="google-site-verification" content="{{.GoogSiteVerify}}" />{{end}} {{if .GoogSiteVerify}}<meta name="google-site-verification" content="{{.GoogSiteVerify}}"/>{{end}}
<link rel="search" type="application/opensearchdescription+xml" title="{{.Header.Site.Name}}" href="/opensearch.xml"> <link rel="search" type="application/opensearchdescription+xml" title="{{.Header.Site.Name}}" href="/opensearch.xml">
</head> </head>
<body> <body>
@ -39,8 +39,7 @@
<li class="menu_left menu_hamburger" title="{{lang "menu_hamburger_tooltip"}}"><a></a></li> <li class="menu_left menu_hamburger" title="{{lang "menu_hamburger_tooltip"}}"><a></a></li>
</ul> </ul>
</div> </div>
</div> </div><div style="clear:both;"></div>
<div style="clear:both;"></div>
</nav> </nav>
<div class="right_of_nav">{{/**<!--{{dock "rightOfNav" .Header }}-->**/}} <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 **/}} {{/** TODO: Make this a separate template and load it via the theme docks, here for now so we can rapidly prototype the Nox theme **/}}