refactor: update templates for new frontend structure
- Extract inline JavaScript from index.templ - Replace with external script include for theme.js - All templates reference /static/ for assets - Cleaner separation of concerns between markup and logic
This commit is contained in:
@@ -7,6 +7,7 @@ templ Admin(user User) {
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Admin Dashboard - Bookmann</title>
|
<title>Admin Dashboard - Bookmann</title>
|
||||||
<script src="/static/htmx.min.js"></script>
|
<script src="/static/htmx.min.js"></script>
|
||||||
|
<script src="/static/toast.js"></script>
|
||||||
<link href="/static/style.css" rel="stylesheet">
|
<link href="/static/style.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ templ AdminLibrary(user User) {
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Library Management - Bookmann</title>
|
<title>Library Management - Bookmann</title>
|
||||||
<script src="/static/htmx.min.js"></script>
|
<script src="/static/htmx.min.js"></script>
|
||||||
|
<script src="/static/toast.js"></script>
|
||||||
<link href="/static/style.css" rel="stylesheet">
|
<link href="/static/style.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ templ AdminProfile(user User) {
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Profile Settings - Bookmann</title>
|
<title>Profile Settings - Bookmann</title>
|
||||||
<script src="/static/htmx.min.js"></script>
|
<script src="/static/htmx.min.js"></script>
|
||||||
|
<script src="/static/toast.js"></script>
|
||||||
<link href="/static/style.css" rel="stylesheet">
|
<link href="/static/style.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ templ Dashboard(user User) {
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Dashboard - Bookmann</title>
|
<title>Dashboard - Bookmann</title>
|
||||||
<script src="/static/htmx.min.js"></script>
|
<script src="/static/htmx.min.js"></script>
|
||||||
|
<script src="/static/toast.js"></script>
|
||||||
<link href="/static/style.css" rel="stylesheet">
|
<link href="/static/style.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
|
|||||||
+2
-53
@@ -8,6 +8,7 @@ templ Index(loggedIn bool) {
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Bookmann - Home</title>
|
<title>Bookmann - Home</title>
|
||||||
<script src="/static/htmx.min.js"></script>
|
<script src="/static/htmx.min.js"></script>
|
||||||
|
<script src="/static/toast.js"></script>
|
||||||
<link href="/static/style.css" rel="stylesheet">
|
<link href="/static/style.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
@@ -238,59 +239,7 @@ templ Index(loggedIn bool) {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<script>
|
<script src="/static/theme.js"></script>
|
||||||
function applyTheme(theme) {
|
|
||||||
document.body.className = `theme-${theme}`;
|
|
||||||
localStorage.setItem('theme', theme);
|
|
||||||
}
|
|
||||||
function loadTheme() {
|
|
||||||
const theme = localStorage.getItem('theme') || 'tokyo-night';
|
|
||||||
applyTheme(theme);
|
|
||||||
}
|
|
||||||
function changeTheme() {
|
|
||||||
const theme = document.getElementById('theme-select').value;
|
|
||||||
applyTheme(theme);
|
|
||||||
// Save to server if logged in
|
|
||||||
fetch('/api/auth/theme', {
|
|
||||||
method: 'PUT',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization': 'Bearer ' + localStorage.getItem('token')
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ theme })
|
|
||||||
}).catch(err => console.log('Theme save failed', err));
|
|
||||||
}
|
|
||||||
function loadUserTheme() {
|
|
||||||
// If logged in, load from profile
|
|
||||||
const token = localStorage.getItem('token');
|
|
||||||
if (token) {
|
|
||||||
fetch('/api/auth/profile', {
|
|
||||||
headers: { 'Authorization': 'Bearer ' + token }
|
|
||||||
}).then(res => res.json()).then(data => {
|
|
||||||
if (data.theme) applyTheme(data.theme);
|
|
||||||
}).catch(() => {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
|
||||||
loadTheme();
|
|
||||||
loadUserTheme();
|
|
||||||
document.getElementById('theme-select').value = localStorage.getItem('theme') || 'tokyo-night';
|
|
||||||
|
|
||||||
// Smooth scroll for anchor links
|
|
||||||
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
|
||||||
anchor.addEventListener('click', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
const target = document.querySelector(this.getAttribute('href'));
|
|
||||||
if (target) {
|
|
||||||
target.scrollIntoView({
|
|
||||||
behavior: 'smooth',
|
|
||||||
block: 'start'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ templ Login() {
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Login</title>
|
<title>Login</title>
|
||||||
<script src="/static/htmx.min.js"></script>
|
<script src="/static/htmx.min.js"></script>
|
||||||
|
<script src="/static/toast.js"></script>
|
||||||
<link href="/static/style.css" rel="stylesheet">
|
<link href="/static/style.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ templ Register() {
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Register</title>
|
<title>Register</title>
|
||||||
<script src="/static/htmx.min.js"></script>
|
<script src="/static/htmx.min.js"></script>
|
||||||
|
<script src="/static/toast.js"></script>
|
||||||
<link href="/static/style.css" rel="stylesheet">
|
<link href="/static/style.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
|
|||||||
Reference in New Issue
Block a user