move mentions to mz module
This commit is contained in:
parent
a7dbec14c4
commit
7fb5c94554
|
@ -1099,12 +1099,6 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
|
|||
if !h.Public {
|
||||
jo["directMessage"] = true
|
||||
}
|
||||
var mentions []Mention
|
||||
if len(h.Mentions) > 0 {
|
||||
mentions = h.Mentions
|
||||
} else {
|
||||
mentions = bunchofgrapes(h.Noise)
|
||||
}
|
||||
translate(h)
|
||||
redoimages(h)
|
||||
if h.Precis != "" {
|
||||
|
@ -1124,7 +1118,7 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
|
|||
}
|
||||
|
||||
var tags []junk.Junk
|
||||
for _, m := range mentions {
|
||||
for _, m := range h.Mentions {
|
||||
t := junk.New()
|
||||
t["type"] = "Mention"
|
||||
t["name"] = m.Who
|
||||
|
|
24
fun.go
24
fun.go
|
@ -33,8 +33,8 @@ import (
|
|||
"humungus.tedunangst.com/r/webs/cache"
|
||||
"humungus.tedunangst.com/r/webs/htfilter"
|
||||
"humungus.tedunangst.com/r/webs/httpsig"
|
||||
"humungus.tedunangst.com/r/webs/templates"
|
||||
"humungus.tedunangst.com/r/webs/mz"
|
||||
"humungus.tedunangst.com/r/webs/templates"
|
||||
)
|
||||
|
||||
var allowedclasses = make(map[string]bool)
|
||||
|
@ -68,7 +68,6 @@ func reverbolate(userid int64, honks []*Honk) {
|
|||
}
|
||||
if local && h.What != "bonked" {
|
||||
h.Noise = re_memes.ReplaceAllString(h.Noise, "")
|
||||
h.Noise = mentionize(h.Noise)
|
||||
}
|
||||
h.Username, h.Handle = handles(h.Honker)
|
||||
if !local {
|
||||
|
@ -238,10 +237,12 @@ func translate(honk *Honk) {
|
|||
|
||||
var marker mz.Marker
|
||||
marker.HashLinker = ontoreplacer
|
||||
marker.AtLinker = attoreplacer
|
||||
noise = strings.TrimSpace(noise)
|
||||
noise = marker.Mark(noise)
|
||||
honk.Noise = noise
|
||||
honk.Onts = oneofakind(marker.HashTags)
|
||||
honk.Mentions = bunchofgrapes(marker.Mentions)
|
||||
}
|
||||
|
||||
func redoimages(honk *Honk) {
|
||||
|
@ -265,7 +266,6 @@ func redoimages(honk *Honk) {
|
|||
honk.Donks = honk.Donks[:j]
|
||||
|
||||
honk.Noise = re_memes.ReplaceAllString(honk.Noise, "")
|
||||
honk.Noise = mentionize(honk.Noise)
|
||||
honk.Noise = strings.Replace(honk.Noise, "<a href=", "<a class=\"mention u-url\" href=", -1)
|
||||
}
|
||||
|
||||
|
@ -290,9 +290,6 @@ func xfiltrate() string {
|
|||
return xcelerate(b[:])
|
||||
}
|
||||
|
||||
var re_mentions = regexp.MustCompile(`@[[:alnum:]._-]+@[[:alnum:].-]*[[:alnum:]]`)
|
||||
var re_urltions = regexp.MustCompile(`@https://\S+`)
|
||||
|
||||
func grapevine(mentions []Mention) []string {
|
||||
var s []string
|
||||
for _, m := range mentions {
|
||||
|
@ -301,8 +298,7 @@ func grapevine(mentions []Mention) []string {
|
|||
return s
|
||||
}
|
||||
|
||||
func bunchofgrapes(s string) []Mention {
|
||||
m := re_mentions.FindAllString(s, -1)
|
||||
func bunchofgrapes(m []string) []Mention {
|
||||
var mentions []Mention
|
||||
for i := range m {
|
||||
where := gofish(m[i])
|
||||
|
@ -310,10 +306,6 @@ func bunchofgrapes(s string) []Mention {
|
|||
mentions = append(mentions, Mention{Who: m[i], Where: where})
|
||||
}
|
||||
}
|
||||
m = re_urltions.FindAllString(s, -1)
|
||||
for i := range m {
|
||||
mentions = append(mentions, Mention{Who: m[i][1:], Where: m[i][1:]})
|
||||
}
|
||||
return mentions
|
||||
}
|
||||
|
||||
|
@ -459,20 +451,14 @@ func fullname(name string, userid int64) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func mentionize(s string) string {
|
||||
func attoreplacer(m string) string {
|
||||
fill := `<span class="h-card"><a class="u-url mention" href="%s">%s</a></span>`
|
||||
s = re_mentions.ReplaceAllStringFunc(s, func(m string) string {
|
||||
where := gofish(m)
|
||||
if where == "" {
|
||||
return m
|
||||
}
|
||||
who := m[0 : 1+strings.IndexByte(m[1:], '@')]
|
||||
return fmt.Sprintf(fill, html.EscapeString(where), html.EscapeString(who))
|
||||
})
|
||||
s = re_urltions.ReplaceAllStringFunc(s, func(m string) string {
|
||||
return fmt.Sprintf(fill, html.EscapeString(m[1:]), html.EscapeString(m))
|
||||
})
|
||||
return s
|
||||
}
|
||||
|
||||
func ontoreplacer(h string) string {
|
||||
|
|
5
web.go
5
web.go
|
@ -1600,7 +1600,6 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk {
|
|||
noise = strings.Replace(noise, "\r", "", -1)
|
||||
noise = quickrename(noise, userinfo.UserID)
|
||||
noise = hooterize(noise)
|
||||
honk.Mentions = bunchofgrapes(noise)
|
||||
honk.Noise = noise
|
||||
translate(honk)
|
||||
|
||||
|
@ -1632,9 +1631,9 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk {
|
|||
honk.Audience = []string{thewholeworld}
|
||||
}
|
||||
if honk.Noise != "" && honk.Noise[0] == '@' {
|
||||
honk.Audience = append(grapevine(bunchofgrapes(honk.Noise)), honk.Audience...)
|
||||
honk.Audience = append(grapevine(honk.Mentions), honk.Audience...)
|
||||
} else {
|
||||
honk.Audience = append(honk.Audience, grapevine(bunchofgrapes(honk.Noise))...)
|
||||
honk.Audience = append(honk.Audience, grapevine(honk.Mentions)...)
|
||||
}
|
||||
|
||||
if convoy == "" {
|
||||
|
|
Loading…
Reference in New Issue