diff --git a/activity.go b/activity.go index 3c211a1..f0dd39b 100644 --- a/activity.go +++ b/activity.go @@ -1242,6 +1242,7 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) { if !h.Public { jo["directMessage"] = true } + h.Noise = re_retag.ReplaceAllString(h.Noise, "") translate(h) redoimages(h) if h.Precis != "" { diff --git a/fun.go b/fun.go index 4524ebd..09327e3 100644 --- a/fun.go +++ b/fun.go @@ -82,6 +82,7 @@ func reverbolate(userid int64, honks []*Honk) { local = true } if local && h.What != "bonked" { + h.Noise = re_retag.ReplaceAllString(h.Noise, "") h.Noise = re_memes.ReplaceAllString(h.Noise, "") } h.Username, h.Handle = handles(h.Honker) @@ -124,11 +125,27 @@ func reverbolate(userid int64, honks []*Honk) { h.Precis = demoji(h.Precis) h.Noise = demoji(h.Noise) h.Open = "open" + var misto string for _, m := range h.Mentions { if m.Where != h.Honker && !m.IsPresent(h.Noise) { - h.Noise = "(" + m.Who + ")" + h.Noise + misto += "(" + m.Who + ")" } } + var mistag string + for _, o := range h.Onts { + if !OntIsPresent(o, h.Noise) { + mistag += "(" + o + ")" + } + } + if len(misto) > 0 || len(mistag) > 0 { + if len(misto) > 0 { + misto = misto + "

" + } + if len(mistag) > 0 { + mistag = "

" + mistag + } + h.Noise = misto + h.Noise + mistag + } zap := make(map[string]bool) { @@ -329,7 +346,7 @@ func translate(honk *Honk) { noise = strings.TrimSpace(noise) noise = marker.Mark(noise) honk.Noise = noise - honk.Onts = oneofakind(marker.HashTags) + honk.Onts = oneofakind(append(honk.Onts, marker.HashTags...)) honk.Mentions = bunchofgrapes(marker.Mentions) } @@ -438,6 +455,7 @@ var re_memes = regexp.MustCompile("meme: ?([^\n]+)") var re_avatar = regexp.MustCompile("avatar: ?([^\n]+)") var re_banner = regexp.MustCompile("banner: ?([^\n]+)") var re_convoy = regexp.MustCompile("convoy: ?([^\n]+)") +var re_retag = regexp.MustCompile("tags: ?([^\n]+)") var re_convalidate = regexp.MustCompile("^(https?|tag|data):") func memetize(honk *Honk) { @@ -475,6 +493,24 @@ func memetize(honk *Honk) { honk.Noise = re_memes.ReplaceAllStringFunc(honk.Noise, repl) } +func recategorize(honk *Honk) { + repl := func(x string) string { + x = x[5:] + for _, t := range strings.Split(x, " ") { + if t == "" { + continue + } + if t[0] != '#' { + t = "#" + t + } + dlog.Printf("hashtag: %s", t) + honk.Onts = append(honk.Onts, t) + } + return "" + } + honk.Noise = re_retag.ReplaceAllStringFunc(honk.Noise, repl) +} + var re_quickmention = regexp.MustCompile("(^|[ \n])@[[:alnum:]_]+([ \n:;.,']|$)") func quickrename(s string, userid int64) string { diff --git a/honk.go b/honk.go index 1f6d09e..80b3584 100644 --- a/honk.go +++ b/honk.go @@ -144,6 +144,11 @@ func (mention *Mention) IsPresent(noise string) bool { return strings.Contains(noise, ">@"+nick) || strings.Contains(noise, "@"+nick) } +func OntIsPresent(ont, noise string) bool { + ont = ont[1:] + return strings.Contains(noise, ">#"+ont) || strings.Contains(noise, "#"+ont) +} + type OldRevision struct { Precis string Noise string diff --git a/web.go b/web.go index a61d3ae..c7507cc 100644 --- a/web.go +++ b/web.go @@ -1743,6 +1743,7 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk { honk.Noise = noise precipitate(honk) noise = honk.Noise + recategorize(honk) translate(honk) if rid != "" {