aboutsummaryrefslogtreecommitdiff
path: root/templates/base.qtpl.go
diff options
context:
space:
mode:
Diffstat (limited to 'templates/base.qtpl.go')
-rw-r--r--templates/base.qtpl.go125
1 files changed, 76 insertions, 49 deletions
diff --git a/templates/base.qtpl.go b/templates/base.qtpl.go
index dce4cbc..db8afec 100644
--- a/templates/base.qtpl.go
+++ b/templates/base.qtpl.go
@@ -11,57 +11,77 @@ package templates
import "context"
//line templates/base.qtpl:4
-import "strconv"
+import "crypto/rand"
//line templates/base.qtpl:5
-import "time"
+import "encoding/hex"
+
+//line templates/base.qtpl:6
+import "strconv"
//line templates/base.qtpl:7
+import "time"
+
+//line templates/base.qtpl:9
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
-//line templates/base.qtpl:7
+//line templates/base.qtpl:9
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
-//line templates/base.qtpl:8
+//line templates/base.qtpl:11
var Slug = ""
+var Session = ""
+
+func init() {
+ Session = hex.EncodeToString(generateSmallTimeID())
+}
+
+func generateSmallTimeID() []byte {
+ b := make([]byte, 4)
+ _, err := rand.Read(b)
+ if err != nil {
+ panic(err)
+ }
+ return b
+}
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
type Page interface {
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
Title(ctx context.Context) string
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
StreamTitle(qw422016 *qt422016.Writer, ctx context.Context)
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
WriteTitle(qq422016 qtio422016.Writer, ctx context.Context)
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
Content(ctx context.Context) string
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
StreamContent(qw422016 *qt422016.Writer, ctx context.Context)
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
WriteContent(qq422016 qtio422016.Writer, ctx context.Context)
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
Script(ctx context.Context) string
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
StreamScript(qw422016 *qt422016.Writer, ctx context.Context)
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
WriteScript(qq422016 qtio422016.Writer, ctx context.Context)
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
Navbar(ctx context.Context) string
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
StreamNavbar(qw422016 *qt422016.Writer, ctx context.Context)
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
WriteNavbar(qq422016 qtio422016.Writer, ctx context.Context)
-//line templates/base.qtpl:12
+//line templates/base.qtpl:29
}
-//line templates/base.qtpl:21
+//line templates/base.qtpl:38
func FromUInttoString(u *uint) string {
if u != nil {
return strconv.FormatUint(uint64(*u), 10)
@@ -69,23 +89,23 @@ func FromUInttoString(u *uint) string {
return ""
}
-//line templates/base.qtpl:31
+//line templates/base.qtpl:48
func TimeFormat(t time.Time) string {
return t.Format("02.01.2006")
}
-//line templates/base.qtpl:36
+//line templates/base.qtpl:53
func Ignore[T any](v T, _ error) T {
return v
}
-//line templates/base.qtpl:42
+//line templates/base.qtpl:59
func IsAuthenticationDisabled(ctx context.Context) bool {
t, ok := ctx.Value("disableAuthentication").(bool)
return ok && t
}
-//line templates/base.qtpl:48
+//line templates/base.qtpl:65
func IsLoggedIn(ctx context.Context) bool {
t, ok := ctx.Value("logged").(bool)
return ok && t
@@ -93,9 +113,9 @@ func IsLoggedIn(ctx context.Context) bool {
// Page prints a page implementing Page interface.
-//line templates/base.qtpl:55
+//line templates/base.qtpl:72
func StreamPageTemplate(qw422016 *qt422016.Writer, p Page, ctx context.Context) {
-//line templates/base.qtpl:55
+//line templates/base.qtpl:72
qw422016.N().S(`
<!DOCTYPE html>
<html lang="en" data-bs-theme="light">
@@ -103,14 +123,21 @@ func StreamPageTemplate(qw422016 *qt422016.Writer, p Page, ctx context.Context)
<meta charset="utf-8">
<link rel="icon" href="data:,">
<title>`)
-//line templates/base.qtpl:61
+//line templates/base.qtpl:78
p.StreamTitle(qw422016, ctx)
-//line templates/base.qtpl:61
- qw422016.N().S(`</title>
+//line templates/base.qtpl:78
+ qw422016.N().S(`</title>
<link rel="stylesheet" href="/static/main`)
-//line templates/base.qtpl:62
+//line templates/base.qtpl:79
qw422016.E().S(Slug)
-//line templates/base.qtpl:62
+//line templates/base.qtpl:79
+ qw422016.N().S(`.css">
+ <link rel="stylesheet" href="/static/theme.`)
+//line templates/base.qtpl:80
+ qw422016.E().S(Session)
+//line templates/base.qtpl:80
+ qw422016.E().S(Slug)
+//line templates/base.qtpl:80
qw422016.N().S(`.css">
<html data-bs-theme="dark">
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
@@ -118,53 +145,53 @@ func StreamPageTemplate(qw422016 *qt422016.Writer, p Page, ctx context.Context)
</head>
<body>
`)
-//line templates/base.qtpl:68
+//line templates/base.qtpl:86
p.StreamNavbar(qw422016, ctx)
-//line templates/base.qtpl:68
+//line templates/base.qtpl:86
qw422016.N().S(`
<div class="container">
`)
-//line templates/base.qtpl:70
+//line templates/base.qtpl:88
p.StreamContent(qw422016, ctx)
-//line templates/base.qtpl:70
+//line templates/base.qtpl:88
qw422016.N().S(`
</div>
</body>
`)
-//line templates/base.qtpl:73
+//line templates/base.qtpl:91
p.StreamScript(qw422016, ctx)
-//line templates/base.qtpl:73
+//line templates/base.qtpl:91
qw422016.N().S(`
<script>
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);
</script>
</html>
`)
-//line templates/base.qtpl:78
+//line templates/base.qtpl:96
}
-//line templates/base.qtpl:78
+//line templates/base.qtpl:96
func WritePageTemplate(qq422016 qtio422016.Writer, p Page, ctx context.Context) {
-//line templates/base.qtpl:78
+//line templates/base.qtpl:96
qw422016 := qt422016.AcquireWriter(qq422016)
-//line templates/base.qtpl:78
+//line templates/base.qtpl:96
StreamPageTemplate(qw422016, p, ctx)
-//line templates/base.qtpl:78
+//line templates/base.qtpl:96
qt422016.ReleaseWriter(qw422016)
-//line templates/base.qtpl:78
+//line templates/base.qtpl:96
}
-//line templates/base.qtpl:78
+//line templates/base.qtpl:96
func PageTemplate(p Page, ctx context.Context) string {
-//line templates/base.qtpl:78
+//line templates/base.qtpl:96
qb422016 := qt422016.AcquireByteBuffer()
-//line templates/base.qtpl:78
+//line templates/base.qtpl:96
WritePageTemplate(qb422016, p, ctx)
-//line templates/base.qtpl:78
+//line templates/base.qtpl:96
qs422016 := string(qb422016.B)
-//line templates/base.qtpl:78
+//line templates/base.qtpl:96
qt422016.ReleaseByteBuffer(qb422016)
-//line templates/base.qtpl:78
+//line templates/base.qtpl:96
return qs422016
-//line templates/base.qtpl:78
+//line templates/base.qtpl:96
}