Commit Graph
7 Commits
Author SHA1 Message Date
lucioandClaude Fable 5 a9da249760 Remove unsafe-inline from script-src CSP
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]>
2026-06-09 20:14:30 -07:00
lucio 9e10bc3031 Redesign UI to match Solis design system
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.
2026-06-06 14:15:19 -07:00
lucioandClaude Opus 4.8 f013e1f22b Compress over-limit images client-side to fit instead of rejecting them
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]>
2026-06-04 23:24:11 -07:00
lucio 2f5c31499d security review 2026-06-02 01:24:19 -07:00
lucioandClaude Opus 4.6 1b91014d1c Preserve original upload filenames, share upload JS, polish UI, update docs
- 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]>
2026-05-21 01:43:38 -07:00
lucioandClaude Opus 4.6 b069027d56 Add generic file upload support to pastebin (5 MB max)
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]>
2026-05-21 00:48:14 -07:00
lucio b45c837c1a Add image upload functionality with management interface 2026-04-08 01:06:12 -07:00