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.
This commit is contained in:
Drew DeVault 2020-05-13 10:58:22 -04:00 committed by Simon Ser
parent 0191b73996
commit 1cf95af41e
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
26 changed files with 34 additions and 27 deletions

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .}}
<h1>alps</h1>

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .}}
<h1>alps</h1>

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .}}
<h1>alps</h1>

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .}}
<h1>alps</h1>

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .}}
<h1>alps</h1>

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .}}
<h1>alps</h1>

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .}}
<h1>alps</h1>

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .}}
<h1>alps</h1>

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .}}
<h1>alps</h1>

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .}}
<h1>alps</h1>

View file

@ -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,

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .}}
{{template "nav.html" .}}

View file

@ -4,6 +4,9 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff">
{{- if eq (index .GlobalData.Path 0) "mailbox"}}
<meta id="refresh" http-equiv="refresh" content="60">
{{end -}}
<title>Webmail</title>
<link rel="stylesheet" href="/themes/alps/assets/style.css">
</head>

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .}}
<h1>alps webmail</h1>
<form method="post" action="/login">

View file

@ -1,5 +1,5 @@
{{template "head.html"}}
{{template "nav.html" . }}
{{template "head.html" .}}
{{template "nav.html" .}}
<div class="page-wrap">
<aside>

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .}}
{{template "nav.html" .}}
<div class="page-wrap">

View file

@ -21,7 +21,7 @@
{{ end }}
&nbsp;&nbsp;
<a href="{{ .GlobalData.Path }}" class="button-link">Refresh</a>
<a href="{{ .GlobalData.URL.String }}" class="button-link">Refresh</a>
</div>
<form action="" method="post" class="actions-search">

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .Global}}
{{template "nav.html" .Global}}
<div class="container-fluid">

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .Global}}
{{template "nav.html" .Global}}
{{$fn := .AddressObject.Card.Value "FN"}}

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .Global}}
{{template "nav.html" .Global}}
<div class="container-fluid">

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .Global}}
{{template "nav.html" .Global}}
<div class="container-fluid">

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .Global}}
{{template "nav.html" .Global}}
{{$event := index .Event.Data.Events 0}}

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .Global}}
{{template "nav.html" .Global}}
<div class="container">

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .Global}}
{{template "nav.html" .Global}}
<!-- TODO: Share tabs if reasonable -->

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .Global}}
{{template "nav.html" .Global}}
<div class="container-fluid">

View file

@ -1,4 +1,4 @@
{{template "head.html"}}
{{template "head.html" .Global}}
{{template "nav.html" .Global}}
<div class="container-fluid">