Add envelope metadata to message view
This commit is contained in:
parent
e78d2db3ea
commit
9404be1a32
3 changed files with 52 additions and 11 deletions
|
@ -1,9 +1,6 @@
|
|||
package koushinbase
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/url"
|
||||
|
||||
"git.sr.ht/~emersion/koushin"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
@ -13,14 +10,7 @@ const messagesPerPage = 50
|
|||
func init() {
|
||||
p := koushin.GoPlugin{Name: "base"}
|
||||
|
||||
p.TemplateFuncs(template.FuncMap{
|
||||
"tuple": func(values ...interface{}) []interface{} {
|
||||
return values
|
||||
},
|
||||
"pathescape": func(s string) string {
|
||||
return url.PathEscape(s)
|
||||
},
|
||||
})
|
||||
p.TemplateFuncs(templateFuncs)
|
||||
|
||||
p.GET("/mailbox/:mbox", handleGetMailbox)
|
||||
p.POST("/mailbox/:mbox", handleGetMailbox)
|
||||
|
|
|
@ -30,6 +30,28 @@
|
|||
<input type="submit" value="Delete">
|
||||
</form>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<strong>Date</strong>: {{.Message.Envelope.Date | formatdate}}
|
||||
</li>
|
||||
<li>
|
||||
<strong>From</strong>: {{.Message.Envelope.From | formataddrlist}}
|
||||
</li>
|
||||
<li>
|
||||
<strong>To</strong>: {{.Message.Envelope.To | formataddrlist}}
|
||||
</li>
|
||||
{{if .Message.Envelope.Cc}}
|
||||
<li>
|
||||
<strong>Cc</strong>: {{.Message.Envelope.Cc | formataddrlist}}
|
||||
</li>
|
||||
{{end}}
|
||||
{{if .Message.Envelope.Bcc}}
|
||||
<li>
|
||||
<strong>Bcc</strong>: {{.Message.Envelope.Bcc | formataddrlist}}
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
||||
{{define "message-part-tree"}}
|
||||
{{/* nested templates can't access the parent's context */}}
|
||||
{{$ = index . 0}}
|
||||
|
|
29
plugins/base/template.go
Normal file
29
plugins/base/template.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package koushinbase
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/emersion/go-imap"
|
||||
)
|
||||
|
||||
var templateFuncs = template.FuncMap{
|
||||
"tuple": func(values ...interface{}) []interface{} {
|
||||
return values
|
||||
},
|
||||
"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