allow zonking of anything, but be clear that disavow is not delete

This commit is contained in:
Ted Unangst 2019-04-15 16:18:38 -04:00
parent 026a260722
commit 3a03baf1de
6 changed files with 62 additions and 13 deletions

View File

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

View File

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

14
honk.go
View File

@ -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() {

View File

@ -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)
}
</script>
{{ end }}

View File

@ -1,7 +1,8 @@
<div class="honk {{ if eq .Honk.What "tonked" }} tonk {{ end }}">
<div class="honk {{ .Honk.What }}">
{{ with .Honk }}
<div class="title"><img alt="avatar" src="/a?a={{ .Honker}}"><p><a href="{{ .Honker }}" rel=noreferrer>{{ .Username }}</a> <span class="clip">{{ .What }} {{ .Date.Format "02 Jan 2006 15:04" }} <a href="{{ .URL }}" rel=noreferrer>{{ .URL }}</a></span></div>
<div class="noise"><p>{{ .HTML }}</div>
<div class="noise">
<p>{{ .HTML }}
{{ range .Donks }}
{{ if eq .Media "text/plain" }}
<p><a href="/d/{{ .XID }}">Attachment: {{ .Name }}</a>
@ -9,10 +10,12 @@
<p><a href="/d/{{ .XID }}"><img src="/d/{{ .XID }}" title="{{ .URL }}"></a>
{{ end }}
{{ end }}
</div>
{{ end }}
{{ if .Bonk }}
{{ if and .Bonk (not (eq .Honk.What "zonked")) }}
<p>
<button onclick="bonk('{{ .Honk.XID }}'); return false;"><a href="/bonk">bonk</a></button>
<button style="margin-left: 4em;" onclick="showhonkform('{{ .Honk.XID }}', '{{ .Honk.Username }}'); return false;"><a href="/newhonk">tonk</a></button>
<button onclick="showhonkform('{{ .Honk.XID }}', '{{ .Honk.Username }}'); return false;"><a href="/newhonk">tonk</a></button>
<button onclick="zonkit('{{ .Honk.XID }}'); return false;"><a href="/zonkit">zonk</a></button>
{{ end }}
</div>

View File

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