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" data-bs-theme="light">
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 <link rel="stylesheet" href="/static/themes/dark">
64 <link rel="stylesheet" href="/static/themes/light">
65 <html data-bs-theme="dark">
66 <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
67 <meta name="viewport" content="width=device-width, initial-scale=1" />
68 </head>
69 <body>
70 {%= p.Navbar(ctx) %}
71 <div class="container">
72 {%= p.Content(ctx) %}
73 </div>
74 </body>
75 {%= p.Script(ctx) %}
76 <script>
77 function a(){const e=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.setAttribute("data-bs-theme",e?"dark":"light")}a(),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",a);
78 </script>
79</html>
80{% endfunc %}