From a7dbec14c4c06fa908a35c15f3e5c361dc53b794 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 20 Jul 2020 23:00:36 -0400 Subject: [PATCH] move hashtag to mz module --- fun.go | 44 ++++++++------------------------------------ markitzero.go | 2 +- 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/fun.go b/fun.go index 1b427bd..8988c8c 100644 --- a/fun.go +++ b/fun.go @@ -34,6 +34,7 @@ import ( "humungus.tedunangst.com/r/webs/htfilter" "humungus.tedunangst.com/r/webs/httpsig" "humungus.tedunangst.com/r/webs/templates" + "humungus.tedunangst.com/r/webs/mz" ) var allowedclasses = make(map[string]bool) @@ -68,7 +69,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.Noise = ontologize(h.Noise) } h.Username, h.Handle = handles(h.Honker) if !local { @@ -236,10 +236,12 @@ func translate(honk *Honk) { } honk.Precis = markitzero(strings.TrimSpace(honk.Precis)) + var marker mz.Marker + marker.HashLinker = ontoreplacer noise = strings.TrimSpace(noise) - noise = markitzero(noise) + noise = marker.Mark(noise) honk.Noise = noise - honk.Onts = oneofakind(ontologies(honk.Noise)) + honk.Onts = oneofakind(marker.HashTags) } func redoimages(honk *Honk) { @@ -263,7 +265,7 @@ func redoimages(honk *Honk) { honk.Donks = honk.Donks[:j] honk.Noise = re_memes.ReplaceAllString(honk.Noise, "") - honk.Noise = ontologize(mentionize(honk.Noise)) + honk.Noise = mentionize(honk.Noise) honk.Noise = strings.Replace(honk.Noise, "%s`, p, serverName, +func ontoreplacer(h string) string { + return fmt.Sprintf(`%s`, serverName, strings.ToLower(h[1:]), h) - }) - return s } var re_unurl = regexp.MustCompile("https://([^/]+).*/([^/]+)") diff --git a/markitzero.go b/markitzero.go index 23c1cf4..49b3c74 100644 --- a/markitzero.go +++ b/markitzero.go @@ -16,7 +16,7 @@ package main import ( - mz "humungus.tedunangst.com/r/webs/markitzero" + "humungus.tedunangst.com/r/webs/mz" ) func markitzero(s string) string {