diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-12-11 17:05:12 +0100 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-12-11 17:05:12 +0100 |
commit | 1e45ae2ea3497958b2ea6a20137955cfc3bbc964 (patch) | |
tree | 00af0e28864d79d7a9cbb8b693aff1b397b1a949 /templates/base.qtpl | |
parent | e6ded0d01117c592ec124f3e02d6c89eeafec382 (diff) | |
download | cerrado-1e45ae2ea3497958b2ea6a20137955cfc3bbc964.tar.gz cerrado-1e45ae2ea3497958b2ea6a20137955cfc3bbc964.tar.bz2 cerrado-1e45ae2ea3497958b2ea6a20137955cfc3bbc964.zip |
feat: Add UI/Handler login process
It adds the whole workflow to store and handle login on both UI and
handler level. With that the login information should be available at
any point given the context.
Diffstat (limited to 'templates/base.qtpl')
-rw-r--r-- | templates/base.qtpl | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/templates/base.qtpl b/templates/base.qtpl index 566308f..2a42cb8 100644 --- a/templates/base.qtpl +++ b/templates/base.qtpl @@ -1,5 +1,6 @@ This is a base page template. All the other template pages implement this interface. +{% import "context" %} {% import "strconv" %} {% import "time" %} @@ -9,10 +10,10 @@ This is a base page template. All the other template pages implement this interf {% interface Page { - Title() - Content() - Script() - Navbar() + Title(ctx context.Context) + Content(ctx context.Context) + Script(ctx context.Context) + Navbar(ctx context.Context) } %} @@ -25,6 +26,8 @@ Page { } %} + + {% code func TimeFormat(t time.Time) string { return t.Format("02.01.2006") } @@ -35,24 +38,30 @@ Page { } %} +{% code func IsLoggedIn(ctx context.Context) bool { + t, ok := ctx.Value("logged").(bool) + return ok && t + } +%} + Page prints a page implementing Page interface. -{% func PageTemplate(p Page) %} +{% func PageTemplate(p Page, ctx context.Context) %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="icon" href="data:,"> - <title>{%= p.Title() %}</title> + <title>{%= p.Title(ctx) %}</title> <link rel="stylesheet" href="/static/main{%s Slug %}.css"> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <meta name="viewport" content="width=device-width, initial-scale=1" /> </head> <body> - {%= p.Navbar() %} + {%= p.Navbar(ctx) %} <div class="container"> - {%= p.Content() %} + {%= p.Content(ctx) %} </div> </body> - {%= p.Script() %} + {%= p.Script(ctx) %} </html> {% endfunc %} |