# HG changeset patch # User Peter Sanchez # Date 1730507221 21600 # Fri Nov 01 18:27:01 2024 -0600 # Node ID b460d3cd8242676bbc5bf852886554347824894c # Parent ee60e572f91b5c1d09878edc0fb581d56f2f2ce7 # Parent d8bb261c6432ae9131eb81a1ad8df9d052e46aca Merge tedu upstream diff --git a/cli.go b/cli.go --- a/cli.go +++ b/cli.go @@ -152,7 +152,7 @@ errx("user not found") } - honkerid, err := gethonker(user.ID, args[2]) + honkerid, err := findhonkerid(user.ID, args[2]) if err != nil { errx("sorry couldn't find them") } diff --git a/database.go b/database.go --- a/database.go +++ b/database.go @@ -103,7 +103,7 @@ return user } -func gethonker(userid UserID, xid string) (int64, error) { +func findhonkerid(userid UserID, xid string) (int64, error) { row := opendatabase(). QueryRow("select honkerid from honkers where xid = ? and userid = ? and flavor in ('sub')", xid, userid) var honkerid int64 diff --git a/docs/changelog.txt b/docs/changelog.txt --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,5 +1,9 @@ changelog +### next + ++ Add dehonk button. + ### 1.4.1 Antiquated Automaton + Add back a scriptable init function. diff --git a/fun.go b/fun.go --- a/fun.go +++ b/fun.go @@ -582,20 +582,26 @@ return s } -var shortnames = gencache.New(gencache.Options[UserID, map[string]string]{Fill: func(userid UserID) (map[string]string, bool) { +var honkerdirectory = gencache.New(gencache.Options[UserID, map[string]*Honker]{Fill: func(userid UserID) (map[string]*Honker, bool) { honkers := gethonkers(userid) - m := make(map[string]string) + m := make(map[string]*Honker) for _, h := range honkers { - m[h.XID] = h.Name + m[h.XID] = h } return m, true }, Invalidator: &honkerinvalidator}) -func shortname(userid UserID, xid string) string { - m, ok := shortnames.Get(userid) +func gethonker(userid UserID, xid string) *Honker { + m, ok := honkerdirectory.Get(userid) if ok { return m[xid] } + return nil +} +func shortname(userid UserID, xid string) string { + if h := gethonker(userid, xid); h != nil { + return h.Name + } return "" } diff --git a/views/honkers.html b/views/honkers.html --- a/views/honkers.html +++ b/views/honkers.html @@ -35,7 +35,7 @@
avatar -

{{ .Name }} +

{{ .Name }}

diff --git a/web.go b/web.go --- a/web.go +++ b/web.go @@ -949,25 +949,39 @@ honkpage(w, u, honks, templinfo) } +func honkerhat(userid UserID, xid string, r *http.Request) template.HTML { + var miniform template.HTML + sname := shortname(userid, xid) + if sname == "" { + sname = xid + miniform = templates.Sprintf(`
+ + + +
`, login.GetCSRF("submithonker", r), xid) + } else { + honker := gethonker(userid, xid) + miniform = templates.Sprintf(`
+ + + + + +
`, login.GetCSRF("submithonker", r), honker.ID, honker.Name, honker.Meta.Notes) + } + msg := templates.Sprintf(`honks by honker: %s%s`, xid, sname, miniform) + return msg +} + func showhonker(w http.ResponseWriter, r *http.Request) { u := login.GetUserInfo(r) - name := mux.Vars(r)["name"] - var honks []*Honk - if name == "" { - name = r.FormValue("xid") - honks = gethonksbyxonker(UserID(u.UserID), name, 0) - } else { - honks = gethonksbyhonker(UserID(u.UserID), name, 0) - } - miniform := templates.Sprintf(`
- - - -
`, login.GetCSRF("submithonker", r), name) - msg := templates.Sprintf(`honks by honker: %s%s`, name, name, miniform) + var userid = UserID(u.UserID) + xid := r.FormValue("xid") + honks := gethonksbyxonker(userid, xid, 0) + msg := honkerhat(userid, xid, r) templinfo := getInfo(r) templinfo["PageName"] = "honker" - templinfo["PageArg"] = name + templinfo["PageArg"] = xid templinfo["ServerMessage"] = msg templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) honkpage(w, u, honks, templinfo) @@ -2881,13 +2895,7 @@ case "honker": xid := r.FormValue("xid") honks = gethonksbyxonker(userid, xid, wanted) - miniform := templates.Sprintf(`
- - - -
`, login.GetCSRF("submithonker", r), xid) - msg := templates.Sprintf(`honks by honker: %s%s`, xid, xid, miniform) - hydra.Srvmsg = msg + hydra.Srvmsg = honkerhat(userid, xid, r) case "user": uname := r.FormValue("uname") honks = gethonksbyuser(uname, u != nil && u.Username == uname, wanted)