auth/web/baseof.qtpl

111 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

{% import (
"runtime/debug"
"golang.org/x/text/language"
"golang.org/x/text/message"
"source.toby3d.me/toby3d/auth/internal/domain"
) %}
{% interface Page {
2023-08-06 00:42:38 +00:00
body()
head()
lang()
t(format message.Reference, args ...any)
title()
} %}
{% code type BaseOf struct {
Config *domain.Config
Language language.Tag
Printer *message.Printer
} %}
{% stripspace %}
2023-08-06 00:42:38 +00:00
{% func (p *BaseOf) lang() %}
2023-01-16 10:19:22 +00:00
{% if p.Language != language.Und %}
{%s p.Language.String() %}
{% else %}
en
{% endif %}
{% endfunc %}
{% endstripspace %}
{% collapsespace %}
2023-08-06 00:42:38 +00:00
{% func (p *BaseOf) title() %}
2023-01-16 10:19:22 +00:00
{%s p.Config.Name %}
{% endfunc %}
2023-08-06 00:42:38 +00:00
{% func (p *BaseOf) head() %}
2023-01-16 10:19:22 +00:00
{% comment %}https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs{% endcomment %}
<link rel="icon"
href="/favicon.ico"
2023-01-16 10:19:22 +00:00
sizes="any">
2023-01-16 10:19:22 +00:00
<link rel="icon"
href="/icon.svg"
2023-01-16 10:19:22 +00:00
type="image/svg+xml">
2023-01-16 10:19:22 +00:00
<link rel="apple-touch-icon"
href="/apple-touch-icon.png">
2023-01-16 10:19:22 +00:00
<link rel="manifest"
href="/manifest.webmanifest">
{% endfunc %}
2023-08-06 00:42:38 +00:00
{% func (p *BaseOf) body() %}{% endfunc %}
{% func Template(p Page) %}
2023-01-16 10:19:22 +00:00
<!DOCTYPE html>
<html class="page"
2023-08-06 00:42:38 +00:00
lang="{%= p.lang() %}">
2023-01-16 10:19:22 +00:00
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
2023-08-06 00:42:38 +00:00
{%= p.head() %}
2023-01-16 10:19:22 +00:00
2023-08-06 00:42:38 +00:00
<title>{%= p.title() %}</title>
2023-01-16 10:19:22 +00:00
</head>
<body class="page__body body">
2023-08-06 00:42:38 +00:00
{%= p.body() %}
2023-01-16 10:19:22 +00:00
{% code
var path, vcsRevision string
if bi, ok := debug.ReadBuildInfo(); ok {
path = bi.Path
for i := range bi.Settings {
if bi.Settings[i].Key != "vcs.revision" {
continue
}
vcsRevision = bi.Settings[i].Value
}
}
%}
2023-01-16 10:19:22 +00:00
{% if vcsRevision != "" %}
<footer>
<small>
2023-08-06 00:42:38 +00:00
{%= p.t("version") %}
2023-01-16 10:19:22 +00:00
<a href="https://{%s path %}/commit/{%s vcsRevision %}"
target="_blank">
{%s vcsRevision[:7] -%}
</a>
</small>
</footer>
{% endif %}
</body>
</html>
{% endfunc %}
2023-08-06 00:42:38 +00:00
{% func (p BaseOf) t(format message.Reference, args ...any) %}
{%s= p.Printer.Sprintf(format, args...) %}
{% endfunc %}
{% endcollapsespace %}