mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-05-16 03:30:11 +00:00
refactor(web): pass render URL state explicitly
Signed-off-by: Jason Cameron <jason.cameron@stanwith.me>
This commit is contained in:
+13
-13
@@ -9,12 +9,12 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
templ base(title string, body templ.Component, impressum *config.Impressum, challenge any, ogTags map[string]string, localizer *localization.SimpleLocalizer) {
|
||||
templ base(opts Options, title string, body templ.Component, impressum *config.Impressum, challenge any, ogTags map[string]string, localizer *localization.SimpleLocalizer) {
|
||||
<!DOCTYPE html>
|
||||
<html lang={ localizer.GetLang() }>
|
||||
<head>
|
||||
<title>{ title }</title>
|
||||
<link rel="stylesheet" href={ anubis.BasePrefix + xess.URL }/>
|
||||
<link rel="stylesheet" href={ opts.BasePrefix + xess.URL }/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<meta name="robots" content="noindex,nofollow"/>
|
||||
for key, value := range ogTags {
|
||||
@@ -60,11 +60,11 @@ templ base(title string, body templ.Component, impressum *config.Impressum, chal
|
||||
</style>
|
||||
@templ.JSONScript("anubis_version", anubis.Version)
|
||||
@templ.JSONScript("anubis_challenge", challenge)
|
||||
@templ.JSONScript("anubis_base_prefix", anubis.BasePrefix)
|
||||
@templ.JSONScript("anubis_public_url", anubis.PublicUrl)
|
||||
@templ.JSONScript("anubis_base_prefix", opts.BasePrefix)
|
||||
@templ.JSONScript("anubis_public_url", opts.PublicURL)
|
||||
</head>
|
||||
<body id="top">
|
||||
@honeypotLink(anubis.BasePrefix + fmt.Sprintf("%shoneypot/%s/init", anubis.APIPrefix, uuid.NewString()))
|
||||
@honeypotLink(opts.BasePrefix + fmt.Sprintf("%shoneypot/%s/init", anubis.APIPrefix, uuid.NewString()))
|
||||
<main>
|
||||
<h1 id="title" class="centered-div">{ title }</h1>
|
||||
@body
|
||||
@@ -79,7 +79,7 @@ templ base(title string, body templ.Component, impressum *config.Impressum, chal
|
||||
if impressum != nil {
|
||||
<p>
|
||||
@templ.Raw(impressum.Footer)
|
||||
-- <a href={ templ.SafeURL(anubis.BasePrefix + fmt.Sprintf("%simprint", anubis.APIPrefix)) }>Imprint</a>
|
||||
-- <a href={ templ.SafeURL(opts.BasePrefix + fmt.Sprintf("%simprint", anubis.APIPrefix)) }>Imprint</a>
|
||||
</p>
|
||||
}
|
||||
<p>{ localizer.T("version_info") } <code>{ anubis.Version }</code>.</p>
|
||||
@@ -90,9 +90,9 @@ templ base(title string, body templ.Component, impressum *config.Impressum, chal
|
||||
</html>
|
||||
}
|
||||
|
||||
templ errorPage(message, mail, code string, localizer *localization.SimpleLocalizer) {
|
||||
templ errorPage(opts Options, message, mail, code string, localizer *localization.SimpleLocalizer) {
|
||||
<div class="centered-div">
|
||||
<img id="image" alt="Sad Anubis" style="width:100%;max-width:256px;" src={ anubis.BasePrefix + "/.within.website/x/cmd/anubis/static/img/reject.webp?cacheBuster=" + anubis.Version }/>
|
||||
<img id="image" alt="Sad Anubis" style="width:100%;max-width:256px;" src={ opts.BasePrefix + "/.within.website/x/cmd/anubis/static/img/reject.webp?cacheBuster=" + anubis.Version }/>
|
||||
<p>{ message }.</p>
|
||||
if code != "" {
|
||||
<code><pre>{ code }</pre></code>
|
||||
@@ -110,19 +110,19 @@ templ errorPage(message, mail, code string, localizer *localization.SimpleLocali
|
||||
</div>
|
||||
}
|
||||
|
||||
templ StaticHappy(localizer *localization.SimpleLocalizer) {
|
||||
templ staticHappy(opts Options, localizer *localization.SimpleLocalizer) {
|
||||
<div class="centered-div">
|
||||
<img
|
||||
style="display:none;"
|
||||
style="width:100%;max-width:256px;"
|
||||
src={ "/.within.website/x/cmd/anubis/static/img/happy.webp?cacheBuster=" +
|
||||
src={ opts.BasePrefix + "/.within.website/x/cmd/anubis/static/img/happy.webp?cacheBuster=" +
|
||||
anubis.Version }
|
||||
/>
|
||||
<p>{ localizer.T("static_check_endpoint") }</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ bench(localizer *localization.SimpleLocalizer) {
|
||||
templ bench(opts Options, localizer *localization.SimpleLocalizer) {
|
||||
<div style="height:20rem;display:flex">
|
||||
<table style="margin-top:1rem;display:grid;grid-template:auto 1fr/auto auto;gap:0 0.5rem">
|
||||
<thead
|
||||
@@ -145,9 +145,9 @@ templ bench(localizer *localization.SimpleLocalizer) {
|
||||
></tbody>
|
||||
</table>
|
||||
<div class="centered-div">
|
||||
<img id="image" style="width:100%;max-width:256px;" src={ anubis.BasePrefix + "/.within.website/x/cmd/anubis/static/img/pensive.webp?cacheBuster=" + anubis.Version }/>
|
||||
<img id="image" style="width:100%;max-width:256px;" src={ opts.BasePrefix + "/.within.website/x/cmd/anubis/static/img/pensive.webp?cacheBuster=" + anubis.Version }/>
|
||||
<p id="status" style="max-width:256px">{ localizer.T("loading") }</p>
|
||||
<script async type="module" src={ anubis.BasePrefix + "/.within.website/x/cmd/anubis/static/js/bench.mjs?cacheBuster=" + anubis.Version }></script>
|
||||
<script async type="module" src={ opts.BasePrefix + "/.within.website/x/cmd/anubis/static/js/bench.mjs?cacheBuster=" + anubis.Version }></script>
|
||||
<div id="sparkline"></div>
|
||||
<noscript>
|
||||
<p>{ localizer.T("benchmark_requires_js") }</p>
|
||||
|
||||
Reference in New Issue
Block a user