Replace Pico CSS with a custom Solis-style design system — warm amber
on cream, Outfit font, 260px sidebar (logged in) or sticky public
header (logged out), soft amber-tinted shadows, cubic-bezier spring
animations on toasts and modals.
- Add static/css/style.css with the full design token system
- Add base.html + content-block pattern; each page defines its own
{{define "content"}} and base.html provides the chrome
- pageData gains ActiveNav; adminPage(w, r, nav) sets it; handlers
pass the right value for every admin route
- Standalone pages (login, 404, embed) render without base.html
- Templates use Solis-style data-table, card, stats-bar, tag-pill,
alert, btn components
- Remove vendored Pico CSS (83KB) and the old style.css (12KB)
- Update AGENTS.md and CLAUDE.md to reflect the new design system
Bug fixes during the redesign:
- Preview dialog now only shows when [open] (UA default was being
overridden by display:flex)
- Preview dialog centered via explicit top/left/transform — the
browser's default margin:auto centering fights with display:flex
on <dialog>
- Add ?embed=1 route that renders paste content without base.html
chrome, so the admin paste preview iframe shows only the body
Tested: go build ./... clean, go vet ./... clean, binary boots.
72 lines
1.7 KiB
Go
72 lines
1.7 KiB
Go
package server
|
|
|
|
import (
|
|
"embed"
|
|
"fmt"
|
|
"html/template"
|
|
"io"
|
|
)
|
|
|
|
//go:embed all:templates
|
|
var templateFS embed.FS
|
|
|
|
//go:embed all:static
|
|
var staticFS embed.FS
|
|
|
|
var templateMap map[string]*template.Template
|
|
|
|
func initTemplates() {
|
|
templateMap = make(map[string]*template.Template)
|
|
|
|
// Pages that use the base layout (sidebar if logged in, public header otherwise).
|
|
// Each gets its own parsed template set so their {{define "content"}} blocks don't collide.
|
|
layoutPages := []string{
|
|
"index.html",
|
|
"admin.html",
|
|
"admin_edit.html",
|
|
"admin_bin.html",
|
|
"admin_bin_edit.html",
|
|
"admin_uploads.html",
|
|
"bin_view.html",
|
|
"bin_token.html",
|
|
}
|
|
|
|
for _, page := range layoutPages {
|
|
t := template.Must(
|
|
template.New("").ParseFS(templateFS, "templates/base.html", "templates/"+page),
|
|
)
|
|
templateMap[page] = t
|
|
}
|
|
|
|
// Standalone pages (no base layout wrapper) — render themselves directly.
|
|
standalonePages := []string{
|
|
"admin_login.html",
|
|
"404.html",
|
|
"bin_view_embed.html", // for ?embed=1 iframe preview
|
|
}
|
|
for _, page := range standalonePages {
|
|
t := template.Must(
|
|
template.New("").ParseFS(templateFS, "templates/"+page),
|
|
)
|
|
templateMap[page] = t
|
|
}
|
|
}
|
|
|
|
func renderTemplate(w io.Writer, name string, data any) error {
|
|
t, ok := templateMap[name]
|
|
if !ok {
|
|
return fmt.Errorf("template %q not found", name)
|
|
}
|
|
// Layout pages render via the base template (which calls {{template "content" .}}).
|
|
// Standalone pages render by their own filename.
|
|
standalone := map[string]bool{
|
|
"admin_login.html": true,
|
|
"404.html": true,
|
|
"bin_view_embed.html": true,
|
|
}
|
|
if standalone[name] {
|
|
return t.ExecuteTemplate(w, name, data)
|
|
}
|
|
return t.ExecuteTemplate(w, "base", data)
|
|
}
|