From 1e45ae2ea3497958b2ea6a20137955cfc3bbc964 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Wed, 11 Dec 2024 17:05:12 +0100 Subject: 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. --- templates/base.qtpl | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'templates/base.qtpl') 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) %} - {%= p.Title() %} + {%= p.Title(ctx) %} - {%= p.Navbar() %} + {%= p.Navbar(ctx) %}
- {%= p.Content() %} + {%= p.Content(ctx) %}
- {%= p.Script() %} + {%= p.Script(ctx) %} {% endfunc %} -- cgit v1.2.3