fix(webui): correct layout rendering; select content template by name and include via layout; fix navbar/footer appearance
This commit is contained in:
parent
3ed38031be
commit
ab11490807
4 changed files with 12 additions and 6 deletions
|
|
@ -42,6 +42,8 @@ func (s *Server) render(w http.ResponseWriter, name string, data map[string]any)
|
||||||
} else {
|
} else {
|
||||||
data["Title"] = strings.Title(base)
|
data["Title"] = strings.Title(base)
|
||||||
}
|
}
|
||||||
|
// Tell layout which content template to include
|
||||||
|
data["Content"] = base
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
_ = tpl.ExecuteTemplate(w, name, data)
|
_ = tpl.ExecuteTemplate(w, "layout.tmpl", data)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{{ define "content" }}
|
{{ define "dashboard" }}
|
||||||
<main class="container">
|
<main class="container">
|
||||||
<aside class="sidebar">
|
<aside class="sidebar">
|
||||||
<nav id="chanlist"></nav>
|
<nav id="chanlist"></nav>
|
||||||
|
|
@ -8,5 +8,5 @@
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ template "layout.tmpl" . }}
|
{{/* layout executes us via .Content */}}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,11 @@
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
{{ block "content" . }}{{ end }}
|
{{ if eq .Content "dashboard" }}
|
||||||
|
{{ template "dashboard" . }}
|
||||||
|
{{ else if eq .Content "summarizer" }}
|
||||||
|
{{ template "summarizer" . }}
|
||||||
|
{{ end }}
|
||||||
<footer><small>{{ .Version }} ({{ .Commit }})</small></footer>
|
<footer><small>{{ .Version }} ({{ .Commit }})</small></footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{{ define "content" }}
|
{{ define "summarizer" }}
|
||||||
<main class="container">
|
<main class="container">
|
||||||
<article>
|
<article>
|
||||||
<h3>On-demand summarization</h3>
|
<h3>On-demand summarization</h3>
|
||||||
|
|
@ -10,5 +10,5 @@
|
||||||
</article>
|
</article>
|
||||||
</main>
|
</main>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ template "layout.tmpl" . }}
|
{{/* layout executes us via .Content */}}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue