all repos — flounder @ 35f0a3f55d49b0043cb33279ea6867ec32362e22

A small site builder for the Gemini protocol

add basic nav handler
alex wennerberg alex@alexwennerberg.com
Tue, 20 Oct 2020 22:37:50 -0700
commit

35f0a3f55d49b0043cb33279ea6867ec32362e22

parent

7e0b032dd3df947f42db5dd912a424c88ce03c03

4 files changed, 11 insertions(+), 2 deletions(-)

jump to
M flounder.tomlflounder.toml

@@ -1,3 +1,3 @@

-site_title="flounder" +SiteTitle="🐟flounder" RootDomain="localhost:8080"
M http.gohttp.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.htmltemplates/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>
M templates/nav.htmltemplates/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>