From e2d70ba6cab2e18063bd5b457cd861700cbbc9e7 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 17 Dec 2019 13:02:38 +0100 Subject: Linkify address lists --- plugins/base/public/message.html | 16 ++++++++++++---- plugins/base/routes.go | 5 +++++ plugins/base/template.go | 8 -------- 3 files changed, 17 insertions(+), 12 deletions(-) (limited to 'plugins') diff --git a/plugins/base/public/message.html b/plugins/base/public/message.html index 56e6e6f..b41ae39 100644 --- a/plugins/base/public/message.html +++ b/plugins/base/public/message.html @@ -49,24 +49,32 @@ {{end}} +{{define "addr-list"}} + {{range $i := .}} + {{if $i}},{{end}} + {{.PersonalName}} + <{{.Address}}> + {{end}} +{{end}} + diff --git a/plugins/base/routes.go b/plugins/base/routes.go index 84126d3..d73dfea 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -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")) diff --git a/plugins/base/template.go b/plugins/base/template.go index 714ca3c..d867ff3 100644 --- a/plugins/base/template.go +++ b/plugins/base/template.go @@ -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") }, -- cgit v1.2.3