better quick rename needs to be earlier for consistency
This commit is contained in:
parent
ea81f1fa20
commit
d8f6060163
13
fun.go
13
fun.go
|
@ -204,7 +204,6 @@ func translate(honk *Honk, redoimages bool) {
|
||||||
honk.Precis = markitzero(strings.TrimSpace(honk.Precis))
|
honk.Precis = markitzero(strings.TrimSpace(honk.Precis))
|
||||||
|
|
||||||
noise = strings.TrimSpace(noise)
|
noise = strings.TrimSpace(noise)
|
||||||
noise = quickrename(noise, honk.UserID)
|
|
||||||
noise = markitzero(noise)
|
noise = markitzero(noise)
|
||||||
honk.Noise = noise
|
honk.Noise = noise
|
||||||
honk.Onts = oneofakind(ontologies(honk.Noise))
|
honk.Onts = oneofakind(ontologies(honk.Noise))
|
||||||
|
@ -375,7 +374,7 @@ func memetize(honk *Honk) {
|
||||||
honk.Noise = re_memes.ReplaceAllStringFunc(honk.Noise, repl)
|
honk.Noise = re_memes.ReplaceAllStringFunc(honk.Noise, repl)
|
||||||
}
|
}
|
||||||
|
|
||||||
var re_quickmention = regexp.MustCompile("(^| )@[[:alnum:]]+( |$)")
|
var re_quickmention = regexp.MustCompile("(^|[ \n])@[[:alnum:]]+([ \n]|$)")
|
||||||
|
|
||||||
func quickrename(s string, userid int64) string {
|
func quickrename(s string, userid int64) string {
|
||||||
nonstop := true
|
nonstop := true
|
||||||
|
@ -383,13 +382,15 @@ func quickrename(s string, userid int64) string {
|
||||||
nonstop = false
|
nonstop = false
|
||||||
s = re_quickmention.ReplaceAllStringFunc(s, func(m string) string {
|
s = re_quickmention.ReplaceAllStringFunc(s, func(m string) string {
|
||||||
prefix := ""
|
prefix := ""
|
||||||
if m[0] == ' ' {
|
if m[0] == ' ' || m[0] == '\n' {
|
||||||
prefix = " "
|
prefix = m[:1]
|
||||||
m = m[1:]
|
m = m[1:]
|
||||||
}
|
}
|
||||||
prefix += "@"
|
prefix += "@"
|
||||||
m = m[1:]
|
m = m[1:]
|
||||||
if m[len(m)-1] == ' ' {
|
tail := ""
|
||||||
|
if m[len(m)-1] == ' ' || m[len(m)-1] == '\n' {
|
||||||
|
tail = m[len(m)-1:]
|
||||||
m = m[:len(m)-1]
|
m = m[:len(m)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +403,7 @@ func quickrename(s string, userid int64) string {
|
||||||
m = name
|
m = name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return prefix + m + " "
|
return prefix + m + tail
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
|
|
2
web.go
2
web.go
|
@ -1342,6 +1342,8 @@ func submithonk(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
noise = strings.Replace(noise, "\r", "", -1)
|
||||||
|
noise = quickrename(noise, userinfo.UserID)
|
||||||
noise = hooterize(noise)
|
noise = hooterize(noise)
|
||||||
honk.Noise = noise
|
honk.Noise = noise
|
||||||
translate(honk, false)
|
translate(honk, false)
|
||||||
|
|
Loading…
Reference in New Issue