79 lines
2.5 KiB
Plaintext
79 lines
2.5 KiB
Plaintext
package layout
|
|
|
|
import "git.haelnorr.com/h/oslstats/internal/view/component/popup"
|
|
import "git.haelnorr.com/h/oslstats/internal/view/component/nav"
|
|
import "git.haelnorr.com/h/oslstats/internal/view/component/footer"
|
|
import "git.haelnorr.com/h/oslstats/pkg/contexts"
|
|
|
|
// Global page layout. Includes HTML document settings, header tags
|
|
// navbar and footer
|
|
templ Global(title string) {
|
|
{{ htmxLogging := contexts.HTMXLog(ctx) }}
|
|
<!DOCTYPE html>
|
|
<html
|
|
lang="en"
|
|
x-data="{
|
|
theme: localStorage.getItem('theme')
|
|
|| 'system'}"
|
|
x-init="$watch('theme', (val) => localStorage.setItem('theme', val))"
|
|
x-bind:class="{'dark': theme === 'dark' || (theme === 'system' &&
|
|
window.matchMedia('(prefers-color-scheme: dark)').matches)}"
|
|
>
|
|
<head>
|
|
<script src="/static/js/theme.js"></script>
|
|
<meta charset="UTF-8"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>{ title }</title>
|
|
<link rel="icon" type="image/x-icon" href="/static/favicon.ico"/>
|
|
<link href="/static/css/output.css" rel="stylesheet"/>
|
|
<script src="https://unpkg.com/htmx.org@2.0.4" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
|
<script defer src="https://cdn.jsdelivr.net/npm/@alpinejs/persist@3.x.x/dist/cdn.min.js"></script>
|
|
<script src="https://unpkg.com/alpinejs" defer></script>
|
|
if htmxLogging {
|
|
<script>
|
|
htmx.logAll();
|
|
</script>
|
|
}
|
|
<script>
|
|
const bodyData = {
|
|
showError500: false,
|
|
showError503: false,
|
|
// handle errors from the server on HTMX requests
|
|
handleHtmxError(event) {
|
|
const errorCode = event.detail.errorInfo.error;
|
|
|
|
// internal server error
|
|
if (errorCode.includes("Code 500")) {
|
|
this.showError500 = true;
|
|
setTimeout(() => (this.showError500 = false), 6000);
|
|
}
|
|
// service not available error
|
|
if (errorCode.includes("Code 503")) {
|
|
this.showError503 = true;
|
|
setTimeout(() => (this.showError503 = false), 6000);
|
|
}
|
|
},
|
|
};
|
|
</script>
|
|
</head>
|
|
<body
|
|
class="bg-base text-text ubuntu-mono-regular overflow-x-hidden"
|
|
x-data="bodyData"
|
|
x-on:htmx:error="handleHtmxError($event)"
|
|
>
|
|
@popup.Error500Popup()
|
|
@popup.Error503Popup()
|
|
<div
|
|
id="main-content"
|
|
class="flex flex-col h-screen justify-between"
|
|
>
|
|
@nav.Navbar()
|
|
<div id="page-content" class="mb-auto md:px-5 md:pt-5">
|
|
{ children... }
|
|
</div>
|
|
@footer.Footer()
|
|
</div>
|
|
</body>
|
|
</html>
|
|
}
|