start consolidating templates
This commit is contained in:
parent
1e99e99835
commit
af961c701c
4
honk.go
4
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("Cache-Control", "max-age=0")
|
||||||
}
|
}
|
||||||
w.Header().Set("Last-Modified", modtime.Format(http.TimeFormat))
|
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 {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
}
|
}
|
||||||
|
@ -523,6 +523,7 @@ func honkpage(w http.ResponseWriter, r *http.Request, u *UserInfo, user *WhatAbo
|
||||||
templinfo["WhatAbout"] = cleanstring(whatabout)
|
templinfo["WhatAbout"] = cleanstring(whatabout)
|
||||||
}
|
}
|
||||||
templinfo["Honks"] = honks
|
templinfo["Honks"] = honks
|
||||||
|
templinfo["ServerMessage"] = "(some info goes here)"
|
||||||
err := readviews.ExecuteTemplate(w, "honkpage.html", templinfo)
|
err := readviews.ExecuteTemplate(w, "honkpage.html", templinfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
|
@ -1092,7 +1093,6 @@ func serve() {
|
||||||
debug := false
|
debug := false
|
||||||
getconfig("debug", &debug)
|
getconfig("debug", &debug)
|
||||||
readviews = ParseTemplates(debug,
|
readviews = ParseTemplates(debug,
|
||||||
"views/homepage.html",
|
|
||||||
"views/honkpage.html",
|
"views/honkpage.html",
|
||||||
"views/honkers.html",
|
"views/honkers.html",
|
||||||
"views/zonkers.html",
|
"views/zonkers.html",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{{ template "header.html" . }}
|
{{ template "header.html" . }}
|
||||||
<div class="center">
|
<div class="center">
|
||||||
|
<div class="info" id="infobox">
|
||||||
{{ if .Name }}
|
{{ if .Name }}
|
||||||
<div class="info">
|
|
||||||
<p>{{ .Name }} <span style="margin-left:1em;"><a href="/u/{{ .Name }}/rss">rss</a></span>
|
<p>{{ .Name }} <span style="margin-left:1em;"><a href="/u/{{ .Name }}/rss">rss</a></span>
|
||||||
{{ if .HonkCSRF }}
|
{{ if .HonkCSRF }}
|
||||||
<div>
|
<div>
|
||||||
|
@ -15,10 +15,35 @@
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<p>{{ .WhatAbout }}
|
<p>{{ .WhatAbout }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
<p>{{ .ServerMessage }}
|
||||||
|
{{ if .HonkCSRF }}
|
||||||
|
{{ template "honkform.html" . }}
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
{{ $BonkCSRF := .HonkCSRF }}
|
||||||
{{ range .Honks }}
|
{{ range .Honks }}
|
||||||
{{ template "honk.html" map "Honk" . }}
|
{{ template "honk.html" map "Honk" . "Bonk" $BonkCSRF }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</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 }}
|
||||||
|
|
Loading…
Reference in New Issue