experiment with an out of band address input field

This commit is contained in:
Ted Unangst 2020-02-18 15:45:22 -05:00
parent 87104be774
commit 5628d0376a
4 changed files with 24 additions and 17 deletions

23
fun.go
View File

@ -287,19 +287,22 @@ func ontologies(s string) []string {
var re_mentions = regexp.MustCompile(`@[[:alnum:]._-]+@[[:alnum:].-]*[[:alnum:]]`) var re_mentions = regexp.MustCompile(`@[[:alnum:]._-]+@[[:alnum:].-]*[[:alnum:]]`)
var re_urltions = regexp.MustCompile(`@https://\S+`) var re_urltions = regexp.MustCompile(`@https://\S+`)
func grapevine(s string) []string { func grapevine(mentions []Mention) []string {
var mentions []string var s []string
m := re_mentions.FindAllString(s, -1) for _, m := range mentions {
for i := range m { s = append(s, m.Where)
where := gofish(m[i]) }
return s
}
func grapeape(s string) []Mention {
var mentions []Mention
for _, m := range strings.Split(s, " ") {
where := gofish(m)
if where != "" { 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 return mentions
} }

View File

@ -37,6 +37,8 @@
<p><label for=timeend>duration:</label><br> <p><label for=timeend>duration:</label><br>
<input type="text" name="timeend" value="{{ .Duration }}"> <input type="text" name="timeend" value="{{ .Duration }}">
</div> </div>
<p><label for=mentions>to:</label><br>
<input type="text" name="mentions" id=mentions value="{{ .Mentions }}">
</details> </details>
<p> <p>
<textarea name="noise" id="honknoise">{{ .Noise }}</textarea> <textarea name="noise" id="honknoise">{{ .Noise }}</textarea>

View File

@ -257,10 +257,10 @@ function showhonkform(elem, rid, hname) {
elem.insertAdjacentElement('afterend', form) elem.insertAdjacentElement('afterend', form)
} }
var ridinput = document.getElementById("ridinput") var ridinput = document.getElementById("ridinput")
var honknoise = document.getElementById("honknoise") var elmentions = document.getElementById("mentions")
if (rid) { if (rid) {
ridinput.value = rid ridinput.value = rid
honknoise.value = "@" + hname + " " elmentions.value = hname
} else { } else {
ridinput.value = "" ridinput.value = ""
honknoise.value = "" honknoise.value = ""

10
web.go
View File

@ -1436,6 +1436,7 @@ func submitwebhonk(w http.ResponseWriter, r *http.Request) {
func submithonk(w http.ResponseWriter, r *http.Request, isAPI bool) { func submithonk(w http.ResponseWriter, r *http.Request, isAPI bool) {
rid := r.FormValue("rid") rid := r.FormValue("rid")
noise := r.FormValue("noise") noise := r.FormValue("noise")
mentions := r.FormValue("mentions")
format := r.FormValue("format") format := r.FormValue("format")
if format == "" { if format == "" {
format = "markdown" format = "markdown"
@ -1480,7 +1481,7 @@ func submithonk(w http.ResponseWriter, r *http.Request, isAPI bool) {
noise = strings.Replace(noise, "\r", "", -1) noise = strings.Replace(noise, "\r", "", -1)
noise = quickrename(noise, userinfo.UserID) noise = quickrename(noise, userinfo.UserID)
noise = hooterize(noise) noise = hooterize(noise)
honk.Mentions = bunchofgrapes(noise) honk.Mentions = append(grapeape(mentions), bunchofgrapes(noise)...)
honk.Noise = noise honk.Noise = noise
translate(honk) translate(honk)
@ -1511,10 +1512,10 @@ func submithonk(w http.ResponseWriter, r *http.Request, isAPI bool) {
} else { } else {
honk.Audience = []string{thewholeworld} honk.Audience = []string{thewholeworld}
} }
if honk.Noise != "" && honk.Noise[0] == '@' { if mentions != "" {
honk.Audience = append(grapevine(honk.Noise), honk.Audience...) honk.Audience = append(grapevine(honk.Mentions), honk.Audience...)
} else { } else {
honk.Audience = append(honk.Audience, grapevine(honk.Noise)...) honk.Audience = append(honk.Audience, grapevine(honk.Mentions)...)
} }
if convoy == "" { if convoy == "" {
@ -1676,6 +1677,7 @@ func submithonk(w http.ResponseWriter, r *http.Request, isAPI bool) {
templinfo["MapLink"] = getmaplink(userinfo) templinfo["MapLink"] = getmaplink(userinfo)
templinfo["InReplyTo"] = r.FormValue("rid") templinfo["InReplyTo"] = r.FormValue("rid")
templinfo["Noise"] = r.FormValue("noise") templinfo["Noise"] = r.FormValue("noise")
templinfo["Mentions"] = r.FormValue("mentions")
templinfo["SavedFile"] = donkxid templinfo["SavedFile"] = donkxid
if tm := honk.Time; tm != nil { if tm := honk.Time; tm != nil {
templinfo["ShowTime"] = ";" templinfo["ShowTime"] = ";"