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

25
fun.go
View File

@ -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
}

View File

@ -37,6 +37,8 @@
<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>

View File

@ -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 = ""

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) {
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"] = ";"