aboutsummaryrefslogtreecommitdiff
path: root/templates/base.qtpl
blob: db9deeed4f226872ce7a32728f8c5d9db0898b5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
This is a base page template. All the other template pages implement this interface.

{% import "context" %}
{% import "strconv" %}
{% import "time" %}

{% code 
 var Slug = ""
%}

{% interface
Page {
	Title(ctx context.Context)
	Content(ctx context.Context)
    Script(ctx context.Context)
    Navbar(ctx context.Context)
}
%}


{% code func FromUInttoString(u *uint) string {
        if u != nil {
            return strconv.FormatUint(uint64(*u), 10)
        }
        return ""
    }
%}



{% code func TimeFormat(t time.Time) string {
        return t.Format("02.01.2006")
    }
%}

{% code func Ignore[T any](v T, _ error) T {
        return v
    }
%}


{% code func IsAuthenticationDisabled(ctx context.Context) bool {
	t, ok := ctx.Value("disableAuthentication").(bool)
	return ok && t
    }
%}

{% 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, ctx context.Context) %}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <link rel="icon" href="data:,">
    <title>{%= p.Title(ctx) %}</title> 
    <link rel="stylesheet" href="/static/main{%s Slug %}.css">
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
  </head>
  <body>
    {%= p.Navbar(ctx) %}
    <div class="container">
      {%= p.Content(ctx) %}
    </div>
  </body>
  {%= p.Script(ctx) %}
</html>
{% endfunc %}