From 3a03baf1de92278d4861f47ac663dbca4a199eec Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 15 Apr 2019 16:18:38 -0400 Subject: [PATCH] allow zonking of anything, but be clear that disavow is not delete --- activity.go | 9 +++++++++ docs/manual.txt | 7 +++++++ honk.go | 14 ++++++++++++++ views/homepage.html | 3 +++ views/honk.html | 11 +++++++---- views/style.css | 31 ++++++++++++++++++++++--------- 6 files changed, 62 insertions(+), 13 deletions(-) diff --git a/activity.go b/activity.go index 3462b9f..23d1ba5 100644 --- a/activity.go +++ b/activity.go @@ -521,13 +521,22 @@ func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]inte } switch h.What { + case "zonk": + fallthrough case "tonk": fallthrough case "honk": j["type"] = "Create" + if h.What == "zonk" { + j["type"] = "Delete" + } + jo = NewJunk() jo["id"] = user.URL + "/h/" + h.XID jo["type"] = "Note" + if h.What == "zonk" { + jo["type"] = "Tombstone" + } jo["published"] = dt jo["url"] = user.URL + "/h/" + h.XID jo["attributedTo"] = user.URL diff --git a/docs/manual.txt b/docs/manual.txt index b556468..d698ae8 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -14,6 +14,13 @@ like https://example.com/users/name. Note that the commonly seen URL with Selecting just peeping won't actually follow them. (Incomplete feature.) +-- zonking + +You can zonk anything you like (or dislike), either your own honk or +those of others that you're tired of seeing. This reduces its visibility, but +doesn't attempt to delete it, which is infeasible. +It's more like disavow. + -- css Custom CSS may be provided by creating a views/local.css file. diff --git a/honk.go b/honk.go index 4abf557..3545cc2 100644 --- a/honk.go +++ b/honk.go @@ -611,6 +611,9 @@ func donksforhonks(honks []*Honk) { var ids []string hmap := make(map[int64]*Honk) for _, h := range honks { + if h.What == "zonk" { + continue + } ids = append(ids, fmt.Sprintf("%d", h.ID)) hmap[h.ID] = h } @@ -684,6 +687,14 @@ func savebonk(w http.ResponseWriter, r *http.Request) { } +func zonkit(w http.ResponseWriter, r *http.Request) { + xid := r.FormValue("xid") + + log.Printf("zonking %s", xid) + userinfo := GetUserInfo(r) + stmtZonkIt.Exec(userinfo.UserID, xid) +} + func savehonk(w http.ResponseWriter, r *http.Request) { rid := r.FormValue("rid") noise := r.FormValue("noise") @@ -991,6 +1002,7 @@ func serve() { loggedin.Use(LoginRequired) loggedin.Handle("/honk", CSRFWrap("honkhonk", http.HandlerFunc(savehonk))) loggedin.Handle("/bonk", CSRFWrap("honkhonk", http.HandlerFunc(savebonk))) + loggedin.Handle("/zonkit", CSRFWrap("honkhonk", http.HandlerFunc(zonkit))) loggedin.Handle("/saveuser", CSRFWrap("saveuser", http.HandlerFunc(saveuser))) loggedin.HandleFunc("/honkers", showhonkers) loggedin.Handle("/savehonker", CSRFWrap("savehonker", http.HandlerFunc(savehonker))) @@ -1006,6 +1018,7 @@ var stmtHonksForUser, stmtDeleteHonk, stmtSaveDub *sql.Stmt var stmtHonksByHonker, stmtSaveHonk, stmtFileData, stmtWhatAbout *sql.Stmt var stmtFindXonk, stmtSaveDonk, stmtFindFile, stmtSaveFile *sql.Stmt var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover *sql.Stmt +var stmtZonkIt *sql.Stmt func preparetodie(db *sql.DB, s string) *sql.Stmt { stmt, err := db.Prepare(s) @@ -1036,6 +1049,7 @@ func prepareStatements(db *sql.DB) { stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers") stmtLoadDoover = preparetodie(db, "select tries, username, rcpt, msg from doovers where dooverid = ?") stmtZapDoover = preparetodie(db, "delete from doovers where dooverid = ?") + stmtZonkIt = preparetodie(db, "update honks set what = 'zonk' where userid = ? and xid = ?") } func ElaborateUnitTests() { diff --git a/views/homepage.html b/views/homepage.html index 97f188e..0c39a48 100644 --- a/views/homepage.html +++ b/views/homepage.html @@ -23,5 +23,8 @@ function post(url, data) { function bonk(xid) { post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + xid) } +function zonkit(xid) { + post("/zonkit", "CSRF={{ $BonkCSRF }}&xid=" + xid) +} {{ end }} diff --git a/views/honk.html b/views/honk.html index 013e8dc..ec53dce 100644 --- a/views/honk.html +++ b/views/honk.html @@ -1,7 +1,8 @@ -
+
{{ with .Honk }}
avatar

{{ .Username }} {{ .What }} {{ .Date.Format "02 Jan 2006 15:04" }} {{ .URL }}

-

{{ .HTML }}

+
+

{{ .HTML }} {{ range .Donks }} {{ if eq .Media "text/plain" }}

Attachment: {{ .Name }} @@ -9,10 +10,12 @@

{{ end }} {{ end }} +

{{ end }} -{{ if .Bonk }} +{{ if and .Bonk (not (eq .Honk.What "zonked")) }}

- + + {{ end }}

diff --git a/views/style.css b/views/style.css index 64fe496..42ea8ad 100644 --- a/views/style.css +++ b/views/style.css @@ -110,15 +110,6 @@ button a { padding-right: 1em; padding-top: 0; } -.tonk { -} -.tonk .noise { - color: #aab; - font-size: 0.8em; -} -.tonk .noise a { - color: #aab; -} .honk a { color: #dde; } @@ -141,6 +132,28 @@ button a { .honk .title p { margin-top: 0px; } +.honk button { + margin-right: 6em; +} +.tonked { +} +.tonked .noise { + color: #aab; + font-size: 0.8em; +} +.tonked .noise a { + color: #aab; +} +.zonked { +} +.zonked .noise { + color: #a79; + font-size: 0.8em; + text-decoration: line-through; +} +.zonked .noise a { + color: #a79; +} img { max-width: 100% }