commit 5b7152e1711944ed170b8c352bde3f00e6c6b31b
parent 00f0dc21975e7103bc46f8a29e22c29706d357b0
Author: Peter Kosyh <p.kosyh@gmail.com>
Date: Fri, 4 Sep 2020 20:27:25 +0300
fixes
Diffstat:
5 files changed, 45 insertions(+), 19 deletions(-)
diff --git a/ii-node/lib/style.css b/ii-node/lib/style.css
@@ -20,7 +20,7 @@
margin-right:auto;
}
-#pager a, a:visited {
+#pager a, #pager a:visited {
color: #777777;
text-decoration: none;
}
@@ -108,11 +108,11 @@
background: #eaffff;
}
#topic .subj a, #topic .subj a:hover, #topic .subj a:visited {
- color: #ea5555;
+ color: #000000;
font-size: large;
text-decoration: none;
}
-#topic .reply a, #topic .reply a:hover, #topic .reply a:visited {
+#topic .reply a, #topic .reply a:hover, #topic .reply a:visited {
color: #ea5555;
text-decoration: none;
}
@@ -167,12 +167,21 @@
font-style: italic;
margin-top: 1em;
}
+.quote {
+ color: #555555;
+}
#profile td, #login td, #error td {
padding: 0.5em;
}
#profile .links, #login .links, #error .links {
text-align: center;
}
+
+.msgid {
+ color: #ea5555;
+ text-decoration: none;
+}
+
@media (max-width: 640px) {
.extra {
display: none;
diff --git a/ii-node/tpl/topic.tpl b/ii-node/tpl/topic.tpl
@@ -1,6 +1,5 @@
{{template "header.tpl" $}}
{{template "pager.tpl" $}}
-
<div id="topic">
{{ range .Msg }}
{{if eq $.Selected .MsgId }}
@@ -9,17 +8,16 @@
{{else}}
<div class="msg">
{{end}}
-<span class="subj"><a href="/{{. | repto}}#{{. | repto}}">{{.Subj}}</a></span><br>
+<a class="msgid" href="/{{.MsgId}}#{{.MsgId}}">#</a><span class="subj"><a href="/{{. | repto}}#{{. | repto}}">{{.Subj}}</a></span><br>
<span class="info">{{.From}}({{.Addr}}) — {{.To}}<br>{{.Date | fdate}}</span><br>
-<span class="text">
+<div class="text">
<br>
{{with .Text}}
{{. | msg_format}}
{{end}}
<br>
-<br>
-<span class="reply"><a href="/{{$.BasePath}}/reply">Reply</a></span><br>
-</span>
+<span class="reply"><a href="/{{.MsgId}}/reply">Reply</a></span><br>
+</div>
</div>
{{ end }}
</div>
diff --git a/ii-node/tpl/topics.tpl b/ii-node/tpl/topics.tpl
@@ -13,7 +13,7 @@
{{ else }}
<tr class="even">
{{ end }}
-<td class="topic"><a href="/{{.Head.MsgId}}">{{.Head.Subj}}</a></td>
+<td class="topic"><a href="/{{.Head.MsgId}}/1">{{.Head.Subj}}</a></td>
<td class="posts extra">{{.Count}}</td>
<td class="info"><a href="/{{.Tail.MsgId}}#{{.Tail.MsgId}}">{{.Tail.Date | fdate}}</a><br>by {{.Tail.From}}</td>
</tr>
diff --git a/ii-node/web.go b/ii-node/web.go
@@ -6,6 +6,7 @@ import (
"fmt"
"html/template"
"net/http"
+ "regexp"
"sort"
"strings"
"time"
@@ -28,7 +29,7 @@ type WebContext struct {
}
func www_register(user *ii.User, www WWW, w http.ResponseWriter, r *http.Request) error {
- ctx := WebContext{ User: user }
+ ctx := WebContext{ User: user }
ii.Trace.Printf("www register")
switch r.Method {
case "GET":
@@ -201,7 +202,6 @@ func makePager(ctx *WebContext, count int, page int) int {
func www_topics(user *ii.User, www WWW, w http.ResponseWriter, r *http.Request, echo string, page int) error {
db := www.db
ctx := WebContext{ User: user, Echo: echo }
-
mis := db.LookupIDS(db.SelectIDS(ii.Query{Echo: echo}))
ii.Trace.Printf("www topics: %s", echo)
topicsIds := getTopics(db, mis)
@@ -254,6 +254,9 @@ func www_topic(user *ii.User, www WWW, w http.ResponseWriter, r *http.Request, i
if mi == nil {
return errors.New("No such message")
}
+ if page == 0 {
+ ctx.Selected = id
+ }
ctx.Echo = mi.Echo
mis := db.LookupIDS(db.SelectIDS(ii.Query{Echo: mi.Echo}))
@@ -386,15 +389,28 @@ func www_reply(user *ii.User, www WWW, w http.ResponseWriter, r *http.Request, i
return nil
}
+func str_esc(l string) string {
+ l = strings.Replace(l, "&", "&", -1)
+ l = strings.Replace(l, "<", "<", -1)
+ l = strings.Replace(l, ">", ">", -1)
+ return l
+}
+
+var quoteRegex = regexp.MustCompile("^[^>]*>")
+
func msg_format(txt string) template.HTML {
txt = strings.Replace(txt, "\r", "", -1)
txt = strings.TrimLeft(txt, "\n")
txt = strings.TrimRight(txt, "\n")
txt = strings.TrimSuffix(txt, "\n")
- txt = strings.Replace(txt, "&", "&", -1)
- txt = strings.Replace(txt, "<", "<", -1)
- txt = strings.Replace(txt, ">", ">", -1)
- return template.HTML(strings.Replace(txt, "\n", "<br/>", -1))
+ f := ""
+ for _, l := range strings.Split(txt, "\n") {
+ if quoteRegex.MatchString(l) {
+ l = fmt.Sprintf("<span class=\"quote\">%s</span>", str_esc(l))
+ }
+ f += l + "<br>\n"
+ }
+ return template.HTML(f)
}
func WebInit(www *WWW, db *ii.DB) {
@@ -451,7 +467,7 @@ func _handleWWW(user *ii.User, www WWW, w http.ResponseWriter, r *http.Request)
} else if path == "register" {
return www_register(user, www, w, r)
} else if ii.IsMsgId(args[0]) {
- page := 1
+ page := 0
if len(args) > 1 {
if args[1] == "reply" {
return www_reply(user, www, w, r, args[0])
diff --git a/ii/msg.go b/ii/msg.go
@@ -75,12 +75,15 @@ func DecodeMsgline(msg string, enc bool) (*Msg, error) {
m.Tags, _ = MakeTags("ii/ok")
if strings.HasPrefix(repto, "@repto:") {
start += 1
- m.Tags.Add("repto/" + strings.Trim(strings.Split(repto, ":")[1], " "))
+ repto = strings.Trim(strings.Split(repto, ":")[1], " ")
+ m.Tags.Add("repto/" + repto)
+ Trace.Printf("Add repto tag: %s", repto)
}
for i := start; i < len(text); i++ {
m.Text += text[i] + "\n"
}
m.Text = strings.TrimSuffix(m.Text, "\n")
+ Trace.Printf("Final message: %s\n", m.String())
return &m, nil
}
@@ -154,7 +157,7 @@ func NewTags(str string) Tags {
return t
}
-func (t Tags) Add(str string) error {
+func (t *Tags) Add(str string) error {
tags := strings.Split(str, "/")
if len(tags)%2 != 0 {
return errors.New("Wrong tags")