Files
uptimesebi/internal/web/layout.templ
Sebastian UnterschützandClaude Opus 5.5 73eb0f8bcd feat: legal notice and privacy policy as Markdown or link
Admins set the platform's documents, linked in the footer of the console
and sign-in pages and served at /legal/<kind>. Organizations set their
own for their status pages, falling back to the platform's. Documents
travel in the status page snapshot, so status page servers serve them at
/<slug>/imprint and /imprint on custom domains during API outages too.
Markdown is rendered with goldmark, which drops raw HTML and unsafe
links; stored links must be http or https.

Closes #67

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 10:17:39 +01:00

98 lines
2.8 KiB
Templ

package web
import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
// Page carries what every rendered page needs besides its own content.
type Page struct {
TitleID string
CSRF string
Languages []string
// ErrorID and NoticeID name catalog messages shown above the content,
// typically after a redirect back from an SSO flow.
ErrorID string
NoticeID string
// Legal links the platform's legal notice and privacy policy.
Legal []LegalLink
}
templ Layout(p Page) {
<!DOCTYPE html>
<html lang={ i18n.Lang(ctx) }>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
if p.CSRF != "" {
<meta name="csrf-token" content={ p.CSRF }/>
}
<title>{ i18n.T(ctx, p.TitleID) } · uptimesebi</title>
<link rel="stylesheet" href="/static/dist/app.css"/>
<script src="/static/dist/axios.min.js" defer></script>
<script src="/static/dist/app.js" defer></script>
</head>
<body class="flex min-h-screen flex-col" data-msg-network={ i18n.T(ctx, "app.network_error") }>
<div class="flex-1">
{ children... }
</div>
@legalFooter(p.Legal)
</body>
</html>
}
templ languageSwitch(langs []string) {
<span class="flex gap-2 font-mono text-xs">
for _, l := range langs {
if l == i18n.Lang(ctx) {
<span class="text-ink" aria-current="true">{ l }</span>
} else {
<button type="button" data-locale={ l } class="text-muted hover:text-ink" title={ i18n.T(ctx, "lang."+l) }>{ l }</button>
}
}
</span>
}
templ authShell(p Page) {
@Layout(p) {
<main class="mx-auto mt-[12vh] w-full max-w-sm px-6">
<div class="mb-10 flex items-baseline justify-between">
<p class="font-mono text-xs tracking-wide text-muted">uptimesebi</p>
@languageSwitch(p.Languages)
</div>
<h1 class="mb-6 text-xl font-semibold">{ i18n.T(ctx, p.TitleID) }</h1>
@flash(p)
{ children... }
</main>
}
}
templ field(label, name, typ, autocomplete string, required bool) {
<label class="mb-4 block">
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ label }</span>
<input
class="w-full border border-rule bg-transparent px-2.5 py-1.5 outline-none focus:border-ink"
type={ typ }
name={ name }
autocomplete={ autocomplete }
required?={ required }
/>
</label>
}
templ submit(label string) {
<button type="submit" class="mt-2 w-full bg-ink px-3 py-2 text-sm font-medium text-paper hover:opacity-90 disabled:opacity-50">
{ label }
</button>
}
templ flash(p Page) {
if p.ErrorID != "" {
<p class="mb-6 border-l-2 border-down pl-2 text-sm text-down">{ i18n.T(ctx, p.ErrorID) }</p>
}
if p.NoticeID != "" {
<p class="mb-6 border-l-2 border-up pl-2 text-sm">{ i18n.T(ctx, p.NoticeID) }</p>
}
}
templ formError() {
<p data-error class="mb-4 hidden border-l-2 border-down pl-2 text-sm text-down"></p>
}