137 lines
2.8 KiB
Plaintext
137 lines
2.8 KiB
Plaintext
{% import (
|
|
"runtime/debug"
|
|
|
|
"golang.org/x/text/language"
|
|
"golang.org/x/text/message"
|
|
) %}
|
|
|
|
{% interface Page {
|
|
body()
|
|
head()
|
|
lang()
|
|
t(format message.Reference, args ...any)
|
|
title()
|
|
} %}
|
|
|
|
{% code
|
|
type BaseOf struct {
|
|
language language.Tag
|
|
printer *message.Printer
|
|
name string
|
|
}
|
|
|
|
func NewBaseOf(lang language.Tag, name string) *BaseOf {
|
|
return &BaseOf{
|
|
language: lang,
|
|
printer: message.NewPrinter(lang),
|
|
name: name,
|
|
}
|
|
}
|
|
%}
|
|
|
|
{% stripspace %}
|
|
{% func (p *BaseOf) lang() %}
|
|
{%s p.language.String() %}
|
|
{% endfunc %}
|
|
|
|
{% func (p *BaseOf) title() %}
|
|
{%s p.name %}
|
|
{% endfunc %}
|
|
|
|
{% func (p *BaseOf) head() %}
|
|
{% comment %}https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs{% endcomment %}
|
|
<link rel="manifest"
|
|
{% space %}href="/static/manifest.webmanifest">
|
|
|
|
<link rel="icon"
|
|
{% space %}href="/static/favicon.ico"
|
|
{% space %}sizes="any">
|
|
|
|
<link rel="icon"
|
|
{% space %}href="/static/icon.svg"
|
|
{% space %}type="image/svg+xml">
|
|
|
|
<link rel="apple-touch-icon"
|
|
{% space %}href="/static/apple-touch-icon.png">
|
|
{% endfunc %}
|
|
|
|
{% func (p *BaseOf) body() %}{% endfunc %}
|
|
|
|
{% func (p *BaseOf) t(format message.Reference, args ...any) %}
|
|
{%s p.printer.Sprintf(format, args...) %}
|
|
{% endfunc %}
|
|
|
|
{% func Template(p Page) %}
|
|
<!DOCTYPE html>
|
|
<html class="page"
|
|
{% space %}lang="{%= p.lang() %}"
|
|
{% space %}dir="ltr">
|
|
|
|
<head>
|
|
<meta name="viewport"
|
|
{% space %}content="width=device-width, initial-scale=1">
|
|
|
|
<title>{%= p.title() %}</title>
|
|
|
|
<link rel="preload stylesheet"
|
|
{% space %}as="style"
|
|
{% space %}href="/static/style.css"
|
|
{% space %}type="text/css">
|
|
|
|
{%= p.head() %}
|
|
</head>
|
|
|
|
<body class="[ page__body ][ cover ]">
|
|
{%= p.body() %}
|
|
|
|
{% 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
|
|
}
|
|
}
|
|
%}
|
|
|
|
<footer class="[ body__footer ][ center ][ text-align_center ]">
|
|
<p>
|
|
Made with{% space %}
|
|
<span role="img"
|
|
{% space %}aria-label="love">
|
|
❤️
|
|
</span>
|
|
{% space %}to{% space %}
|
|
<a rel="external"
|
|
{% space %}href="https://{%s path %}">
|
|
open source
|
|
</a>
|
|
{% space %}by{% space %}
|
|
<a rel="author"
|
|
{% space %}href="https://toby3d.me/">
|
|
toby3d
|
|
</a>
|
|
</p>
|
|
|
|
{% if vcsRevision != "" %}
|
|
<small>
|
|
{%= p.t("version") %}
|
|
<a href="https://{%s path %}/commit/{%s vcsRevision %}"
|
|
{% space %}target="_blank">
|
|
|
|
{%s vcsRevision[:7] -%}
|
|
</a>
|
|
</small>
|
|
{% endif %}
|
|
</footer>
|
|
</body>
|
|
</html>
|
|
{% endfunc %}
|
|
{% endstripspace %}
|