Add /manage (edit, delete) and -default-view #1

Merged
puttaalu merged 2 commits from manage-endpoint into trunk-ng 2026-10-03 11:15:40 +00:00
Collaborator

Two additions, one commit each, for running two galleries from one
photog build behind nginx. Both are opt-in: without the new flags an
existing install behaves exactly as before.

-default-view timeline|grid (f1abd45)

Picks which view is published at /; the other moves to /timeline/
or /grid/. Defaults to timeline, so nothing moves unless asked.
Page paths and the links between the views are derived from the
setting instead of being hardcoded. NixOS:
services.photogallery.defaultView.

/manage: edit and delete published photos (3f71935)

  • Off by default; enabled with -manage
    (NixOS services.photogallery.manage.enable, which also adds the
    nginx location). Without the flag the routes are not registered and
    the paths 404.
  • GET /manage lists every photo with View / Edit / Delete links.
  • Edit rewrites caption and date in the sidecar; the image is never
    touched.
  • Delete asks for confirmation, then removes the image, the sidecar
    and every generated file. Permanent, no trash.
  • Same model as /upload: nginx guards it, nothing public links to
    it. Handlers live in a new manage.go; the upload code is
    untouched.
  • Form posts are checked for same origin, since browsers replay basic
    auth on cross-site requests.
  • Builds now prune what a delete or a date change leaves behind: day
    pages of days without photos, pager pages past the last one, and
    the old directory of a view that became the default.

For the reviewer

  • NewGenerator and NewServer each take one more argument.
  • A hand-rolled nginx config needs a location /manage block; the
    pages 404 without it.
  • Whoever has the upload login can also delete.

Testing

generator_test.go and manage_test.go are the repo's first tests;
go vet and go test pass. Running in production on FreeBSD 15.1
behind nginx, two instances from one binary, one with
-default-view grid, both with -manage. Nothing browser-level.

🤖 Generated with Claude Code

Two additions, one commit each, for running two galleries from one photog build behind nginx. Both are opt-in: without the new flags an existing install behaves exactly as before. ## `-default-view timeline|grid` (f1abd45) Picks which view is published at `/`; the other moves to `/timeline/` or `/grid/`. Defaults to `timeline`, so nothing moves unless asked. Page paths and the links between the views are derived from the setting instead of being hardcoded. NixOS: `services.photogallery.defaultView`. ## `/manage`: edit and delete published photos (3f71935) - Off by default; enabled with `-manage` (NixOS `services.photogallery.manage.enable`, which also adds the nginx location). Without the flag the routes are not registered and the paths 404. - `GET /manage` lists every photo with View / Edit / Delete links. - Edit rewrites caption and date in the sidecar; the image is never touched. - Delete asks for confirmation, then removes the image, the sidecar and every generated file. Permanent, no trash. - Same model as `/upload`: nginx guards it, nothing public links to it. Handlers live in a new `manage.go`; the upload code is untouched. - Form posts are checked for same origin, since browsers replay basic auth on cross-site requests. - Builds now prune what a delete or a date change leaves behind: day pages of days without photos, pager pages past the last one, and the old directory of a view that became the default. ## For the reviewer - `NewGenerator` and `NewServer` each take one more argument. - A hand-rolled nginx config needs a `location /manage` block; the pages 404 without it. - Whoever has the upload login can also delete. ## Testing `generator_test.go` and `manage_test.go` are the repo's first tests; `go vet` and `go test` pass. Running in production on FreeBSD 15.1 behind nginx, two instances from one binary, one with `-default-view grid`, both with `-manage`. Nothing browser-level. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
puttaalu changed target branch from trunk to trunk-ng 2026-10-03 11:15:31 +00:00
puttaalu added 2 commits 2026-10-03 11:15:31 +00:00
The chosen view is published at /, the other under /timeline/ or
/grid/. Page paths, pager links and the cross-links between the views
are derived from the setting. The directory named after the default
view is removed on build, since it can only be a leftover from before
a switch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
/manage lists every photo; /manage/edit/{slug} rewrites the photo's
.toml sidecar (caption, date), /manage/delete/{slug} asks for
confirmation and then removes the image, its sidecar and everything
generated from them. Builds now drop day pages of days without photos
and pager pages past the last one, so a delete or a date change leaves
nothing behind.

The pages are off by default: the routes are only registered with
-manage, so an install that does not opt in has no such code path and
answers 404. NixOS gets services.photogallery.manage.enable, which
also adds the nginx location only when on. Like /upload, the pages
carry no auth of their own and are not linked from the public site.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
puttaalu merged commit 43075f00d4 into trunk-ng 2026-10-03 11:15:40 +00:00
fox deleted branch manage-endpoint 2026-10-05 05:31:54 +00:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: puttaalu/photog#1