add notes to honkers as well

This commit is contained in:
Ted Unangst 2019-12-02 18:26:29 -05:00
parent 5c18c05517
commit fc21e23207
10 changed files with 51 additions and 18 deletions

View File

@ -101,13 +101,16 @@ func gethonkers(userid int64) []*Honker {
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 @@ func preparetodie(db *sql.DB, s string) *sql.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'")

View File

@ -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.

View File

@ -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

View File

@ -43,15 +43,18 @@ The
field is required.
Either of two forms are accepted, the user's handle (or webfinger) or their
ActivityPub actor URL.
The
.Ar name
field is optional and will be automatically inferred.
Examples:
.Pp
.Dl @user@example.social
.Dl https://example.social/users/user
.Pp
The
.Ar name
field is optional and will be automatically inferred.
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

View File

@ -179,6 +179,11 @@ type Honker struct {
Handle string
Flavor string
Combos []string
Meta HonkerMeta
}
type HonkerMeta struct {
Notes string
}
type SomeThing struct {

View File

@ -5,7 +5,7 @@ var sqlSchema = `
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);

View File

@ -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);

View File

@ -24,7 +24,7 @@ import (
"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 @@ func upgradedb() {
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)

View File

@ -13,6 +13,9 @@
<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 @@ function expandstuff() {
<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>

10
web.go
View File

@ -1715,6 +1715,10 @@ func submithonker(w http.ResponseWriter, r *http.Request) {
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 @@ func submithonker(w http.ResponseWriter, r *http.Request) {
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 @@ func submithonker(w http.ResponseWriter, r *http.Request) {
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 @@ func submithonker(w http.ResponseWriter, r *http.Request) {
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