eliminate need for js in various places
Ted Unangst tedu@tedunangst.com
Sun, 13 Oct 2019 22:59:02 -0400
5 files changed,
51 insertions(+),
11 deletions(-)
M
docs/changelog.txt
→
docs/changelog.txt
@@ -2,6 +2,8 @@ changelog
-- next ++ More JS free fallbacks for some basic functions. + + Add chpass command. + Improved honker management.
M
views/honk.html
→
views/honk.html
@@ -92,25 +92,25 @@ <div>
<p> {{ if .Honk.Public }} {{ if .Honk.IsBonked }} -<button onclick="unbonk(this, '{{ .Honk.XID }}');">unbonk</button> +<button onclick="return unbonk(this, '{{ .Honk.XID }}');">unbonk</button> {{ else }} -<button onclick="bonk(this, '{{ .Honk.XID }}');">bonk</button> +<button onclick="return bonk(this, '{{ .Honk.XID }}');"><a href="/bonk?xid={{ .Honk.XID }}&CSRF={{ $bonkcsrf }}">bonk</a></button> {{ end }} {{ else }} <button disabled>nope</button> {{ end }} -<button onclick="showhonkform(this, '{{ .Honk.XID }}', '{{ .Honk.Handle }}');">honk back</button> -<button onclick="muteit(this, '{{ .Honk.Convoy }}');">mute</button> -<button onclick="zonkit(this, '{{ .Honk.XID }}');">zonk</button> +<button onclick="return showhonkform(this, '{{ .Honk.XID }}', '{{ .Honk.Handle }}');"><a href="/newhonk?rid={{ .Honk.XID }}">honk back</a></button> +<button onclick="return muteit(this, '{{ .Honk.Convoy }}');">mute</button> +<button onclick="return zonkit(this, '{{ .Honk.XID }}');">zonk</button> {{ if .Honk.IsAcked }} -<button onclick="flogit(this, 'deack', '{{ .Honk.XID }}');">deack</button> +<button onclick="return flogit(this, 'deack', '{{ .Honk.XID }}');">deack</button> {{ else }} -<button onclick="flogit(this, 'ack', '{{ .Honk.XID }}');">ack</button> +<button onclick="return flogit(this, 'ack', '{{ .Honk.XID }}');">ack</button> {{ end }} {{ if .Honk.IsSaved }} -<button onclick="flogit(this, 'unsave', '{{ .Honk.XID }}');">unsave</button> +<button onclick="return flogit(this, 'unsave', '{{ .Honk.XID }}');">unsave</button> {{ else }} -<button onclick="flogit(this, 'save', '{{ .Honk.XID }}');">save</button> +<button onclick="return flogit(this, 'save', '{{ .Honk.XID }}');">save</button> {{ end }} <button><a href="/edit?xid={{ .Honk.XID }}">edit</a></button> </div>
M
views/honkform.html
→
views/honkform.html
@@ -1,5 +1,5 @@
<p id="honkformhost"> -<button onclick="showhonkform(); return false"><a href="/newhonk">it's honking time</a></button> +<button onclick="return showhonkform();"><a href="/newhonk">it's honking time</a></button> <form id="honkform" action="/honk" method="POST" enctype="multipart/form-data" {{ if not .IsPreview }}style="display: none"{{ end }}> <input type="hidden" name="CSRF" value="{{ .HonkCSRF }}"> <input type="hidden" name="updatexid" value = "{{ .UpdateXID }}">
M
views/honkpage.js
→
views/honkpage.js
@@ -22,7 +22,8 @@ }
function bonk(el, xid) { el.innerHTML = "bonked" el.disabled = true - post("/bonk", encode({"CSRF": csrftoken, "xid": xid})) + post("/bonk", encode({"js": "2", "CSRF": csrftoken, "xid": xid})) + return false } function unbonk(el, xid) { el.innerHTML = "unbonked"@@ -238,6 +239,7 @@ ridinput.value = rid
honknoise.value = "@" + hname + " " } document.getElementById("honknoise").focus() + return false } function showelement(id) { var el = document.getElementById(id)
M
web.go
→
web.go
@@ -848,6 +848,15 @@ return
} go honkworldwide(user, &bonk) + + if r.FormValue("js") != "1" { + templinfo := getInfo(r) + templinfo["ServerMessage"] = "Bonked!" + err = readviews.Execute(w, "msg.html", templinfo) + if err != nil { + log.Print(err) + } + } } func sendzonkofsorts(xonk *Honk, user *WhatAbout, what string) {@@ -977,6 +986,31 @@ templinfo["UpdateXID"] = honk.XID
if len(honk.Donks) > 0 { templinfo["SavedFile"] = honk.Donks[0].XID } + err := readviews.Execute(w, "honkpage.html", templinfo) + if err != nil { + log.Print(err) + } +} + +func newhonkpage(w http.ResponseWriter, r *http.Request) { + u := login.GetUserInfo(r) + rid := r.FormValue("rid") + noise := "" + + xonk := getxonk(u.UserID, rid) + if xonk != nil { + _, replto := handles(xonk.Honker) + if replto != "" { + noise = "@" + replto + " " + } + } + + templinfo := getInfo(r) + templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) + templinfo["InReplyTo"] = rid + templinfo["Noise"] = noise + templinfo["ServerMessage"] = "compose honk" + templinfo["IsPreview"] = true err := readviews.Execute(w, "honkpage.html", templinfo) if err != nil { log.Print(err)@@ -1686,6 +1720,7 @@ "views/about.html",
"views/funzone.html", "views/login.html", "views/xzone.html", + "views/msg.html", "views/header.html", "views/onts.html", "views/honkpage.js",@@ -1743,6 +1778,7 @@ loggedin.HandleFunc("/chpass", dochpass)
loggedin.HandleFunc("/atme", homepage) loggedin.HandleFunc("/hfcs", hfcspage) loggedin.HandleFunc("/xzone", xzone) + loggedin.HandleFunc("/newhonk", newhonkpage) loggedin.HandleFunc("/edit", edithonkpage) loggedin.Handle("/honk", login.CSRFWrap("honkhonk", http.HandlerFunc(submithonk))) loggedin.Handle("/bonk", login.CSRFWrap("honkhonk", http.HandlerFunc(submitbonk)))