move emuxifier into html filter to avoid link damage
This commit is contained in:
parent
4e052bcfde
commit
4b89e0a43a
|
@ -2,6 +2,8 @@ changelog
|
||||||
|
|
||||||
=== next
|
=== next
|
||||||
|
|
||||||
|
+ Reduce interference between various text substitution rules.
|
||||||
|
|
||||||
+ Fix crash in search with extra space.
|
+ Fix crash in search with extra space.
|
||||||
|
|
||||||
+ Fix pubkey issue with domain only keys.
|
+ Fix pubkey issue with domain only keys.
|
||||||
|
|
57
fun.go
57
fun.go
|
@ -97,6 +97,29 @@ func reverbolate(userid int64, honks []*Honk) {
|
||||||
htf.Imager = replaceimgsand(zap, false)
|
htf.Imager = replaceimgsand(zap, false)
|
||||||
htf.SpanClasses = allowedclasses
|
htf.SpanClasses = allowedclasses
|
||||||
htf.BaseURL, _ = url.Parse(h.XID)
|
htf.BaseURL, _ = url.Parse(h.XID)
|
||||||
|
emuxifier := func(e string) string {
|
||||||
|
for _, d := range h.Donks {
|
||||||
|
if d.Name == e {
|
||||||
|
zap[d.XID] = true
|
||||||
|
if d.Local {
|
||||||
|
return fmt.Sprintf(`<img class="emu" title="%s" src="/d/%s">`, d.Name, d.XID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if local && h.What != "bonked" {
|
||||||
|
var emu Emu
|
||||||
|
emucache.Get(e, &emu)
|
||||||
|
if emu.ID != "" {
|
||||||
|
return fmt.Sprintf(`<img class="emu" title="%s" src="%s">`, emu.Name, emu.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
htf.FilterText = func(w io.Writer, data string) {
|
||||||
|
data = htfilter.EscapeText(data)
|
||||||
|
data = re_emus.ReplaceAllStringFunc(data, emuxifier)
|
||||||
|
io.WriteString(w, data)
|
||||||
|
}
|
||||||
p, _ := htf.String(h.Precis)
|
p, _ := htf.String(h.Precis)
|
||||||
n, _ := htf.String(h.Noise)
|
n, _ := htf.String(h.Noise)
|
||||||
h.Precis = string(p)
|
h.Precis = string(p)
|
||||||
|
@ -115,41 +138,7 @@ func reverbolate(userid int64, honks []*Honk) {
|
||||||
unsee(honks, userid)
|
unsee(honks, userid)
|
||||||
|
|
||||||
for _, h := range honks {
|
for _, h := range honks {
|
||||||
local := false
|
|
||||||
if h.Whofore == 2 || h.Whofore == 3 {
|
|
||||||
local = true
|
|
||||||
}
|
|
||||||
zap := make(map[string]bool)
|
|
||||||
emuxifier := func(e string) string {
|
|
||||||
for _, d := range h.Donks {
|
|
||||||
if d.Name == e {
|
|
||||||
zap[d.XID] = true
|
|
||||||
if d.Local {
|
|
||||||
return fmt.Sprintf(`<img class="emu" title="%s" src="/d/%s">`, d.Name, d.XID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if local && h.What != "bonked" {
|
|
||||||
var emu Emu
|
|
||||||
emucache.Get(e, &emu)
|
|
||||||
if emu.ID != "" {
|
|
||||||
return fmt.Sprintf(`<img class="emu" title="%s" src="%s">`, emu.Name, emu.ID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return e
|
|
||||||
}
|
|
||||||
renderflags(h)
|
renderflags(h)
|
||||||
h.Precis = re_emus.ReplaceAllStringFunc(h.Precis, emuxifier)
|
|
||||||
h.Noise = re_emus.ReplaceAllStringFunc(h.Noise, emuxifier)
|
|
||||||
|
|
||||||
j := 0
|
|
||||||
for i := 0; i < len(h.Donks); i++ {
|
|
||||||
if !zap[h.Donks[i].XID] {
|
|
||||||
h.Donks[j] = h.Donks[i]
|
|
||||||
j++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
h.Donks = h.Donks[:j]
|
|
||||||
|
|
||||||
h.HTPrecis = template.HTML(h.Precis)
|
h.HTPrecis = template.HTML(h.Precis)
|
||||||
h.HTML = template.HTML(h.Noise)
|
h.HTML = template.HTML(h.Noise)
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -9,5 +9,5 @@ require (
|
||||||
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4
|
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859
|
||||||
humungus.tedunangst.com/r/go-sqlite3 v1.1.3
|
humungus.tedunangst.com/r/go-sqlite3 v1.1.3
|
||||||
humungus.tedunangst.com/r/webs v0.6.42
|
humungus.tedunangst.com/r/webs v0.6.43
|
||||||
)
|
)
|
||||||
|
|
6
go.sum
6
go.sum
|
@ -22,7 +22,5 @@ golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9ga8k38geUI=
|
humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9ga8k38geUI=
|
||||||
humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M=
|
humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M=
|
||||||
humungus.tedunangst.com/r/webs v0.6.41 h1:kteIzz03ij7EujsLLbRlquSgONRzoqIm1o1Bc5ie6HU=
|
humungus.tedunangst.com/r/webs v0.6.43 h1:V7tmvzXi/LETO2QfHyqvIivi1kbjRSHQoDFcR3hML+k=
|
||||||
humungus.tedunangst.com/r/webs v0.6.41/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps=
|
humungus.tedunangst.com/r/webs v0.6.43/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps=
|
||||||
humungus.tedunangst.com/r/webs v0.6.42 h1:y1j7Z04Bs8/UmzYwsQb2OfOs1F1veJ6u9bwjc70PhLo=
|
|
||||||
humungus.tedunangst.com/r/webs v0.6.42/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps=
|
|
||||||
|
|
Loading…
Reference in New Issue