Move every inline <script> block and on*= attribute out of the templates
into per-page files under static/js/, then tighten the CSP to
script-src 'self' so injected inline scripts are actually blocked.
- static/js/base.js: QR modal, form[data-confirm] submit confirmation,
and a shared glimmerCopy clipboard helper (loaded by base.html)
- One script per template: index, bin_view, bin_token, admin,
admin_edit, admin_bin, admin_bin_edit, admin_uploads
- Template data now flows through data-* attributes (data-slug,
data-filename, data-max-mb, ...) instead of being interpolated
into JS; confirm() prompts use data-confirm
- style-src keeps unsafe-inline for the style="" attributes
- Update CLAUDE.md / AGENTS.md with the no-inline-JS rule
Verified in a live browser session: shorten flow, login, QR modal,
paste editor (token radios, name preview), paste cards (preview
dialog, expand/close), public paste view, token prompt redirect, and
uploads page - no console errors or CSP violations.
Co-Authored-By: Claude Fable 5 <[email protected]>
- Reject images over 24 MP before full decode (decodeImageBounded) so a
small PNG declaring huge dimensions cannot OOM the RPi Zero via the
public thumbnail route or the resize handler
- Graceful shutdown on SIGINT/SIGTERM with a 10s drain so the SQLite DB
closes cleanly on deploys
- Set the Secure flag on the csrf cookie (same isHTTPS rule as the
session cookie); csrfToken is now a *Server method
- Add handlers_test.go: auth, login, CSRF, upload serving (traversal +
forced attachment), and decompression-bomb coverage
- Track remaining work (CSP unsafe-inline removal) in plan.md
Co-Authored-By: Claude Fable 5 <[email protected]>
- Verify CSRF on POST /admin/uploads/resize (was the only state-changing
admin route without a check) and cap its body at 1 MB
- limitBody: exact-match /admin/upload and /admin/upload-file instead of
a prefix match that also exempted /admin/uploads/{delete,resize}
- Only honour X-Forwarded-Proto behind a trusted proxy (same rule as
X-Forwarded-For); fall back to the configured base_url scheme for the
session cookie Secure flag and baseURL()
- handleAdminBinSave: return 500 on non-ErrNoRows DB error instead of
dereferencing a nil paste
Co-Authored-By: Claude Fable 5 <[email protected]>
Programmatic short-link creation that shares the same bearer key as the
MCP endpoint. Registered only when [mcp].enabled is true and api_key is
set, so a misconfigured server never exposes the route unauthenticated;
unauthenticated visitors hitting /api/links get a plain 404.
- POST /api/links accepts {"url","slug?"}, returns 201/200 with the
same snake_case payload shape as the MCP create_link tool.
- Constant-time Bearer / X-API-Key auth (reuses mcpAPIKeyAuth helper).
- 4 KB body cap, DisallowUnknownFields, URL auto-scheme, dedupe on URL.
- 13 unit tests cover auth, validation, dedupe, and duplicate-slug.
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.
Sessions were stored in an in-memory map, so every server reboot logged the
admin out. Back the session store with the database instead:
- Add a sessions table (token, expires_at, created_at) created via the existing
migrate() (CREATE TABLE IF NOT EXISTS), backwards-compatible with deployed DBs.
- Add CreateSession / SessionValid / DeleteSession / CleanupSessions; expiry is
checked in SQL against datetime('now') (UTC).
- sessionStore is now a thin DB-backed wrapper with the same Create/Valid/Delete
interface; the hourly cleanup goroutine purges expired rows (plus once at
startup). Login, logout, requireAuth, and isLoggedIn are unchanged.
The session cookie was already persistent (MaxAge), so logins now survive both
browser and server restarts until session_hours expiry.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
- Replace the pastes table with a masonry card grid: each card shows the
paste's first image as a thumbnail, a short plain-text summary, meta badges,
and Copy link / Edit / QR / Delete actions.
- Clicking anywhere on a card (except the action buttons) opens an in-page
preview modal with the rendered paste in an iframe; it can be expanded to the
main content area or closed (Esc/backdrop/button). Keyboard accessible.
- Generate and cache 512px (long side) JPEG thumbnails for uploaded images on
first request (GET /uploads/thumb/{filename}); also generated at upload time
and invalidated on resize/delete. WebP falls back to the original.
- Sync the public paste pages (bin_view, bin_token) to the dark theme so they
match the rest of the app and the preview iframe.
- Relax framing headers to same-origin (X-Frame-Options SAMEORIGIN,
frame-ancestors 'self') so the same-origin preview iframe can load; cross-site
framing stays blocked.
- Document the new thumbnail route in the README routes table.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Previously an image at/over the upload size limit was simply rejected with
"File too large", and the limit was hardcoded to 50 MB in the client even when
the server was configured lower. Now:
- The configured image limit (upload.max_size_mb) is surfaced to the client via
pageData.UploadMaxMB and passed to GlimmerUpload.init({maxImageMB}).
- Selecting an over-limit image prompts to compress it in the browser to fit;
the oversized original is never uploaded (Cancel aborts). Images over 10 MB
but under the limit get an optional "compress for faster upload" prompt.
- compressToTarget iteratively fits the file just under the limit: it tries a
JPEG quality ladder (0.85 → 0.4) at each resolution and halves the resolution
on failure, down to a 320 px floor, targeting 95% of the limit for headroom.
If it can't get under the limit it reports the smallest size achieved and
uploads nothing.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
The upload handlers called verifyCSRF (which reads a form value, implicitly
triggering ParseMultipartForm) before parsing the multipart body. When a file
exceeded the MaxBytesReader cap, the parse failed, FormValue returned "", and
the request was rejected as "Invalid CSRF token" (403) instead of a proper
413 "File too large". Small images parsed fine, so only large uploads broke.
- handlers.go: parse the multipart form explicitly before the CSRF check in
both handleUpload and handleFileUpload; report oversized bodies as 413 via
errors.As(http.MaxBytesError) instead of a fragile error-string compare.
- upload.js: offer in-browser canvas compression (downscale + JPEG re-encode)
for images over 10 MB before upload; falls back to the original on failure.
- server.go: allow blob: in CSP img-src so the compressor canvas can load the
selected file.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
- Adds an "uploads" SQLite table (filename → original_name) so the user's
original filename is preserved and used in Content-Disposition headers and
the admin listing instead of the on-disk hex name.
- Extracts shared upload logic to static/upload.js (window.GlimmerUpload),
deduplicating ~80 lines between the uploads page and the paste editor.
- Adds size hints on upload buttons, an extension chip + original name in the
uploads table, and a .ext-chip style.
- Updates CLAUDE.md and README.md (route table, schema, features, project
structure) to reflect the new endpoint and behaviour.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Adds a new POST /admin/upload-file endpoint for uploading any file type
alongside the existing image upload. Files are served with
Content-Disposition: attachment to prevent same-origin XSS via uploaded
HTML/SVG/JS. The display filename embedded in markdown link responses is
sanitized to block markdown injection.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
The JS QR library (qr.min.js) produced unscannable codes. Replaced with
a /admin/qr/{slug} endpoint using the same server-side rsc.io/qr that
already works on the home page.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Normalize Edit/QR/Del button sizes in role=group with consistent
padding, font-size, and white-space:nowrap
- Add QR button to each link row in My Links and Anonymous Links tables
- QR modal uses <dialog> + qr.min.js to generate an inline SVG on click
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Rebrand from "urlshort" to "Glimmer" across the entire codebase:
Go module/imports, build targets, HTML templates, deploy scripts
(including renaming service files), config, and README.
Co-Authored-By: Claude Opus 4.6 <[email protected]>