aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/base/routes.go19
-rw-r--r--renderer.go19
-rw-r--r--themes/alps/head.html2
3 files changed, 25 insertions, 15 deletions
diff --git a/plugins/base/routes.go b/plugins/base/routes.go
index 70764e6..2d4cb8c 100644
--- a/plugins/base/routes.go
+++ b/plugins/base/routes.go
@@ -136,7 +136,7 @@ func handleGetMailbox(ctx *alps.Context) error {
}
return ctx.Render(http.StatusOK, "mailbox.html", &MailboxRenderData{
- BaseRenderData: *alps.NewBaseRenderData(ctx),
+ BaseRenderData: *alps.NewBaseRenderData(ctx).WithTitle(mbox.Name),
Mailbox: mbox,
Mailboxes: mailboxes,
Messages: msgs,
@@ -271,14 +271,15 @@ func handleGetPart(ctx *alps.Context, raw bool) error {
}
return ctx.Render(http.StatusOK, "message.html", &MessageRenderData{
- BaseRenderData: *alps.NewBaseRenderData(ctx),
- Mailboxes: mailboxes,
- Mailbox: mbox,
- Message: msg,
- Part: msg.PartByPath(partPath),
- View: view,
- MailboxPage: int(mbox.Messages-msg.SeqNum) / messagesPerPage,
- Flags: flags,
+ BaseRenderData: *alps.NewBaseRenderData(ctx).
+ WithTitle(msg.Envelope.Subject),
+ Mailboxes: mailboxes,
+ Mailbox: mbox,
+ Message: msg,
+ Part: msg.PartByPath(partPath),
+ View: view,
+ MailboxPage: int(mbox.Messages-msg.SeqNum) / messagesPerPage,
+ Flags: flags,
})
}
diff --git a/renderer.go b/renderer.go
index 3379233..a6b4118 100644
--- a/renderer.go
+++ b/renderer.go
@@ -17,13 +17,15 @@ const themesDir = "themes"
// GlobalRenderData contains data available in all templates.
type GlobalRenderData struct {
Path []string
- URL *url.URL
+ URL *url.URL
LoggedIn bool
// if logged in
Username string
+ Title string
+
// additional plugin-specific data
Extra map[string]interface{}
}
@@ -67,22 +69,29 @@ type RenderData interface {
// // other fields...
// }
func NewBaseRenderData(ctx *Context) *BaseRenderData {
- global := GlobalRenderData{Extra: make(map[string]interface{})}
+ global := GlobalRenderData{
+ Extra: make(map[string]interface{}),
+ Path: strings.Split(ctx.Request().URL.Path, "/")[1:],
+ Title: "Webmail",
+ URL: ctx.Request().URL,
+ }
if ctx.Session != nil {
global.LoggedIn = true
global.Username = ctx.Session.username
}
- global.URL = ctx.Request().URL
- global.Path = strings.Split(global.URL.Path, "/")[1:]
-
return &BaseRenderData{
GlobalData: global,
Extra: make(map[string]interface{}),
}
}
+func (brd *BaseRenderData) WithTitle(title string) *BaseRenderData {
+ brd.GlobalData.Title = title
+ return brd
+}
+
type renderer struct {
logger echo.Logger
defaultTheme string
diff --git a/themes/alps/head.html b/themes/alps/head.html
index 899f7d6..c2d5130 100644
--- a/themes/alps/head.html
+++ b/themes/alps/head.html
@@ -7,7 +7,7 @@
{{- if eq (index .GlobalData.Path 0) "mailbox"}}
<meta id="refresh" http-equiv="refresh" content="60">
{{end -}}
- <title>Webmail</title>
+ <title>{{.GlobalData.Title}}</title>
<link rel="stylesheet" href="/themes/alps/assets/style.css">
</head>
<body>