95 lines
2.7 KiB
Text
95 lines
2.7 KiB
Text
package web
|
|
|
|
import (
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
templ Base(title string) {
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta charset="utf-8"/>
|
|
<title>{title}</title>
|
|
<link rel="stylesheet" href="/assets/styles.css"/>
|
|
</head>
|
|
<body class="flex flex-col min-h-screen">
|
|
<header>
|
|
@NavBar(title)
|
|
</header>
|
|
<main class="flex-grow">
|
|
<div class="container mx-auto px-4 py-8 sm:px-6 lg:px-8 max-w-8xl">
|
|
{ children... }
|
|
</div>
|
|
</main>
|
|
<footer class="bg-gray-800 text-gray-300 py-4">
|
|
<div class="container mx-auto text-center">
|
|
<p>{viper.GetString("ui.name")} by <a href={templ.URL(viper.GetString("ui.byurl"))}>{viper.GetString("ui.byname")}</a> licenced under GPLv2, </p>
|
|
<p><a href={templ.URL(viper.GetString("ui.source"))}>Source</a></p>
|
|
</div>
|
|
<script src="/assets/htmx.min.js"></script>
|
|
<script src="/assets/alpine.min.js"></script>
|
|
<script>
|
|
// Re-initialize templUI components after HTMX swaps
|
|
document.body.addEventListener("htmx:afterSwap", (e) => {
|
|
if (window.templUI) {
|
|
Object.values(window.templUI).forEach(comp => {
|
|
comp.init?.(e.detail.elt);
|
|
});
|
|
}
|
|
});
|
|
|
|
// Re-initialize components after out-of-band swaps
|
|
document.body.addEventListener("htmx:oobAfterSwap", (e) => {
|
|
if (window.templUI) {
|
|
Object.values(window.templUI).forEach(comp => {
|
|
comp.init?.(e.detail.target);
|
|
});
|
|
}
|
|
});
|
|
|
|
// Cleanup before swap (for components with event listeners)
|
|
document.body.addEventListener("htmx:beforeSwap", (e) => {
|
|
if (window.templUI) {
|
|
Object.values(window.templUI).forEach(comp => {
|
|
comp.cleanup?.(e.detail.target);
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
</footer>
|
|
</body>
|
|
</html>
|
|
}
|
|
|
|
templ NavBar(title string) {
|
|
<nav class="bg-blue-600 p-4 shadow-lg">
|
|
<div class="container mx-auto flex justify-between items-center">
|
|
<!-- Logo or Brand Name -->
|
|
<a href="/" class="text-white text-lg font-bold">
|
|
Scanfile
|
|
</a>
|
|
<!-- Navigation Links -->
|
|
<div class="flex space-x-4">
|
|
<a
|
|
href="/"
|
|
class="text-white hover:bg-blue-700 px-3 py-2 rounded-md"
|
|
>
|
|
Home
|
|
</a>
|
|
<a
|
|
href="/about"
|
|
class="text-white hover:bg-blue-700 px-3 py-2 rounded-md"
|
|
>
|
|
About
|
|
</a>
|
|
<a
|
|
href="/login"
|
|
class="text-white hover:bg-blue-700 px-3 py-2 rounded-md"
|
|
>
|
|
Login
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
}
|