all repos — honk @ 79d9b15b8387a9f537c5fbbd928c748aa6f8f145

my fork of honk

start consolidating templates
Ted Unangst tedu@tedunangst.com
Tue, 23 Apr 2019 11:22:31 -0400
commit

79d9b15b8387a9f537c5fbbd928c748aa6f8f145

parent

87825edffd7e602cbefb5590d791a085f5cdcd95

2 files changed, 30 insertions(+), 5 deletions(-)

jump to
M honk.gohonk.go

@@ -151,7 +151,7 @@ } else {

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 @@ whatabout = obfusbreak(whatabout)

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 @@

debug := false getconfig("debug", &debug) readviews = ParseTemplates(debug, - "views/homepage.html", "views/honkpage.html", "views/honkers.html", "views/zonkers.html",
M views/honkpage.htmlviews/honkpage.html

@@ -1,7 +1,7 @@

{{ template "header.html" . }} <div class="center"> +<div class="info" id="infobox"> {{ if .Name }} -<div class="info"> <p>{{ .Name }} <span style="margin-left:1em;"><a href="/u/{{ .Name }}/rss">rss</a></span> {{ if .HonkCSRF }} <div>

@@ -15,10 +15,35 @@ </div>

{{ else }} <p>{{ .WhatAbout }} {{ end }} -</div> {{ end }} +<p>{{ .ServerMessage }} +{{ if .HonkCSRF }} +{{ template "honkform.html" . }} +{{ end }} +</div> <div> +{{ $BonkCSRF := .HonkCSRF }} {{ range .Honks }} -{{ template "honk.html" map "Honk" . }} +{{ template "honk.html" map "Honk" . "Bonk" $BonkCSRF }} {{ end }} </div> +{{ if $BonkCSRF }} +<script> +function post(url, data) { + var x = new XMLHttpRequest() + x.open("POST", url) + x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") + x.send(data) +} +function bonk(el, xid) { + el.innerHTML = "bonked" + el.disabled = true + post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + xid) +} +function zonkit(el, xid) { + el.innerHTML = "zonked" + el.disabled = true + post("/zonkit", "CSRF={{ $BonkCSRF }}&xid=" + xid) +} +</script> +{{ end }}