all repos — honk @ c4e87eac3c839f809460c4778371e18cb12be564

my fork of honk

remove inline meme text from post
Ted Unangst tedu@tedunangst.com
Sun, 30 Jun 2019 19:04:37 -0400
commit

c4e87eac3c839f809460c4778371e18cb12be564

parent

fb041c8ad9a9d86390275c95b38643420b0b3d5d

2 files changed, 10 insertions(+), 10 deletions(-)

jump to
M fun.gofun.go

@@ -192,10 +192,8 @@ }

var re_memes = regexp.MustCompile("meme: ?([[:alnum:]_.-]+)") -func memetics(noise string) []*Donk { - var donks []*Donk - m := re_memes.FindAllString(noise, -1) - for _, x := range m { +func memetize(honk *Honk) { + repl := func(x string) string { name := x[5:] if name[0] == ' ' { name = name[1:]

@@ -203,7 +201,7 @@ }

fd, err := os.Open("memes/" + name) if err != nil { log.Printf("no meme for %s", name) - continue + return x } var peek [512]byte n, _ := fd.Read(peek[:])

@@ -214,7 +212,7 @@ url := fmt.Sprintf("https://%s/meme/%s", serverName, name)

res, err := stmtSaveFile.Exec("", name, url, ct, 0, "") if err != nil { log.Printf("error saving meme: %s", err) - continue + return x } var d Donk d.FileID, _ = res.LastInsertId()

@@ -223,9 +221,11 @@ d.Name = name

d.Media = ct d.URL = url d.Local = false - donks = append(donks, &d) + honk.Donks = append(honk.Donks, &d) + log.Printf("replace with -") + return "" } - return donks + honk.Noise = re_memes.ReplaceAllStringFunc(honk.Noise, repl) } var re_bolder = regexp.MustCompile(`(^|\W)\*\*([\w\s,.!?'-]+)\*\*($|\W)`)
M honk.gohonk.go

@@ -1047,7 +1047,7 @@ donk.Name = e.Name

honk.Donks = append(honk.Donks, donk) } } - honk.Donks = append(honk.Donks, memetics(honk.Noise)...) + memetize(&honk) aud := strings.Join(honk.Audience, " ") whofore := 2

@@ -1069,7 +1069,7 @@ }

return } res, err := stmtSaveHonk.Exec(userinfo.UserID, what, honk.Honker, xid, rid, - dt.Format(dbtimeformat), "", aud, noise, convoy, whofore, "html", honk.Precis, honk.Oonker) + dt.Format(dbtimeformat), "", aud, honk.Noise, convoy, whofore, "html", honk.Precis, honk.Oonker) if err != nil { log.Printf("error saving honk: %s", err) return