Standard Alpine evaluates every attribute expression through new Function(), which a strict Content-Security-Policy cannot allow. Swap to the official CSP-safe build (@alpinejs/csp), whose parser evaluates expressions against registered component scope without eval. script-src now carries only 'self' and 'unsafe-inline' (the latter still required by the pre-paint theme flash guard). Bindings rewritten out of the unsupported expression shapes: - 21 multi-statement sequences across admin, audio_reader, docs, header, index, and reader became single component methods (init/loadWatchStatus hooks, commitScrub, pickSkip, pickSpeed, pickDefaultSpeed, chooseSleepOption, chooseSleepClockMode, toggleFxInvert, openPageThumbs, submitNote, clearSearch, pickReadingTheme) - the header sidebar's inline x-data (openPanel/themeMode IIFE) became a registered sidebarShell component; openPanel itself moved to the header root so every sidebar panel shares one open state - the appearance-panel moved into the component init() - header init() now also seeds openPanel from localStorage (or the admin section on /admin pages) Alpine magics (, , , ) remain available — the CSP evaluator injects them into scope. The Playwright suite covers the converted surfaces end to end.
122 lines
5.4 KiB
Templ
122 lines
5.4 KiB
Templ
package templates
|
|
|
|
templ Index(loggedIn bool, registrationEnabled bool) {
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
@ThemeFlashGuard()
|
|
<meta charset="UTF-8"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<title>Bookhoard - Home</title>
|
|
<script src="/static/htmx.min.js"></script>
|
|
<script type="module" src="/static/main.js"></script>
|
|
<link href="/static/style.css" rel="stylesheet"/>
|
|
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg"/>
|
|
</head>
|
|
<body x-data="index">
|
|
<div class="absolute top-4 right-4 z-10">
|
|
<select
|
|
id="theme-select"
|
|
@change="changeTheme"
|
|
class="input w-auto py-1.5 pr-8 text-sm cursor-pointer"
|
|
aria-label="Theme"
|
|
>
|
|
<optgroup label="Dark">
|
|
for _, opt := range ThemeOptionsFor(ModeDark) {
|
|
<option value={ opt.Name }>{ opt.Label }</option>
|
|
}
|
|
</optgroup>
|
|
<optgroup label="Light">
|
|
for _, opt := range ThemeOptionsFor(ModeLight) {
|
|
<option value={ opt.Name }>{ opt.Label }</option>
|
|
}
|
|
</optgroup>
|
|
</select>
|
|
</div>
|
|
<!-- Hero -->
|
|
<div class="brand-gradient relative overflow-hidden">
|
|
<div class="max-w-7xl mx-auto px-4 py-20 sm:px-6 sm:py-28 lg:py-36 lg:px-8 text-center">
|
|
<div class="inline-flex items-center gap-3 mb-6">
|
|
<span class="text-5xl">📚</span>
|
|
<span class="text-4xl sm:text-6xl font-extrabold tracking-tight" style="color: var(--text-primary)">Bookhoard</span>
|
|
</div>
|
|
<p class="mt-4 max-w-2xl mx-auto text-lg sm:text-xl" style="color: var(--text-secondary)">
|
|
Your personal ebook management system. Track reading progress, organize your library, and sync across every device.
|
|
</p>
|
|
<div class="mt-10 flex items-center justify-center gap-3">
|
|
if loggedIn {
|
|
<a href="/dashboard" class="btn btn-primary px-8 py-3 text-base">Go to Library</a>
|
|
} else {
|
|
<a href="#auth" class="btn btn-primary px-8 py-3 text-base">Get Started</a>
|
|
<a href="#features" class="btn btn-secondary px-6 py-3 text-base">Learn more</a>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Features -->
|
|
<div id="features" class="py-16 sm:py-20">
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
<div class="text-center mb-12">
|
|
<h2 class="text-3xl font-extrabold tracking-tight" style="color: var(--text-primary)">Why Bookhoard?</h2>
|
|
<p class="mt-3 text-lg" style="color: var(--text-secondary)">Everything you need to manage your ebook library</p>
|
|
</div>
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
|
<div class="card p-6">
|
|
<div class="grid place-items-center h-12 w-12 rounded-xl mb-4" style="background-color: var(--accent-muted); color: var(--accent);">
|
|
@Icon("book-open", "h-6 w-6")
|
|
</div>
|
|
<h3 class="text-lg font-semibold mb-2" style="color: var(--text-primary)">Reading Progress</h3>
|
|
<p class="text-sm" style="color: var(--text-secondary)">Track progress across all your ebooks with detailed statistics and sync.</p>
|
|
</div>
|
|
<div class="card p-6">
|
|
<div class="grid place-items-center h-12 w-12 rounded-xl mb-4" style="background-color: var(--accent-muted); color: var(--accent);">
|
|
@Icon("palette", "h-6 w-6")
|
|
</div>
|
|
<h3 class="text-lg font-semibold mb-2" style="color: var(--text-primary)">Beautiful Themes</h3>
|
|
<p class="text-sm" style="color: var(--text-secondary)">Choose from 11 stunning themes including Tokyo Night, Dracula, and Catppuccin.</p>
|
|
</div>
|
|
<div class="card p-6">
|
|
<div class="grid place-items-center h-12 w-12 rounded-xl mb-4" style="background-color: var(--accent-muted); color: var(--accent);">
|
|
@Icon("device", "h-6 w-6")
|
|
</div>
|
|
<h3 class="text-lg font-semibold mb-2" style="color: var(--text-primary)">Cross-Device Sync</h3>
|
|
<p class="text-sm" style="color: var(--text-secondary)">Built with Go and HTMX for fast performance and seamless device syncing.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Auth -->
|
|
if !loggedIn {
|
|
<div id="auth" class="pb-20 px-4">
|
|
<div class="max-w-md mx-auto">
|
|
<div class="text-center mb-8">
|
|
<h2 class="text-2xl font-extrabold tracking-tight" style="color: var(--text-primary)">Welcome back</h2>
|
|
<p class="mt-2" style="color: var(--text-secondary)">Sign in to start managing your ebook library</p>
|
|
</div>
|
|
<div class="card p-8">
|
|
<form hx-post="/api/auth/login" hx-target="#auth-result" hx-swap="innerHTML" class="space-y-4">
|
|
<div>
|
|
<label class="block text-xs font-semibold uppercase tracking-wide mb-2" style="color: var(--text-secondary)">Email or Username</label>
|
|
<input type="text" name="login" class="input" required/>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-semibold uppercase tracking-wide mb-2" style="color: var(--text-secondary)">Password</label>
|
|
<input type="password" name="password" class="input" required/>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary w-full py-2.5">Sign In</button>
|
|
</form>
|
|
if registrationEnabled {
|
|
<p class="text-center text-sm mt-4" style="color: var(--text-secondary)">
|
|
No account?
|
|
<a href="/register" class="font-medium hover:underline" style="color: var(--accent)">Register</a>
|
|
</p>
|
|
}
|
|
</div>
|
|
<div id="auth-result" class="mt-4 text-center text-sm"></div>
|
|
</div>
|
|
</div>
|
|
}
|
|
</body>
|
|
</html>
|
|
}
|