make redoimages a separate function

This commit is contained in:
Ted Unangst 2019-12-04 02:30:07 -05:00
parent 0df1a08165
commit 50fb0d5e09
3 changed files with 28 additions and 27 deletions

View File

@ -1027,7 +1027,8 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
jo["directMessage"] = true jo["directMessage"] = true
} }
mentions := bunchofgrapes(h.Noise) mentions := bunchofgrapes(h.Noise)
translate(h, true) translate(h)
redoimages(h)
jo["summary"] = html.EscapeString(h.Precis) jo["summary"] = html.EscapeString(h.Precis)
jo["content"] = h.Noise jo["content"] = h.Noise
if h.Precis != "" { if h.Precis != "" {

50
fun.go
View File

@ -61,7 +61,7 @@ func reverbolate(userid int64, honks []*Honk) {
if !h.Public { if !h.Public {
h.Style += " limited" h.Style += " limited"
} }
translate(h, false) translate(h)
local := false local := false
if (h.Whofore == 2 || h.Whofore == 3) && h.What != "bonked" { if (h.Whofore == 2 || h.Whofore == 3) && h.What != "bonked" {
local = true local = true
@ -198,7 +198,7 @@ func imaginate(honk *Honk) {
htf.String(honk.Noise) htf.String(honk.Noise)
} }
func translate(honk *Honk, redoimages bool) { func translate(honk *Honk) {
if honk.Format == "html" { if honk.Format == "html" {
return return
} }
@ -219,31 +219,31 @@ func translate(honk *Honk, redoimages bool) {
noise = markitzero(noise) noise = markitzero(noise)
honk.Noise = noise honk.Noise = noise
honk.Onts = oneofakind(ontologies(honk.Noise)) honk.Onts = oneofakind(ontologies(honk.Noise))
}
if redoimages { func redoimages(honk *Honk) {
zap := make(map[string]bool) zap := make(map[string]bool)
{ {
var htf htfilter.Filter var htf htfilter.Filter
htf.Imager = replaceimgsand(zap, true) htf.Imager = replaceimgsand(zap, true)
htf.SpanClasses = allowedclasses htf.SpanClasses = allowedclasses
p, _ := htf.String(honk.Precis) p, _ := htf.String(honk.Precis)
n, _ := htf.String(honk.Noise) n, _ := htf.String(honk.Noise)
honk.Precis = string(p) honk.Precis = string(p)
honk.Noise = string(n) honk.Noise = string(n)
}
j := 0
for i := 0; i < len(honk.Donks); i++ {
if !zap[honk.Donks[i].XID] {
honk.Donks[j] = honk.Donks[i]
j++
}
}
honk.Donks = honk.Donks[:j]
honk.Noise = re_memes.ReplaceAllString(honk.Noise, "")
honk.Noise = ontologize(mentionize(honk.Noise))
honk.Noise = strings.Replace(honk.Noise, "<a href=", "<a class=\"mention u-url\" href=", -1)
} }
j := 0
for i := 0; i < len(honk.Donks); i++ {
if !zap[honk.Donks[i].XID] {
honk.Donks[j] = honk.Donks[i]
j++
}
}
honk.Donks = honk.Donks[:j]
honk.Noise = re_memes.ReplaceAllString(honk.Noise, "")
honk.Noise = ontologize(mentionize(honk.Noise))
honk.Noise = strings.Replace(honk.Noise, "<a href=", "<a class=\"mention u-url\" href=", -1)
} }
func xcelerate(b []byte) string { func xcelerate(b []byte) string {

2
web.go
View File

@ -1441,7 +1441,7 @@ func submithonk(w http.ResponseWriter, r *http.Request, isAPI bool) {
noise = hooterize(noise) noise = hooterize(noise)
honk.Mentions = bunchofgrapes(noise) honk.Mentions = bunchofgrapes(noise)
honk.Noise = noise honk.Noise = noise
translate(honk, false) translate(honk)
var convoy string var convoy string
if rid != "" { if rid != "" {