add basic nav handler
alex wennerberg alex@alexwennerberg.com
Tue, 20 Oct 2020 22:37:50 -0700
4 files changed,
11 insertions(+),
2 deletions(-)
M
flounder.toml
→
flounder.toml
@@ -1,3 +1,3 @@
-site_title="flounder" +SiteTitle="🐟flounder" RootDomain="localhost:8080"
M
http.go
→
http.go
@@ -14,10 +14,10 @@ Domain string
SiteTitle string } +// TODO somewhat better error handling const InternalServerError = "500: Internal Server Error" func renderError(w http.ResponseWriter, errorMsg string) { // TODO think about pointers - log.Println(errorMsg) data := struct{ ErrorMsg string }{errorMsg} err := t.ExecuteTemplate(w, "error.html", data) if err != nil { // shouldn't happen probably@@ -28,6 +28,7 @@
func (h *IndexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { indexFiles, err := getIndexFiles() if err != nil { + log.Println(err) w.WriteHeader(http.StatusInternalServerError) renderError(w, InternalServerError) return
M
templates/index.html
→
templates/index.html
@@ -1,6 +1,7 @@
{{$domain := .Domain}} {{template "header" .}} <h1>{{.PageTitle}}</h1> +{{template "nav.html" .}} <h2>All users:</h2> {{ range .Users}} <a href="https://{{.}}.{{$domain}}" class='person-link'>{{.}}</a>