Add web UI: login, dashboard, and share management (templ + Tailwind + htmx)
New internal/web package mounted at /ui/, separate from DAV Basic Auth: - Cookie-based sessions (opaque random tokens in a new web_sessions SQLite table, internal/db/sessions.go), checked against the same cfg.Users/bcrypt credentials as DAV Basic Auth. - Dashboard listing the logged-in user's own calendars/address books, who they're shared with, and what's shared with them. - Share/unshare directly from the dashboard, updated in place via htmx partial swaps (POST to create/update, DELETE to revoke). Always verifies the resource actually belongs to the logged-in user before granting a share. - Templates written in templ (internal/web/templates/*.templ, generated *_templ.go committed), styled with Tailwind CSS v4 (web/input.css, compiled to web/static/app.css), with htmx vendored as a static file for the dynamic bits. Both are embedded into the binary at build time (web/staticassets.go) so the compiled server has no Node.js/web/ runtime dependency. - Wired into cmd/server/main.go at /ui/ alongside the existing /cal/, /card/, /files/ routes; welcome page links to it. - Tests: internal/web/server_test.go covers login success/failure, the login-required redirect, dashboard rendering, share/unshare including the htmx-v2-sends-DELETE-params-as-query-string quirk, and rejecting shares of resources the user doesn't own. - Docs: README (new 'Web UI' section, updated sharing section, project layout, dependencies) and copilot-instructions updated accordingly. Makefile: new templ-generate/web-deps/web-css targets. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package templates
|
||||
|
||||
templ Layout(title string, username string) {
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="h-full bg-gray-50">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>{ title } · nidus</title>
|
||||
<link rel="stylesheet" href="/ui/static/app.css"/>
|
||||
<script src="/ui/static/htmx.min.js" defer></script>
|
||||
</head>
|
||||
<body class="h-full text-gray-900">
|
||||
<nav class="bg-white border-b border-gray-200">
|
||||
<div class="max-w-4xl mx-auto px-4 py-3 flex items-center justify-between">
|
||||
<a href="/ui/" class="font-semibold text-lg tracking-tight">nidus</a>
|
||||
if username != "" {
|
||||
<div class="flex items-center gap-4 text-sm text-gray-600">
|
||||
<span>{ username }</span>
|
||||
<a href="/ui/logout" class="text-red-600 hover:underline">Logout</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</nav>
|
||||
<main class="max-w-4xl mx-auto px-4 py-8">
|
||||
{ children... }
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
Reference in New Issue
Block a user