all repos — honk @ 4b9f01239dc4b7e76077d78bd0fa86656e3e7bbe

my fork of honk

rework how sub/unsub works, and add delete to honkers
Ted Unangst tedu@tedunangst.com
Wed, 25 Nov 2020 22:03:46 -0500
commit

4b9f01239dc4b7e76077d78bd0fa86656e3e7bbe

parent

89bb398fdd7383ce83a566a67733b30ff6e62ff1

3 files changed, 13 insertions(+), 11 deletions(-)

jump to
M database.godatabase.go

@@ -901,6 +901,7 @@ }

} var stmtHonkers, stmtDubbers, stmtNamedDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateHonker *sql.Stmt +var stmtDeleteHonker *sql.Stmt var stmtAnyXonk, stmtOneXonk, stmtPublicHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByConvoy *sql.Stmt var stmtHonksByOntology, stmtHonksForUser, stmtHonksForMe, stmtSaveDub, stmtHonksByXonker *sql.Stmt var stmtHonksFromLongAgo *sql.Stmt

@@ -931,6 +932,7 @@ stmtHonkers = preparetodie(db, "select honkerid, userid, name, xid, flavor, combos, meta from honkers where userid = ? and (flavor = 'presub' or flavor = 'sub' or flavor = 'peep' or flavor = 'unsub') order by name")

stmtSaveHonker = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos, owner, meta, folxid) values (?, ?, ?, ?, ?, ?, ?, '')") stmtUpdateFlavor = preparetodie(db, "update honkers set flavor = ?, folxid = ? where userid = ? and name = ? and xid = ? and flavor = ?") stmtUpdateHonker = preparetodie(db, "update honkers set name = ?, combos = ?, meta = ? where honkerid = ? and userid = ?") + stmtDeleteHonker = preparetodie(db, "delete from honkers where honkerid = ?") stmtOneHonker = preparetodie(db, "select xid from honkers where name = ? and userid = ?") stmtDubbers = preparetodie(db, "select honkerid, userid, name, xid, flavor from honkers where userid = ? and flavor = 'dub'") stmtNamedDubbers = preparetodie(db, "select honkerid, userid, name, xid, flavor from honkers where userid = ? and name = ? and flavor = 'dub'")
M views/honkers.htmlviews/honkers.html

@@ -48,12 +48,11 @@ <p>name: <input type="text" name="name" value="{{ .Name }}">

<p><label for="notes">notes:</label><br> <textarea name="notes">{{ .Meta.Notes }}</textarea> <p>combos: <input type="text" name="combos" value="{{ range .Combos }}{{ . }} {{end}}"> -{{ if eq .Flavor "sub" }} -<p>unsub: <input type="text" name="goodbye" placeholder="press F" value="" autocomplete=off> -{{ else }} -<p>(re)sub: <input type="text" name="goodbye" placeholder="press X" value="" autocomplete=off> -{{ end }} -<p><button name="save" value="save">save</button> +<p> +<button name="save" value="save">save</button> +<button name="sub" value="sub">(re)sub</button> +<button name="unsub" value="unsub">unsub</button> +<button name="delete" value="delete">delete</button> </form> </details> <p>
M web.goweb.go

@@ -1852,16 +1852,17 @@

defer honkerinvalidator.Clear(u.UserID) if honkerid > 0 { - goodbye := r.FormValue("goodbye") - if goodbye == "F" { + if r.FormValue("delete") == "delete" { unfollowyou(user, honkerid) + stmtDeleteHonker.Exec(honkerid) http.Redirect(w, r, "/honkers", http.StatusSeeOther) return } - if goodbye == "X" { + if r.FormValue("unsub") == "unsub" { + unfollowyou(user, honkerid) + } + if r.FormValue("sub") == "sub" { followyou(user, honkerid) - http.Redirect(w, r, "/honkers", http.StatusSeeOther) - return } _, err := stmtUpdateHonker.Exec(name, combos, mj, honkerid, u.UserID) if err != nil {