all repos — honk @ 25ffd152ac82710572424bd703ef1423f4fc4698

my fork of honk

save obfuscated guesses
Ted Unangst tedu@tedunangst.com
Sat, 12 Feb 2022 14:58:57 -0500
commit

25ffd152ac82710572424bd703ef1423f4fc4698

parent

72ffdf2ff08e16a4ad0e2735f3576929f49e627c

5 files changed, 17 insertions(+), 2 deletions(-)

jump to
M database.godatabase.go

@@ -480,6 +480,8 @@ continue

} case "wonkles": h.Wonkles = j + case "guesses": + h.Guesses = template.HTML(j) case "oldrev": default: elog.Printf("unknown meta genus: %s", genus)

@@ -893,6 +895,13 @@ if w := h.Wonkles; w != "" {

_, err := tx.Stmt(stmtSaveMeta).Exec(h.ID, "wonkles", w) if err != nil { elog.Printf("error saving wonkles: %s", err) + return err + } + } + if g := h.Guesses; g != "" { + _, err := tx.Stmt(stmtSaveMeta).Exec(h.ID, "guesses", g) + if err != nil { + elog.Printf("error saving guesses: %s", err) return err } }
M honk.gohonk.go

@@ -100,6 +100,7 @@ Time *Time

Mentions []Mention Badonks []Badonk Wonkles string + Guesses template.HTML } type Badonk struct {
M views/honk.htmlviews/honk.html

@@ -92,7 +92,8 @@ {{ end }}

{{ if eq .Honk.What "wonked" }} <p> {{ if and $bonkcsrf .Honk.IsWonked }} -{{ .Honk.Noise }} +{{ .Honk.Guesses }} +<p>{{ .Honk.Noise }} {{ else }} <button onclick="return playit(this, '{{ .Honk.Noise }}', '{{ .Honk.Wonkles }}', '{{ .Honk.XID }}')">it's play time!</button> {{ end }}
M views/wonk.jsviews/wonk.js

@@ -74,7 +74,7 @@ mess += "<p>" + host.guesses[i]

} div.innerHTML = mess if (typeof(csrftoken) != "undefined") - post("/zonkit", encode({"CSRF": csrftoken, "wherefore": "wonk", "what": host.xid})) + post("/zonkit", encode({"CSRF": csrftoken, "wherefore": "wonk", "guesses": host.guesses.join("<p>"), "what": host.xid})) } else { div.innerHTML = "<p><input> <button onclick='return makeaguess(this)'>guess</button>" }
M web.goweb.go

@@ -1304,6 +1304,10 @@ if wherefore == "wonk" {

xonk := getxonk(userinfo.UserID, what) if xonk != nil { _, err := stmtUpdateFlags.Exec(flagIsWonked, xonk.ID) + if err == nil { + guesses := r.FormValue("guesses") + _, err = stmtSaveMeta.Exec(xonk.ID, "guesses", guesses) + } if err != nil { elog.Printf("error saving: %s", err) }