flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit 35f0a3f55d49b0043cb33279ea6867ec32362e22
parent 7e0b032dd3df947f42db5dd912a424c88ce03c03
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Tue, 20 Oct 2020 22:37:50 -0700

add basic nav handler

Diffstat:
Mflounder.toml | 2+-
Mhttp.go | 3++-
Mtemplates/index.html | 1+
Mtemplates/nav.html | 7+++++++
4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/flounder.toml b/flounder.toml @@ -1,3 +1,3 @@ -site_title="flounder" +SiteTitle="­čÉčflounder" RootDomain="localhost:8080" diff --git a/http.go b/http.go @@ -14,10 +14,10 @@ type IndexHandler struct { 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 renderError(w http.ResponseWriter, errorMsg string) { // TODO think about p 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 diff --git a/templates/index.html b/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> diff --git a/templates/nav.html b/templates/nav.html @@ -0,0 +1,7 @@ +<nav> + <a href="/">home</a> + <a href="/my_site">/my_site</a> + <a href="/register">/register</a> + <a href="/logout">/logout</a> + <a href="/login">/login</a> +</nav>