From 6d52b4f4924c351cbd22a940d2b2fcdffaa2a7cd Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 7 Feb 2023 20:35:38 -0500 Subject: [PATCH] remove wonk support --- activity.go | 15 -------- bloat.go | 51 -------------------------- database.go | 16 --------- docs/activitypub.7 | 7 ---- docs/changelog.txt | 2 ++ fun.go | 3 -- honk.go | 6 ---- views/honk.html | 9 ----- views/honkpage.js | 12 ------- views/wonk.js | 89 ---------------------------------------------- web.go | 23 ------------ 11 files changed, 2 insertions(+), 231 deletions(-) delete mode 100644 views/wonk.js diff --git a/activity.go b/activity.go index 9ecee37..83a8507 100644 --- a/activity.go +++ b/activity.go @@ -687,8 +687,6 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { case "Page": waspage = true fallthrough - case "GuessWord": // dealt with below - fallthrough case "Audio": fallthrough case "Image": @@ -820,12 +818,6 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { targ, _ := obj.GetString("target") content += string(templates.Sprintf(`

Moved to %s`, targ, targ)) } - if ot == "GuessWord" { - what = "wonk" - content, _ = obj.GetString("content") - xonk.Wonkles, _ = obj.GetString("wordlist") - go savewonkles(xonk.Wonkles) - } if what == "honk" && rid != "" { what = "tonk" } @@ -1181,8 +1173,6 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) { fallthrough case "event": fallthrough - case "wonk": - fallthrough case "honk": j["type"] = "Create" jo = junk.New() @@ -1190,8 +1180,6 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) { jo["type"] = "Note" if h.What == "event" { jo["type"] = "Event" - } else if h.What == "wonk" { - jo["type"] = "GuessWord" } if h.What == "update" { j["type"] = "Update" @@ -1298,9 +1286,6 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) { jo["duration"] = "PT" + strings.ToUpper(t.Duration.String()) } } - if w := h.Wonkles; w != "" { - jo["wordlist"] = w - } atts := activatedonks(h.Donks) if len(atts) > 0 { jo["attachment"] = atts diff --git a/bloat.go b/bloat.go index d4c7867..e89675f 100644 --- a/bloat.go +++ b/bloat.go @@ -14,54 +14,3 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. package main - -import ( - "net/http" - "strings" - - "humungus.tedunangst.com/r/webs/junk" -) - -func servewonkles(w http.ResponseWriter, r *http.Request) { - url := r.FormValue("w") - dlog.Printf("getting wordlist: %s", url) - wonkles := getxonker(url, "wonkles") - if wonkles == "" { - wonkles = savewonkles(url) - if wonkles == "" { - http.NotFound(w, r) - return - } - } - var words []string - for _, l := range strings.Split(wonkles, "\n") { - words = append(words, l) - } - if !develMode { - w.Header().Set("Cache-Control", "max-age=7776000") - } - - j := junk.New() - j["wordlist"] = words - j.Write(w) -} - -func savewonkles(url string) string { - w := getxonker(url, "wonkles") - if w != "" { - return w - } - ilog.Printf("fetching wonkles: %s", url) - res, err := fetchsome(url) - if err != nil { - ilog.Printf("error fetching wonkles: %s", err) - return "" - } - w = getxonker(url, "wonkles") - if w != "" { - return w - } - w = string(res) - savexonker(url, w, "wonkles", "") - return w -} diff --git a/database.go b/database.go index d2f10c6..9e5231e 100644 --- a/database.go +++ b/database.go @@ -485,9 +485,7 @@ func donksforhonks(honks []*Honk) { continue } case "wonkles": - h.Wonkles = j case "guesses": - h.Guesses = template.HTML(j) case "oldrev": default: elog.Printf("unknown meta genus: %s", genus) @@ -897,20 +895,6 @@ func saveextras(tx *sql.Tx, h *Honk) error { return err } } - 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 - } - } return nil } diff --git a/docs/activitypub.7 b/docs/activitypub.7 index 00ca7cd..6bf4072 100644 --- a/docs/activitypub.7 +++ b/docs/activitypub.7 @@ -54,13 +54,6 @@ activities are ignored. Limited support. .It Vt Audio Limited Support. -.It Vt GuessWord -Guess the word game. -(Unofficial extension.) -The solution is stored in -.Fa content -with the possible words, one per line, in a file located at -.Fa wordlist . .El .Pp Honk primarily supports HTML content, not markdown or other formats, diff --git a/docs/changelog.txt b/docs/changelog.txt index a9f7054..586b784 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog === next ++ Remove the wonk support. Fun's over, back to work. + + All inclusive danger zone spoiler alerts. + Emu peeker diff --git a/fun.go b/fun.go index 25e155a..27848c5 100644 --- a/fun.go +++ b/fun.go @@ -181,9 +181,6 @@ func reverbolate(userid int64, honks []*Honk) { h.HTPrecis = template.HTML(h.Precis) h.HTML = template.HTML(h.Noise) - if h.What == "wonked" { - h.HTML = "? wonk ?" - } if redo := relingo[h.What]; redo != "" { h.What = redo } diff --git a/honk.go b/honk.go index 51f22d3..1898085 100644 --- a/honk.go +++ b/honk.go @@ -104,8 +104,6 @@ type Honk struct { Time *Time Mentions []Mention Badonks []Badonk - Wonkles string - Guesses template.HTML } type Badonk struct { @@ -180,10 +178,6 @@ func (honk *Honk) IsReacted() bool { return honk.Flags&flagIsReacted != 0 } -func (honk *Honk) IsWonked() bool { - return honk.Flags&flagIsWonked != 0 -} - type Donk struct { FileID int64 XID string diff --git a/views/honk.html b/views/honk.html index fdc6168..8063800 100644 --- a/views/honk.html +++ b/views/honk.html @@ -89,15 +89,6 @@ in reply to: {{ .RID }} {{ end }} {{ end }} -{{ if eq .Honk.What "wonked" }} -

-{{ if and $bonkcsrf .Honk.IsWonked }} -{{ .Honk.Guesses }} -

{{ .Honk.Noise }} -{{ else }} - -{{ end }} -{{ end }} {{ if and $bonkcsrf (not $IsPreview) }}

diff --git a/views/honkpage.js b/views/honkpage.js index c19932b..3e51928 100644 --- a/views/honkpage.js +++ b/views/honkpage.js @@ -337,12 +337,6 @@ function relinklinks() { el.onclick = function() { flogit(el, "react", xid); } - } else if (el.classList.contains("playit")) { - var noise = el.dataset.noise - var wonk = el.dataset.wonk - el.onclick = function() { - playit(el, noise, wonk, xid) - } } }) } @@ -422,12 +416,6 @@ function fillcheckin() { }, gpsoptions) } } -function playit(elem, word, wordlist, xid) { - import('/wonk.js').then(module => { - makeaguess = module.makeaguess - module.addguesscontrols(elem, word, wordlist, xid) - }) -} function addemu(elem) { const data = elem.alt const box = document.getElementById("honknoise"); diff --git a/views/wonk.js b/views/wonk.js deleted file mode 100644 index 22e55a7..0000000 --- a/views/wonk.js +++ /dev/null @@ -1,89 +0,0 @@ -export function addguesscontrols(elem, word, wordlist, xid) { - var host = elem.parentElement - elem.innerHTML = "loading..." - - host.correctAnswer = word - host.guesses = [] - host.xid = xid - var xhr = new XMLHttpRequest() - xhr.open("GET", "/bloat/wonkles?w=" + encodeURIComponent(wordlist)) - xhr.responseType = "json" - xhr.onload = function() { - var wordlist = xhr.response.wordlist - var validguesses = {} - console.log("valid " + wordlist.length) - for (var i = 0; i < wordlist.length; i++) { - validguesses[wordlist[i]] = true - } - host.validGuesses = validguesses - var div = document.createElement( 'div' ); - div.innerHTML = "

" - div.querySelector('button').onclick = function() { - makeaguess(this) - } - host.append(div) - elem.remove() - } - xhr.send() -} -export function makeaguess(btn) { - var host = btn.parentElement.parentElement.parentElement - var correct = host.correctAnswer - var valid = host.validGuesses - var inp = btn.previousElementSibling - var g = inp.value.toLowerCase() - var res = "" - if (valid[g]) { - var letters = {} - var obfu = "" - for (var i = 0; i < correct.length; i++) { - var l = correct[i] - letters[l] = (letters[l] | 0) + 1 - } - for (var i = 0; i < g.length && i < correct.length; i++) { - if (g[i] == correct[i]) { - letters[g[i]] = letters[g[i]] - 1 - } - } - for (var i = 0; i < g.length; i++) { - if (i < correct.length && g[i] == correct[i]) { - res += g[i].toUpperCase() - obfu += "🟩" - } else if (letters[g[i]] > 0) { - res += g[i] - obfu += "🟨" - letters[g[i]] = letters[g[i]] - 1 - } else { - obfu += "⬛" - res += "." - } - } - - var div = document.createElement( 'div' ); - div.innerHTML = "

" + res - host.append(div) - host.guesses.push(obfu) - } else { - var div = document.createElement( 'div' ); - div.innerHTML = "

invalid guess" - host.append(div) - } - var div = document.createElement( 'div' ); - if (res == correct.toUpperCase()) { - var mess = "

you are very smart!" - mess += "

" + host.xid - for (var i = 0; i < host.guesses.length; i++) { - mess += "

" + host.guesses[i] - } - div.innerHTML = mess - if (typeof(csrftoken) != "undefined") - post("/zonkit", encode({"CSRF": csrftoken, "wherefore": "wonk", "guesses": host.guesses.join("

"), "what": host.xid})) - } else { - div.innerHTML = "

" - div.querySelector('button').onclick = function() { - makeaguess(this) - } - } - host.append(div) - btn.parentElement.remove() -} diff --git a/web.go b/web.go index 9fe1e7d..4d0ade8 100644 --- a/web.go +++ b/web.go @@ -1330,21 +1330,6 @@ func zonkit(w http.ResponseWriter, r *http.Request) { return } - 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) - } - } - return - } - // my hammer is too big, oh well defer oldjonks.Flush() @@ -1620,10 +1605,6 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk { if rid != "" { what = "tonk" } - wonkles := r.FormValue("wonkles") - if wonkles != "" { - what = "wonk" - } honk = &Honk{ UserID: userinfo.UserID, Username: userinfo.Username, @@ -1632,7 +1613,6 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk { XID: xid, Date: dt, Format: format, - Wonkles: wonkles, } } @@ -2553,7 +2533,6 @@ func serve() { getters.HandleFunc("/style.css", serveviewasset) getters.HandleFunc("/honkpage.js", serveviewasset) - getters.HandleFunc("/wonk.js", serveviewasset) getters.HandleFunc("/misc.js", serveviewasset) getters.HandleFunc("/local.css", servedataasset) getters.HandleFunc("/local.js", servedataasset) @@ -2566,8 +2545,6 @@ func serve() { getters.HandleFunc("/logout", login.LogoutFunc) getters.HandleFunc("/help/{name:[\\pL[:digit:]_.-]+}", servehelp) - getters.HandleFunc("/bloat/wonkles", servewonkles) - loggedin := mux.NewRoute().Subrouter() loggedin.Use(login.Required) loggedin.HandleFunc("/first", homepage)