- templates/layout.templ: base HTML shell per UI-SPEC §Base Layout Contract (max-w-5xl container, slate-50 header, slate-200 borders, footer copy, /static/tailwind.css in <head>, /static/htmx.min.js deferred at body end — D-10: HTMX never loaded from a CDN) - templates/index.templ: root page consuming @ui.Card and @ui.Button for the canonical HTMX demo (UI-SPEC §Component Library Contract canonical block) - templates/fragments.templ: TimeFragment renders <span> with RFC3339 UTC timestamp; templ auto-escapes interpolation (T-01-13) - internal/web/handlers.go: HealthzHandler (200 ok / 503 degraded per D-20, 2s Ping timeout), IndexHandler, DemoTimeHandler with injected clock - internal/web/router.go: Pinger interface; NewRouter wires RequestIDMiddleware → RealIP → SlogLoggerMiddleware → Recoverer (D-08 + Pitfall 6 — chi middleware.Logger deliberately NOT registered) and routes /, /healthz, /demo/time, /static/* via http.FileServer (T-01-08 path traversal blocked by http.Dir) All six handler tests + ui package tests are GREEN under default go test.
33 lines
1.3 KiB
Text
33 lines
1.3 KiB
Text
// Package templates owns the server-rendered HTML for the Phase 1 walking
|
|
// skeleton. Each *.templ file compiles to a *_templ.go file via `templ
|
|
// generate`; generated files are gitignored.
|
|
package templates
|
|
|
|
// Layout is the base HTML shell every page renders inside. The structural
|
|
// classes, container width (max-w-5xl), horizontal padding, header strip,
|
|
// footer, and asset references (/static/tailwind.css, /static/htmx.min.js)
|
|
// are locked by UI-SPEC §Base Layout Contract and CONTEXT D-10 — do NOT
|
|
// load HTMX from a CDN.
|
|
templ Layout(title string) {
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>{ title }</title>
|
|
<link rel="stylesheet" href="/static/tailwind.css"/>
|
|
</head>
|
|
<body class="min-h-screen bg-white text-slate-900 antialiased">
|
|
<header class="bg-slate-50 border-b border-slate-200">
|
|
<div class="mx-auto max-w-5xl px-4 sm:px-6 py-4"></div>
|
|
</header>
|
|
<main class="mx-auto max-w-5xl px-4 sm:px-6 py-8">
|
|
{ children... }
|
|
</main>
|
|
<footer class="mx-auto max-w-5xl px-4 sm:px-6 py-6 text-sm text-slate-600">
|
|
Phase 1 · Walking skeleton
|
|
</footer>
|
|
<script src="/static/htmx.min.js" defer></script>
|
|
</body>
|
|
</html>
|
|
}
|