commit 2eb9377cc00215a4e1fd455fe6e014bd910624af
parent 53ab6042eee3185f3223651eac6b97e9bc0c677d
Author: Peter Kosyh <p.kosyh@gmail.com>
Date: Sat, 5 Sep 2020 22:22:19 +0300
reply topic
Diffstat:
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/ii-node/tpl/header.tpl b/ii-node/tpl/header.tpl
@@ -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>
diff --git a/ii-node/web.go b/ii-node/web.go
@@ -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 {
diff --git a/ii/db.go b/ii/db.go
@@ -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 {