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> <div>{{ .TopXID }}</div>
{{ $BonkCSRF := .HonkCSRF }} {{ $BonkCSRF := .HonkCSRF }}
<div><p>{{ .ServerMessage }}</div>
<div> <div>
{{ range .Honks }} {{ range .Honks }}
{{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }} {{ 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>{{ .Name }} <span style="margin-left:1em;"><a href="/u/{{ .Name }}/rss">rss</a></span>
<p>{{ .WhatAbout }} <p>{{ .WhatAbout }}
{{ end }} {{ end }}
<p>{{ .ServerMessage }} <div id="srvmsg"><p>{{ .ServerMessage }}</div>
{{ if .HonkCSRF }} {{ if .HonkCSRF }}
{{ template "honkform.html" . }} {{ template "honkform.html" . }}
{{ end }} {{ end }}

View File

@ -67,7 +67,13 @@ function fillinhonks(xhr) {
var doc = xhr.responseXML var doc = xhr.responseXML
var stash = curpagestate.name + ":" + curpagestate.arg var stash = curpagestate.name + ":" + curpagestate.arg
topxid[stash] = doc.children[0].children[1].children[0].innerText 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 honksonpage = document.getElementById("honksonpage")
var holder = honksonpage.children[0] var holder = honksonpage.children[0]
var lenhonks = honks.length var lenhonks = honks.length

8
web.go
View File

@ -1509,24 +1509,32 @@ func webhydra(w http.ResponseWriter, r *http.Request) {
switch page { switch page {
case "atme": case "atme":
honks = gethonksforme(userid) honks = gethonksforme(userid)
templinfo["ServerMessage"] = "at me!"
case "home": case "home":
honks = gethonksforuser(userid) honks = gethonksforuser(userid)
honks = osmosis(honks, userid) honks = osmosis(honks, userid)
templinfo["ServerMessage"] = serverMsg
case "first": case "first":
honks = gethonksforuserfirstclass(userid) honks = gethonksforuserfirstclass(userid)
honks = osmosis(honks, userid) honks = osmosis(honks, userid)
templinfo["ServerMessage"] = "first class only"
case "combo": case "combo":
c := r.FormValue("c") c := r.FormValue("c")
honks = gethonksbycombo(userid, c) honks = gethonksbycombo(userid, c)
templinfo["ServerMessage"] = "honks by combo: " + c
case "convoy": case "convoy":
c := r.FormValue("c") c := r.FormValue("c")
honks = gethonksbyconvoy(userid, c) honks = gethonksbyconvoy(userid, c)
templinfo["ServerMessage"] = "honks in convoy: " + c
case "honker": case "honker":
xid := r.FormValue("xid") xid := r.FormValue("xid")
if strings.IndexByte(xid, '@') != -1 { if strings.IndexByte(xid, '@') != -1 {
xid = gofish(xid) xid = gofish(xid)
} }
honks = gethonksbyxonker(userid, 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: default:
http.NotFound(w, r) http.NotFound(w, r)
} }