reply topic

pull/1/head
Peter Kosyh 2020-09-05 22:22:19 +03:00
parent 53ab6042ee
commit 2eb9377cc0
3 changed files with 14 additions and 1 deletions

View File

@ -28,8 +28,12 @@
{{ end }}
{{ with .Echo }}
{{ if $.Topic }}
:: <a href="/{{$.Topic}}/reply">Reply topic</a>
{{ else }}
:: <a href="/{{.}}/new">New topic</a>
{{ end }}
{{ end }}
{{ else if eq .BasePath "login" }}
<a href="/register">Register</a>

View File

@ -17,6 +17,7 @@ const PAGE_SIZE = 100
type WebContext struct {
Echoes []*ii.Echo
Topics []*Topic
Topic string
Msg []*ii.Msg
Error string
Echo string
@ -269,6 +270,7 @@ func www_topic(user *ii.User, www WWW, w http.ResponseWriter, r *http.Request, i
}
topic = p.Id
}
ctx.Topic = topic
ids := getTopics(db, mis)[topic]
if len(ids) == 0 {
ids = append(ids, id)
@ -464,6 +466,10 @@ func msg_quote(txt string) string {
txt = msg_clean(txt)
f := ""
for _, l := range strings.Split(txt, "\n") {
if strings.Trim(l, " ") == "" {
f += l + "\n"
continue
}
if strings.HasPrefix(l, ">") {
f += ">"+ l + "\n"
} else {

View File

@ -608,7 +608,10 @@ type UDB struct {
}
func IsUsername(u string) bool {
return !strings.ContainsAny(u, ":\n \r\t") && len(u) <= 16 && len(u) > 2
return !strings.ContainsAny(u, ":\n\r\t") &&
!strings.HasPrefix(u, " ") &&
!strings.HasSuffix(u, " ") &&
len(u) <= 16 && len(u) > 2
}
func IsPassword(u string) bool {