add notes to honkers as well
Ted Unangst tedu@tedunangst.com
Mon, 02 Dec 2019 18:26:29 -0500
10 files changed,
51 insertions(+),
18 deletions(-)
M
database.go
→
database.go
@@ -101,13 +101,16 @@ defer rows.Close()
var honkers []*Honker for rows.Next() { h := new(Honker) - var combos string - err = rows.Scan(&h.ID, &h.UserID, &h.Name, &h.XID, &h.Flavor, &combos) - h.Combos = strings.Split(strings.TrimSpace(combos), " ") + var combos, meta string + err = rows.Scan(&h.ID, &h.UserID, &h.Name, &h.XID, &h.Flavor, &combos, &meta) + if err == nil { + err = unjsonify(meta, &h.Meta) + } if err != nil { log.Printf("error scanning honker: %s", err) - return nil + continue } + h.Combos = strings.Split(strings.TrimSpace(combos), " ") honkers = append(honkers, h) } return honkers@@ -738,10 +741,10 @@ return stmt
} func prepareStatements(db *sql.DB) { - stmtHonkers = preparetodie(db, "select honkerid, userid, name, xid, flavor, combos 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) values (?, ?, ?, ?, ?, ?)") + 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) values (?, ?, ?, ?, ?, ?, ?)") stmtUpdateFlavor = preparetodie(db, "update honkers set flavor = ? where userid = ? and xid = ? and name = ? and flavor = ?") - stmtUpdateHonker = preparetodie(db, "update honkers set name = ?, combos = ? where honkerid = ? and userid = ?") + stmtUpdateHonker = preparetodie(db, "update honkers set name = ?, combos = ?, meta = ? where honkerid = ? and userid = ?") 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
docs/changelog.txt
→
docs/changelog.txt
@@ -2,6 +2,8 @@ changelog
-- next ++ Add notes field to honkers to document their downfall. + + Add notes field to filters for record keeping. + Negated search -terms.
M
docs/hfcs.1
→
docs/hfcs.1
@@ -28,6 +28,12 @@ It is accessed via the
.Pa filters menu item. .Pp +Each filter has an optional +.Ar name +and +.Ar notes +for user defined purposes. +.Pp The following match types are possible. All nonempty criteria must match. .Bl -tag -width include-audience
M
docs/honk.1
→
docs/honk.1
@@ -43,15 +43,18 @@ .Ar url
field is required. Either of two forms are accepted, the user's handle (or webfinger) or their ActivityPub actor URL. +.Pp +.Dl @user@example.social +.Dl https://example.social/users/user +.Pp The .Ar name field is optional and will be automatically inferred. -Examples: -.Dl @user@example.social -.Dl https://example.social/users/user -.Pp +The +.Ar notes +field is reserved for user remarks. Fellow honkers may be added to one or more -.Ic combos +.Ar combos to suit one's organizational preferences. These are accessed via the .Pa combos
M
schema.go
→
schema.go
@@ -5,7 +5,7 @@
create table honks (honkid integer primary key, userid integer, what text, honker text, xid text, rid text, dt text, url text, audience text, noise text, convoy text, whofore integer, format text, precis text, oonker text, flags integer); create table donks (honkid integer, fileid integer); create table filemeta (fileid integer primary key, xid text, name text, description text, url text, media text, local integer); -create table honkers (honkerid integer primary key, userid integer, name text, xid text, flavor text, combos text, owner text); +create table honkers (honkerid integer primary key, userid integer, name text, xid text, flavor text, combos text, owner text, meta text); create table xonkers (xonkerid integer primary key, name text, info text, flavor text, dt text); create table zonkers (zonkerid integer primary key, userid integer, name text, wherefore text); create table doovers(dooverid integer primary key, dt text, tries integer, userid integer, rcpt text, msg blob);
M
schema.sql
→
schema.sql
@@ -2,7 +2,7 @@
create table honks (honkid integer primary key, userid integer, what text, honker text, xid text, rid text, dt text, url text, audience text, noise text, convoy text, whofore integer, format text, precis text, oonker text, flags integer); create table donks (honkid integer, fileid integer); create table filemeta (fileid integer primary key, xid text, name text, description text, url text, media text, local integer); -create table honkers (honkerid integer primary key, userid integer, name text, xid text, flavor text, combos text, owner text); +create table honkers (honkerid integer primary key, userid integer, name text, xid text, flavor text, combos text, owner text, meta text); create table xonkers (xonkerid integer primary key, name text, info text, flavor text, dt text); create table zonkers (zonkerid integer primary key, userid integer, name text, wherefore text); create table doovers(dooverid integer primary key, dt text, tries integer, userid integer, rcpt text, msg blob);
M
upgradedb.go
→
upgradedb.go
@@ -24,7 +24,7 @@ "strings"
"time" ) -var myVersion = 33 +var myVersion = 34 func doordie(db *sql.DB, s string, args ...interface{}) { _, err := db.Exec(s, args...)@@ -361,6 +361,11 @@ doordie(db, "update xonkers set dt = ?", time.Now().UTC().Format(dbtimeformat))
doordie(db, "update config set value = 33 where key = 'dbversion'") fallthrough case 33: + doordie(db, "alter table honkers add column meta text") + doordie(db, "update honkers set meta = '{}'") + doordie(db, "update config set value = 34 where key = 'dbversion'") + fallthrough + case 34: default: log.Fatalf("can't upgrade unknown version %d", dbversion)
M
views/honkers.html
→
views/honkers.html
@@ -13,6 +13,9 @@ <p><label for=combos>combos:</label><br>
<input tabindex=1 type="text" name="combos" value="" placeholder="optional"> <p><span><label class=button for="peep">skip subscribe: <input tabindex=1 type="checkbox" id="peep" name="peep" value="peep"><span></span></label></span> +<p><label for="notes">notes:</label><br> +<textarea tabindex=1 name="notes"> +</textarea> <p><button tabindex=1 name="add honker" value="add honker">add honker</button> </form> </div>@@ -42,6 +45,8 @@ <form action="/submithonker" method="POST">
<input type="hidden" name="CSRF" value="{{ $honkercsrf }}"> <input type="hidden" name="honkerid" value="{{ .ID }}"> <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>
M
web.go
→
web.go
@@ -1715,6 +1715,10 @@ combos := strings.TrimSpace(r.FormValue("combos"))
combos = " " + combos + " " honkerid, _ := strconv.ParseInt(r.FormValue("honkerid"), 10, 0) + var meta HonkerMeta + meta.Notes = strings.TrimSpace(r.FormValue("notes")) + mj, _ := jsonify(&meta) + defer honkerinvalidator.Clear(u.UserID) if honkerid > 0 {@@ -1765,7 +1769,7 @@
http.Redirect(w, r, "/honkers", http.StatusSeeOther) return } - _, err := stmtUpdateHonker.Exec(name, combos, honkerid, u.UserID) + _, err := stmtUpdateHonker.Exec(name, combos, mj, honkerid, u.UserID) if err != nil { log.Printf("update honker err: %s", err) return@@ -1789,7 +1793,7 @@ flavor = "peep"
if name == "" { name = url } - _, err := stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos, url) + _, err := stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos, url, mj) if err != nil { log.Print(err) return@@ -1821,7 +1825,7 @@
if name == "" { name = info.Name } - _, err = stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos, info.Owner) + _, err = stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos, info.Owner, mj) if err != nil { log.Print(err) return