remove wonk support

This commit is contained in:
Ted Unangst 2023-02-07 20:35:38 -05:00
parent 628fc34ae4
commit 6d52b4f492
11 changed files with 2 additions and 231 deletions

View File

@ -687,8 +687,6 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
case "Page": case "Page":
waspage = true waspage = true
fallthrough fallthrough
case "GuessWord": // dealt with below
fallthrough
case "Audio": case "Audio":
fallthrough fallthrough
case "Image": case "Image":
@ -820,12 +818,6 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
targ, _ := obj.GetString("target") targ, _ := obj.GetString("target")
content += string(templates.Sprintf(`<p>Moved to <a href="%s">%s</a>`, targ, targ)) content += string(templates.Sprintf(`<p>Moved to <a href="%s">%s</a>`, targ, targ))
} }
if ot == "GuessWord" {
what = "wonk"
content, _ = obj.GetString("content")
xonk.Wonkles, _ = obj.GetString("wordlist")
go savewonkles(xonk.Wonkles)
}
if what == "honk" && rid != "" { if what == "honk" && rid != "" {
what = "tonk" what = "tonk"
} }
@ -1181,8 +1173,6 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
fallthrough fallthrough
case "event": case "event":
fallthrough fallthrough
case "wonk":
fallthrough
case "honk": case "honk":
j["type"] = "Create" j["type"] = "Create"
jo = junk.New() jo = junk.New()
@ -1190,8 +1180,6 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
jo["type"] = "Note" jo["type"] = "Note"
if h.What == "event" { if h.What == "event" {
jo["type"] = "Event" jo["type"] = "Event"
} else if h.What == "wonk" {
jo["type"] = "GuessWord"
} }
if h.What == "update" { if h.What == "update" {
j["type"] = "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()) jo["duration"] = "PT" + strings.ToUpper(t.Duration.String())
} }
} }
if w := h.Wonkles; w != "" {
jo["wordlist"] = w
}
atts := activatedonks(h.Donks) atts := activatedonks(h.Donks)
if len(atts) > 0 { if len(atts) > 0 {
jo["attachment"] = atts jo["attachment"] = atts

View File

@ -14,54 +14,3 @@
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package main 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
}

View File

@ -485,9 +485,7 @@ func donksforhonks(honks []*Honk) {
continue continue
} }
case "wonkles": case "wonkles":
h.Wonkles = j
case "guesses": case "guesses":
h.Guesses = template.HTML(j)
case "oldrev": case "oldrev":
default: default:
elog.Printf("unknown meta genus: %s", genus) elog.Printf("unknown meta genus: %s", genus)
@ -897,20 +895,6 @@ func saveextras(tx *sql.Tx, h *Honk) error {
return err 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 return nil
} }

View File

@ -54,13 +54,6 @@ activities are ignored.
Limited support. Limited support.
.It Vt Audio .It Vt Audio
Limited Support. 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 .El
.Pp .Pp
Honk primarily supports HTML content, not markdown or other formats, Honk primarily supports HTML content, not markdown or other formats,

View File

@ -2,6 +2,8 @@ changelog
=== next === next
+ Remove the wonk support. Fun's over, back to work.
+ All inclusive danger zone spoiler alerts. + All inclusive danger zone spoiler alerts.
+ Emu peeker + Emu peeker

3
fun.go
View File

@ -181,9 +181,6 @@ func reverbolate(userid int64, honks []*Honk) {
h.HTPrecis = template.HTML(h.Precis) h.HTPrecis = template.HTML(h.Precis)
h.HTML = template.HTML(h.Noise) h.HTML = template.HTML(h.Noise)
if h.What == "wonked" {
h.HTML = "? wonk ?"
}
if redo := relingo[h.What]; redo != "" { if redo := relingo[h.What]; redo != "" {
h.What = redo h.What = redo
} }

View File

@ -104,8 +104,6 @@ type Honk struct {
Time *Time Time *Time
Mentions []Mention Mentions []Mention
Badonks []Badonk Badonks []Badonk
Wonkles string
Guesses template.HTML
} }
type Badonk struct { type Badonk struct {
@ -180,10 +178,6 @@ func (honk *Honk) IsReacted() bool {
return honk.Flags&flagIsReacted != 0 return honk.Flags&flagIsReacted != 0
} }
func (honk *Honk) IsWonked() bool {
return honk.Flags&flagIsWonked != 0
}
type Donk struct { type Donk struct {
FileID int64 FileID int64
XID string XID string

View File

@ -89,15 +89,6 @@ in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a>
{{ end }} {{ end }}
</details> </details>
{{ end }} {{ end }}
{{ if eq .Honk.What "wonked" }}
<p>
{{ if and $bonkcsrf .Honk.IsWonked }}
{{ .Honk.Guesses }}
<p>{{ .Honk.Noise }}
{{ else }}
<button class="playit" data-noise="{{ .Honk.Noise }}" data-wonk="{{ .Honk.Wonkles }}">it's play time!</button>
{{ end }}
{{ end }}
{{ if and $bonkcsrf (not $IsPreview) }} {{ if and $bonkcsrf (not $IsPreview) }}
<p> <p>
<details class="actions"> <details class="actions">

View File

@ -337,12 +337,6 @@ function relinklinks() {
el.onclick = function() { el.onclick = function() {
flogit(el, "react", xid); 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) }, gpsoptions)
} }
} }
function playit(elem, word, wordlist, xid) {
import('/wonk.js').then(module => {
makeaguess = module.makeaguess
module.addguesscontrols(elem, word, wordlist, xid)
})
}
function addemu(elem) { function addemu(elem) {
const data = elem.alt const data = elem.alt
const box = document.getElementById("honknoise"); const box = document.getElementById("honknoise");

View File

@ -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 = "<p><input> <button>guess</button>"
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 += "&#129001;"
} else if (letters[g[i]] > 0) {
res += g[i]
obfu += "&#129000;"
letters[g[i]] = letters[g[i]] - 1
} else {
obfu += "&#11035;"
res += "."
}
}
var div = document.createElement( 'div' );
div.innerHTML = "<p class='fontmonospace'>" + res
host.append(div)
host.guesses.push(obfu)
} else {
var div = document.createElement( 'div' );
div.innerHTML = "<p> invalid guess"
host.append(div)
}
var div = document.createElement( 'div' );
if (res == correct.toUpperCase()) {
var mess = "<p>you are very smart!"
mess += "<p>" + host.xid
for (var i = 0; i < host.guesses.length; i++) {
mess += "<p>" + host.guesses[i]
}
div.innerHTML = mess
if (typeof(csrftoken) != "undefined")
post("/zonkit", encode({"CSRF": csrftoken, "wherefore": "wonk", "guesses": host.guesses.join("<p>"), "what": host.xid}))
} else {
div.innerHTML = "<p><input> <button>guess</button>"
div.querySelector('button').onclick = function() {
makeaguess(this)
}
}
host.append(div)
btn.parentElement.remove()
}

23
web.go
View File

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