From af961c701c623fcd7653df6343452b1e997cc314 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 23 Apr 2019 11:22:31 -0400 Subject: [PATCH] start consolidating templates --- honk.go | 4 ++-- views/honkpage.html | 31 ++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/honk.go b/honk.go index 49078e2..4a34252 100644 --- a/honk.go +++ b/honk.go @@ -151,7 +151,7 @@ func homepage(w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "max-age=0") } w.Header().Set("Last-Modified", modtime.Format(http.TimeFormat)) - err := readviews.ExecuteTemplate(w, "homepage.html", templinfo) + err := readviews.ExecuteTemplate(w, "honkpage.html", templinfo) if err != nil { log.Print(err) } @@ -523,6 +523,7 @@ func honkpage(w http.ResponseWriter, r *http.Request, u *UserInfo, user *WhatAbo templinfo["WhatAbout"] = cleanstring(whatabout) } templinfo["Honks"] = honks + templinfo["ServerMessage"] = "(some info goes here)" err := readviews.ExecuteTemplate(w, "honkpage.html", templinfo) if err != nil { log.Print(err) @@ -1092,7 +1093,6 @@ func serve() { debug := false getconfig("debug", &debug) readviews = ParseTemplates(debug, - "views/homepage.html", "views/honkpage.html", "views/honkers.html", "views/zonkers.html", diff --git a/views/honkpage.html b/views/honkpage.html index 9f9259c..cb2ccc2 100644 --- a/views/honkpage.html +++ b/views/honkpage.html @@ -1,7 +1,7 @@ {{ template "header.html" . }}
+
{{ if .Name }} -

{{ .Name }} rss {{ if .HonkCSRF }}

@@ -15,10 +15,35 @@ {{ else }}

{{ .WhatAbout }} {{ end }} -

{{ end }} +

{{ .ServerMessage }} +{{ if .HonkCSRF }} +{{ template "honkform.html" . }} +{{ end }} +

+{{ $BonkCSRF := .HonkCSRF }} {{ range .Honks }} -{{ template "honk.html" map "Honk" . }} +{{ template "honk.html" map "Honk" . "Bonk" $BonkCSRF }} {{ end }}
+{{ if $BonkCSRF }} + +{{ end }}