all repos — honk @ a41e46c3d6d96b857c4f2dd625082c75543afda2

my fork of honk

save honks in markdown, convert on the fly
Ted Unangst tedu@tedunangst.com
Wed, 18 Sep 2019 13:46:42 -0400
commit

a41e46c3d6d96b857c4f2dd625082c75543afda2

parent

6149ef8718e9862b75553eacc07ae6d9da9b7f41

4 files changed, 44 insertions(+), 24 deletions(-)

jump to
M activity.goactivity.go

@@ -843,6 +843,7 @@ }

if !h.Public { jo["directMessage"] = true } + translate(h) jo["summary"] = h.Precis jo["content"] = ontologize(mentionize(h.Noise)) if strings.HasPrefix(h.Precis, "DZ:") {
M database.godatabase.go

@@ -183,7 +183,7 @@ func scanhonk(row RowLike) *Honk {

h := new(Honk) var dt, aud, onts string err := row.Scan(&h.ID, &h.UserID, &h.Username, &h.What, &h.Honker, &h.Oonker, &h.XID, &h.RID, - &dt, &h.URL, &aud, &h.Noise, &h.Precis, &h.Convoy, &h.Whofore, &h.Flags, &onts) + &dt, &h.URL, &aud, &h.Noise, &h.Precis, &h.Format, &h.Convoy, &h.Whofore, &h.Flags, &onts) if err != nil { if err != sql.ErrNoRows { log.Printf("error scanning honk: %s", err)

@@ -290,7 +290,7 @@ }

deleteextras(h.ID) dt := h.Date.UTC().Format(dbtimeformat) - stmtUpdateHonk.Exec(h.Precis, h.Noise, dt, h.ID) + stmtUpdateHonk.Exec(h.Precis, h.Noise, h.Format, dt, h.ID) saveextras(h) }

@@ -341,7 +341,7 @@ stmtUpdateCombos = preparetodie(db, "update honkers set combos = ? 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'") - selecthonks := "select honks.honkid, honks.userid, username, what, honker, oonker, honks.xid, rid, dt, url, audience, noise, precis, convoy, whofore, flags, onts from honks join users on honks.userid = users.userid " + selecthonks := "select honks.honkid, honks.userid, username, what, honker, oonker, honks.xid, rid, dt, url, audience, noise, precis, format, convoy, whofore, flags, onts from honks join users on honks.userid = users.userid " limit := " order by honks.honkid desc limit 250" butnotthose := " and convoy not in (select name from zonkers where userid = ? and wherefore = 'zonvoy' order by zonkerid desc limit 100)" stmtOneXonk = preparetodie(db, selecthonks+"where honks.userid = ? and xid = ?")

@@ -360,7 +360,7 @@

stmtSaveOld = preparetodie(db, "insert into forsaken (honkid, precis, noise) values (?, ?, ?)") stmtSaveHonk = preparetodie(db, "insert into honks (userid, what, honker, xid, rid, dt, url, audience, noise, convoy, whofore, format, precis, oonker, flags, onts) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") stmtDeleteHonk = preparetodie(db, "delete from honks where honkid = ?") - stmtUpdateHonk = preparetodie(db, "update honks set precis = ?, noise = ?, dt = ? where honkid = ?") + stmtUpdateHonk = preparetodie(db, "update honks set precis = ?, noise = ?, format = ?, dt = ? where honkid = ?") stmtSaveOnt = preparetodie(db, "insert into onts (ontology, honkid) values (?, ?)") stmtDeleteOnts = preparetodie(db, "delete from onts where honkid = ?") stmtSaveDonk = preparetodie(db, "insert into donks (honkid, fileid) values (?, ?)")
M fun.gofun.go

@@ -44,6 +44,7 @@ }

if !h.Public { h.Style += " limited" } + translate(h) if h.Whofore == 2 || h.Whofore == 3 { h.URL = h.XID if h.What != "bonked" {

@@ -98,6 +99,32 @@ }

} h.Donks = h.Donks[:j] } +} + +func translate(honk *Honk) { + if honk.Format == "html" { + return + } + noise := honk.Noise + if strings.HasPrefix(noise, "DZ:") { + idx := strings.Index(noise, "\n") + if idx == -1 { + honk.Precis = noise + noise = "" + } else { + honk.Precis = noise[:idx] + noise = noise[idx+1:] + } + } + honk.Precis = strings.TrimSpace(honk.Precis) + + noise = strings.TrimSpace(noise) + noise = quickrename(noise, honk.UserID) + noise = obfusbreak(noise) + noise = re_memes.ReplaceAllString(noise, "") + + honk.Noise = noise + honk.Onts = oneofakind(ontologies(honk.Noise)) } func unsee(zilences []*regexp.Regexp, precis string, noise string) string {
M web.goweb.go

@@ -883,6 +883,7 @@ return

} honk.Date = dt honk.What = "update" + honk.Format = "markdown" } else { xid := fmt.Sprintf("%s/%s/%s", user.URL, honkSep, xfiltrate()) what := "honk"

@@ -896,22 +897,13 @@ What: what,

Honker: user.URL, XID: xid, Date: dt, + Format: "markdown", } } - if strings.HasPrefix(noise, "DZ:") { - idx := strings.Index(noise, "\n") - if idx == -1 { - honk.Precis = noise - noise = "" - } else { - honk.Precis = noise[:idx] - noise = noise[idx+1:] - } - } - noise = quickrename(noise, userinfo.UserID) + noise = hooterize(noise) - noise = strings.TrimSpace(noise) - honk.Precis = strings.TrimSpace(honk.Precis) + honk.Noise = noise + translate(honk) var convoy string if rid != "" {

@@ -936,11 +928,12 @@ honk.RID = rid

} else { honk.Audience = []string{thewholeworld} } - if noise != "" && noise[0] == '@' { - honk.Audience = append(grapevine(noise), honk.Audience...) + if honk.Noise != "" && honk.Noise[0] == '@' { + honk.Audience = append(grapevine(honk.Noise), honk.Audience...) } else { - honk.Audience = append(honk.Audience, grapevine(noise)...) + honk.Audience = append(honk.Audience, grapevine(honk.Noise)...) } + if convoy == "" { convoy = "data:,electrichonkytonk-" + xfiltrate() }

@@ -952,8 +945,6 @@ http.Error(w, "honk to nowhere...", http.StatusNotFound)

return } honk.Public = !keepitquiet(honk.Audience) - noise = obfusbreak(noise) - honk.Noise = noise honk.Convoy = convoy donkxid := r.FormValue("donkxid")

@@ -1055,12 +1046,13 @@ log.Print(err)

} return } - honk.Onts = oneofakind(ontologies(honk.Noise)) honk.UserID = userinfo.UserID honk.RID = rid honk.Date = dt honk.Convoy = convoy - honk.Format = "html" + + // back to markdown + honk.Noise = noise if updatexid != "" { updatehonk(honk)