start including servermsg in updates

This commit is contained in:
Ted Unangst 2019-10-07 12:34:36 -04:00
parent 2b2ae04c56
commit 02adb896ef
4 changed files with 17 additions and 2 deletions

View File

@ -1,5 +1,6 @@
<div>{{ .TopXID }}</div>
{{ $BonkCSRF := .HonkCSRF }}
<div><p>{{ .ServerMessage }}</div>
<div>
{{ range .Honks }}
{{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }}

View File

@ -5,7 +5,7 @@
<p>{{ .Name }} <span style="margin-left:1em;"><a href="/u/{{ .Name }}/rss">rss</a></span>
<p>{{ .WhatAbout }}
{{ end }}
<p>{{ .ServerMessage }}
<div id="srvmsg"><p>{{ .ServerMessage }}</div>
{{ if .HonkCSRF }}
{{ template "honkform.html" . }}
{{ end }}

View File

@ -67,7 +67,13 @@ function fillinhonks(xhr) {
var doc = xhr.responseXML
var stash = curpagestate.name + ":" + curpagestate.arg
topxid[stash] = doc.children[0].children[1].children[0].innerText
var honks = doc.children[0].children[1].children[1].children
var srvmsg = doc.children[0].children[1].children[1]
var honks = doc.children[0].children[1].children[2].children
var srvel = document.getElementById("srvmsg")
srvel.children[0].remove()
srvel.prepend(srvmsg)
var honksonpage = document.getElementById("honksonpage")
var holder = honksonpage.children[0]
var lenhonks = honks.length

8
web.go
View File

@ -1509,24 +1509,32 @@ func webhydra(w http.ResponseWriter, r *http.Request) {
switch page {
case "atme":
honks = gethonksforme(userid)
templinfo["ServerMessage"] = "at me!"
case "home":
honks = gethonksforuser(userid)
honks = osmosis(honks, userid)
templinfo["ServerMessage"] = serverMsg
case "first":
honks = gethonksforuserfirstclass(userid)
honks = osmosis(honks, userid)
templinfo["ServerMessage"] = "first class only"
case "combo":
c := r.FormValue("c")
honks = gethonksbycombo(userid, c)
templinfo["ServerMessage"] = "honks by combo: " + c
case "convoy":
c := r.FormValue("c")
honks = gethonksbyconvoy(userid, c)
templinfo["ServerMessage"] = "honks in convoy: " + c
case "honker":
xid := r.FormValue("xid")
if strings.IndexByte(xid, '@') != -1 {
xid = gofish(xid)
}
honks = gethonksbyxonker(userid, xid)
xid = html.EscapeString(xid)
msg := fmt.Sprintf(`honks by honker: <a href="%s" ref="noreferrer">%s</a>`, xid, xid)
templinfo["ServerMessage"] = template.HTML(msg)
default:
http.NotFound(w, r)
}