1This is a base page template. All the other template pages implement this interface.
2
3{% import "context" %}
4{% import "strconv" %}
5{% import "time" %}
6
7{% code
8 var Slug = ""
9%}
10
11{% interface
12Page {
13 Title(ctx context.Context)
14 Content(ctx context.Context)
15 Script(ctx context.Context)
16 Navbar(ctx context.Context)
17}
18%}
19
20
21{% code func FromUInttoString(u *uint) string {
22 if u != nil {
23 return strconv.FormatUint(uint64(*u), 10)
24 }
25 return ""
26 }
27%}
28
29
30
31{% code func TimeFormat(t time.Time) string {
32 return t.Format("02.01.2006")
33 }
34%}
35
36{% code func Ignore[T any](v T, _ error) T {
37 return v
38 }
39%}
40
41
42{% code func IsAuthenticationDisabled(ctx context.Context) bool {
43 t, ok := ctx.Value("disableAuthentication").(bool)
44 return ok && t
45 }
46%}
47
48{% code func IsLoggedIn(ctx context.Context) bool {
49 t, ok := ctx.Value("logged").(bool)
50 return ok && t
51 }
52%}
53
54Page prints a page implementing Page interface.
55{% func PageTemplate(p Page, ctx context.Context) %}
56<!DOCTYPE html>
57<html lang="en">
58 <head>
59 <meta charset="utf-8">
60 <link rel="icon" href="data:,">
61 <title>{%= p.Title(ctx) %}</title>
62 <link rel="stylesheet" href="/static/main{%s Slug %}.css">
63 <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
64 <meta name="viewport" content="width=device-width, initial-scale=1" />
65 </head>
66 <body>
67 {%= p.Navbar(ctx) %}
68 <div class="container">
69 {%= p.Content(ctx) %}
70 </div>
71 </body>
72 {%= p.Script(ctx) %}
73</html>
74{% endfunc %}