aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/plugin.go12
-rw-r--r--plugins/base/public/message.html22
-rw-r--r--plugins/base/template.go29
3 files changed, 52 insertions, 11 deletions
diff --git a/plugins/base/plugin.go b/plugins/base/plugin.go
index 1cee571..3673885 100644
--- a/plugins/base/plugin.go
+++ b/plugins/base/plugin.go
@@ -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)
diff --git a/plugins/base/public/message.html b/plugins/base/public/message.html
index 11afa73..0b7a8d5 100644
--- a/plugins/base/public/message.html
+++ b/plugins/base/public/message.html
@@ -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}}
diff --git a/plugins/base/template.go b/plugins/base/template.go
new file mode 100644
index 0000000..84c4e21
--- /dev/null
+++ b/plugins/base/template.go
@@ -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")
+ },
+}