diff --git a/honk.go b/honk.go index 44210aa..3d51ab1 100644 --- a/honk.go +++ b/honk.go @@ -165,10 +165,25 @@ func homepage(w http.ResponseWriter, r *http.Request) { } else { honks = gethonksforuser(userid) honks = osmosis(honks, userid) + if len(honks) > 0 { + templinfo["TopXID"] = honks[0].XID + } } templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) } + tname := "honkpage.html" + if topxid := r.FormValue("topxid"); topxid != "" { + for i, h := range honks { + if h.XID == topxid { + honks = honks[0:i] + break + } + } + log.Printf("topxid %d frags", len(honks)) + tname = "honkfrags.html" + } + reverbolate(userid, honks) templinfo["Honks"] = honks @@ -179,7 +194,9 @@ func homepage(w http.ResponseWriter, r *http.Request) { } else { w.Header().Set("Cache-Control", "max-age=0") } - err := readviews.Execute(w, "honkpage.html", templinfo) + w.Header().Set("Content-Type", "text/html") + + err := readviews.Execute(w, tname, templinfo) if err != nil { log.Print(err) } @@ -1513,6 +1530,7 @@ func serve() { getconfig("debug", &debug) readviews = templates.Load(debug, "views/honkpage.html", + "views/honkfrags.html", "views/honkers.html", "views/zonkers.html", "views/combos.html", diff --git a/views/honkfrags.html b/views/honkfrags.html new file mode 100644 index 0000000..1b3ea44 --- /dev/null +++ b/views/honkfrags.html @@ -0,0 +1,5 @@ +
{{ .TopXID }}
+{{ $BonkCSRF := .HonkCSRF }} +{{ range .Honks }} +{{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }} +{{ end }} diff --git a/views/honkpage.html b/views/honkpage.html index 38781e5..cc3ad17 100644 --- a/views/honkpage.html +++ b/views/honkpage.html @@ -11,6 +11,27 @@ {{ end }} {{ $BonkCSRF := .HonkCSRF }} +{{ if .TopXID }} +
+ +

+

+ +{{ end }} {{ range .Honks }} {{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }} {{ end }} @@ -31,6 +52,13 @@ function post(url, data) { x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") x.send(data) } +function get(url, whendone) { + var x = new XMLHttpRequest() + x.open("GET", url) + x.responseType = "document" + x.onload = function() { whendone(x) } + x.send() +} function bonk(el, xid) { el.innerHTML = "bonked" el.disabled = true