all repos — honk @ 00f50e19b5b54c849d988ca9816372c4c41c27e3

my fork of honk

experiment with an out of band address input field
Ted Unangst tedu@tedunangst.com
Tue, 18 Feb 2020 15:45:22 -0500
commit

00f50e19b5b54c849d988ca9816372c4c41c27e3

parent

208e3d2bc72b429eeaf075b2d9aed3871edf8fe7

4 files changed, 23 insertions(+), 16 deletions(-)

jump to
M fun.gofun.go

@@ -287,18 +287,21 @@

var re_mentions = regexp.MustCompile(`@[[:alnum:]._-]+@[[:alnum:].-]*[[:alnum:]]`) var re_urltions = regexp.MustCompile(`@https://\S+`) -func grapevine(s string) []string { - var mentions []string - m := re_mentions.FindAllString(s, -1) - for i := range m { - where := gofish(m[i]) +func grapevine(mentions []Mention) []string { + var s []string + for _, m := range mentions { + s = append(s, m.Where) + } + return s +} + +func grapeape(s string) []Mention { + var mentions []Mention + for _, m := range strings.Split(s, " ") { + where := gofish(m) if where != "" { - mentions = append(mentions, where) + mentions = append(mentions, Mention{Who: m, Where: where}) } - } - m = re_urltions.FindAllString(s, -1) - for i := range m { - mentions = append(mentions, m[i][1:]) } return mentions }
M views/honkform.htmlviews/honkform.html

@@ -37,6 +37,8 @@ <input type="text" name="timestart" value="{{ .StartTime }}">

<p><label for=timeend>duration:</label><br> <input type="text" name="timeend" value="{{ .Duration }}"> </div> +<p><label for=mentions>to:</label><br> +<input type="text" name="mentions" id=mentions value="{{ .Mentions }}"> </details> <p> <textarea name="noise" id="honknoise">{{ .Noise }}</textarea>
M views/honkpage.jsviews/honkpage.js

@@ -257,10 +257,10 @@ elem = document.getElementById("honkformhost")

elem.insertAdjacentElement('afterend', form) } var ridinput = document.getElementById("ridinput") - var honknoise = document.getElementById("honknoise") + var elmentions = document.getElementById("mentions") if (rid) { ridinput.value = rid - honknoise.value = "@" + hname + " " + elmentions.value = hname } else { ridinput.value = "" honknoise.value = ""
M web.goweb.go

@@ -1436,6 +1436,7 @@ // what a hot mess this function is

func submithonk(w http.ResponseWriter, r *http.Request, isAPI bool) { rid := r.FormValue("rid") noise := r.FormValue("noise") + mentions := r.FormValue("mentions") format := r.FormValue("format") if format == "" { format = "markdown"

@@ -1480,7 +1481,7 @@

noise = strings.Replace(noise, "\r", "", -1) noise = quickrename(noise, userinfo.UserID) noise = hooterize(noise) - honk.Mentions = bunchofgrapes(noise) + honk.Mentions = append(grapeape(mentions), bunchofgrapes(noise)...) honk.Noise = noise translate(honk)

@@ -1511,10 +1512,10 @@ }

} else { honk.Audience = []string{thewholeworld} } - if honk.Noise != "" && honk.Noise[0] == '@' { - honk.Audience = append(grapevine(honk.Noise), honk.Audience...) + if mentions != "" { + honk.Audience = append(grapevine(honk.Mentions), honk.Audience...) } else { - honk.Audience = append(honk.Audience, grapevine(honk.Noise)...) + honk.Audience = append(honk.Audience, grapevine(honk.Mentions)...) } if convoy == "" {

@@ -1676,6 +1677,7 @@ templinfo["Honks"] = honks

templinfo["MapLink"] = getmaplink(userinfo) templinfo["InReplyTo"] = r.FormValue("rid") templinfo["Noise"] = r.FormValue("noise") + templinfo["Mentions"] = r.FormValue("mentions") templinfo["SavedFile"] = donkxid if tm := honk.Time; tm != nil { templinfo["ShowTime"] = ";"