From 5628d0376a6b6b05ddc18d1d1142e34600c9c85c Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 18 Feb 2020 15:45:22 -0500 Subject: [PATCH] experiment with an out of band address input field --- fun.go | 25 ++++++++++++++----------- views/honkform.html | 2 ++ views/honkpage.js | 4 ++-- web.go | 10 ++++++---- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/fun.go b/fun.go index 3e1629d..b6e375c 100644 --- a/fun.go +++ b/fun.go @@ -287,18 +287,21 @@ func ontologies(s string) []string { 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]) - if where != "" { - mentions = append(mentions, where) - } +func grapevine(mentions []Mention) []string { + var s []string + for _, m := range mentions { + s = append(s, m.Where) } - m = re_urltions.FindAllString(s, -1) - for i := range m { - mentions = append(mentions, m[i][1:]) + return s +} + +func grapeape(s string) []Mention { + var mentions []Mention + for _, m := range strings.Split(s, " ") { + where := gofish(m) + if where != "" { + mentions = append(mentions, Mention{Who: m, Where: where}) + } } return mentions } diff --git a/views/honkform.html b/views/honkform.html index 7f33eb0..2acfb79 100644 --- a/views/honkform.html +++ b/views/honkform.html @@ -37,6 +37,8 @@


+


+

diff --git a/views/honkpage.js b/views/honkpage.js index bba11d2..80956d3 100644 --- a/views/honkpage.js +++ b/views/honkpage.js @@ -257,10 +257,10 @@ function showhonkform(elem, rid, hname) { 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 = "" diff --git a/web.go b/web.go index 0c5dbc0..51c2ede 100644 --- a/web.go +++ b/web.go @@ -1436,6 +1436,7 @@ func submitwebhonk(w http.ResponseWriter, r *http.Request) { 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 @@ func submithonk(w http.ResponseWriter, r *http.Request, isAPI bool) { 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 @@ func submithonk(w http.ResponseWriter, r *http.Request, isAPI bool) { } 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 @@ func submithonk(w http.ResponseWriter, r *http.Request, isAPI bool) { 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"] = ";"