diff options
author | 2020-05-13 10:58:22 -0400 | |
---|---|---|
committer | 2020-05-13 16:58:48 +0200 | |
commit | 1cf95af41ea24ab76cba8a0761d349b65c08c294 (patch) | |
tree | f7a5fd00a63498f00768aeba140b68a5d4a74431 /renderer.go | |
parent | 0191b739969e00cdba0faa5a05159fd5f83d5d9e (diff) | |
download | alps-1cf95af41ea24ab76cba8a0761d349b65c08c294.tar.gz alps-1cf95af41ea24ab76cba8a0761d349b65c08c294.tar.bz2 alps-1cf95af41ea24ab76cba8a0761d349b65c08c294.zip |
Add <meta refresh> to mailbox view
This causes the mailbox to automatically reload the page every 60
seconds, without JavaScript.
This also updates the base template data to include the full URL, and
replaces the earlier "Path" field with a pre-split array of path
components, which is more immediately useful to most templates given the
limitations of string munging with text/template primitives.
Diffstat (limited to 'renderer.go')
-rw-r--r-- | renderer.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/renderer.go b/renderer.go index 5471158..3379233 100644 --- a/renderer.go +++ b/renderer.go @@ -5,7 +5,9 @@ import ( "html/template" "io" "io/ioutil" + "net/url" "os" + "strings" "github.com/labstack/echo/v4" ) @@ -14,7 +16,8 @@ const themesDir = "themes" // GlobalRenderData contains data available in all templates. type GlobalRenderData struct { - Path string + Path []string + URL *url.URL LoggedIn bool @@ -71,7 +74,8 @@ func NewBaseRenderData(ctx *Context) *BaseRenderData { global.Username = ctx.Session.username } - global.Path = ctx.Request().URL.String() + global.URL = ctx.Request().URL + global.Path = strings.Split(global.URL.Path, "/")[1:] return &BaseRenderData{ GlobalData: global, |