1// Code generated by qtc from "base.qtpl". DO NOT EDIT.
2// See https://github.com/valyala/quicktemplate for details.
3
4// This is a base page template. All the other template pages implement this interface.
5//
6
7//line templates/base.qtpl:3
8package templates
9
10//line templates/base.qtpl:3
11import "context"
12
13//line templates/base.qtpl:4
14import "crypto/rand"
15
16//line templates/base.qtpl:5
17import "encoding/hex"
18
19//line templates/base.qtpl:6
20import "strconv"
21
22//line templates/base.qtpl:7
23import "time"
24
25//line templates/base.qtpl:9
26import (
27 qtio422016 "io"
28
29 qt422016 "github.com/valyala/quicktemplate"
30)
31
32//line templates/base.qtpl:9
33var (
34 _ = qtio422016.Copy
35 _ = qt422016.AcquireByteBuffer
36)
37
38//line templates/base.qtpl:11
39var Slug = ""
40var Session = ""
41
42func init() {
43 Session = hex.EncodeToString(generateSmallTimeID())
44}
45
46func generateSmallTimeID() []byte {
47 b := make([]byte, 4)
48 _, err := rand.Read(b)
49 if err != nil {
50 panic(err)
51 }
52 return b
53}
54
55//line templates/base.qtpl:29
56type Page interface {
57//line templates/base.qtpl:29
58 Title(ctx context.Context) string
59//line templates/base.qtpl:29
60 StreamTitle(qw422016 *qt422016.Writer, ctx context.Context)
61//line templates/base.qtpl:29
62 WriteTitle(qq422016 qtio422016.Writer, ctx context.Context)
63//line templates/base.qtpl:29
64 Content(ctx context.Context) string
65//line templates/base.qtpl:29
66 StreamContent(qw422016 *qt422016.Writer, ctx context.Context)
67//line templates/base.qtpl:29
68 WriteContent(qq422016 qtio422016.Writer, ctx context.Context)
69//line templates/base.qtpl:29
70 Script(ctx context.Context) string
71//line templates/base.qtpl:29
72 StreamScript(qw422016 *qt422016.Writer, ctx context.Context)
73//line templates/base.qtpl:29
74 WriteScript(qq422016 qtio422016.Writer, ctx context.Context)
75//line templates/base.qtpl:29
76 Navbar(ctx context.Context) string
77//line templates/base.qtpl:29
78 StreamNavbar(qw422016 *qt422016.Writer, ctx context.Context)
79//line templates/base.qtpl:29
80 WriteNavbar(qq422016 qtio422016.Writer, ctx context.Context)
81//line templates/base.qtpl:29
82}
83
84//line templates/base.qtpl:38
85func FromUInttoString(u *uint) string {
86 if u != nil {
87 return strconv.FormatUint(uint64(*u), 10)
88 }
89 return ""
90}
91
92//line templates/base.qtpl:48
93func TimeFormat(t time.Time) string {
94 return t.Format("02.01.2006")
95}
96
97//line templates/base.qtpl:53
98func Ignore[T any](v T, _ error) T {
99 return v
100}
101
102//line templates/base.qtpl:59
103func IsAuthenticationDisabled(ctx context.Context) bool {
104 t, ok := ctx.Value("disableAuthentication").(bool)
105 return ok && t
106}
107
108//line templates/base.qtpl:65
109func IsLoggedIn(ctx context.Context) bool {
110 t, ok := ctx.Value("logged").(bool)
111 return ok && t
112}
113
114// Page prints a page implementing Page interface.
115
116//line templates/base.qtpl:72
117func StreamPageTemplate(qw422016 *qt422016.Writer, p Page, ctx context.Context) {
118//line templates/base.qtpl:72
119 qw422016.N().S(`
120<!DOCTYPE html>
121<html lang="en" data-bs-theme="light">
122 <head>
123 <meta charset="utf-8">
124 <link rel="icon" href="data:,">
125 <title>`)
126//line templates/base.qtpl:78
127 p.StreamTitle(qw422016, ctx)
128//line templates/base.qtpl:78
129 qw422016.N().S(`</title>
130 <link rel="stylesheet" href="/static/main`)
131//line templates/base.qtpl:79
132 qw422016.E().S(Slug)
133//line templates/base.qtpl:79
134 qw422016.N().S(`.css">
135 <link rel="stylesheet" href="/static/theme.`)
136//line templates/base.qtpl:80
137 qw422016.E().S(Session)
138//line templates/base.qtpl:80
139 qw422016.E().S(Slug)
140//line templates/base.qtpl:80
141 qw422016.N().S(`.css">
142 <html data-bs-theme="dark">
143 <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
144 <meta name="viewport" content="width=device-width, initial-scale=1" />
145 </head>
146 <body>
147 `)
148//line templates/base.qtpl:86
149 p.StreamNavbar(qw422016, ctx)
150//line templates/base.qtpl:86
151 qw422016.N().S(`
152 <div class="container">
153 `)
154//line templates/base.qtpl:88
155 p.StreamContent(qw422016, ctx)
156//line templates/base.qtpl:88
157 qw422016.N().S(`
158 </div>
159 </body>
160 `)
161//line templates/base.qtpl:91
162 p.StreamScript(qw422016, ctx)
163//line templates/base.qtpl:91
164 qw422016.N().S(`
165 <script>
166 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);
167 </script>
168</html>
169`)
170//line templates/base.qtpl:96
171}
172
173//line templates/base.qtpl:96
174func WritePageTemplate(qq422016 qtio422016.Writer, p Page, ctx context.Context) {
175//line templates/base.qtpl:96
176 qw422016 := qt422016.AcquireWriter(qq422016)
177//line templates/base.qtpl:96
178 StreamPageTemplate(qw422016, p, ctx)
179//line templates/base.qtpl:96
180 qt422016.ReleaseWriter(qw422016)
181//line templates/base.qtpl:96
182}
183
184//line templates/base.qtpl:96
185func PageTemplate(p Page, ctx context.Context) string {
186//line templates/base.qtpl:96
187 qb422016 := qt422016.AcquireByteBuffer()
188//line templates/base.qtpl:96
189 WritePageTemplate(qb422016, p, ctx)
190//line templates/base.qtpl:96
191 qs422016 := string(qb422016.B)
192//line templates/base.qtpl:96
193 qt422016.ReleaseByteBuffer(qb422016)
194//line templates/base.qtpl:96
195 return qs422016
196//line templates/base.qtpl:96
197}