Linkify address lists
This commit is contained in:
parent
0c21c501ff
commit
e2d70ba6ca
3 changed files with 17 additions and 12 deletions
|
@ -49,24 +49,32 @@
|
|||
</form>
|
||||
{{end}}
|
||||
|
||||
{{define "addr-list"}}
|
||||
{{range $i := .}}
|
||||
{{if $i}},{{end}}
|
||||
{{.PersonalName}}
|
||||
<<a href="/compose?to={{.Address}}">{{.Address}}</a>>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<strong>Date</strong>: {{.Message.Envelope.Date | formatdate}}
|
||||
</li>
|
||||
<li>
|
||||
<strong>From</strong>: {{.Message.Envelope.From | formataddrlist}}
|
||||
<strong>From</strong>: {{template "addr-list" .Message.Envelope.From}}
|
||||
</li>
|
||||
<li>
|
||||
<strong>To</strong>: {{.Message.Envelope.To | formataddrlist}}
|
||||
<strong>To</strong>: {{template "addr-list" .Message.Envelope.To}}
|
||||
</li>
|
||||
{{if .Message.Envelope.Cc}}
|
||||
<li>
|
||||
<strong>Cc</strong>: {{.Message.Envelope.Cc | formataddrlist}}
|
||||
<strong>Cc</strong>: {{template "addr-list" .Message.Envelope.Cc}}
|
||||
</li>
|
||||
{{end}}
|
||||
{{if .Message.Envelope.Bcc}}
|
||||
<li>
|
||||
<strong>Bcc</strong>: {{.Message.Envelope.Bcc | formataddrlist}}
|
||||
<strong>Bcc</strong>: {{template "addr-list" .Message.Envelope.Bcc}}
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
|
|
@ -263,6 +263,11 @@ func handleCompose(ectx echo.Context) error {
|
|||
msg.From = ctx.Session.Username()
|
||||
}
|
||||
|
||||
msg.To = strings.Split(ctx.QueryParam("to"), ",")
|
||||
msg.Subject = ctx.QueryParam("subject")
|
||||
msg.Text = ctx.QueryParam("body")
|
||||
msg.InReplyTo = ctx.QueryParam("in-reply-to")
|
||||
|
||||
if ctx.Request().Method == http.MethodGet && ctx.Param("uid") != "" {
|
||||
// This is a reply
|
||||
mboxName, uid, err := parseMboxAndUid(ctx.Param("mbox"), ctx.Param("uid"))
|
||||
|
|
|
@ -3,7 +3,6 @@ package koushinbase
|
|||
import (
|
||||
"html/template"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/emersion/go-imap"
|
||||
|
@ -16,13 +15,6 @@ var templateFuncs = template.FuncMap{
|
|||
"pathescape": func(s string) string {
|
||||
return url.PathEscape(s)
|
||||
},
|
||||
"formataddrlist": func(addrs []*imap.Address) string {
|
||||
l := make([]string, len(addrs))
|
||||
for i, addr := range addrs {
|
||||
l[i] = addr.PersonalName + " <" + addr.Address() + ">"
|
||||
}
|
||||
return strings.Join(l, ", ")
|
||||
},
|
||||
"formatdate": func(t time.Time) string {
|
||||
return t.Format("Mon Jan 02 15:04")
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue