feat(manage): add /manage pages to edit and delete photos, behind -manage

/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>
This commit is contained in:
fox
2026-09-30 08:17:17 +02:00
co-authored by Claude Fable 5.1
parent f1abd45f24
commit 3f719359de
12 changed files with 1108 additions and 21 deletions
+11 -3
View File
@@ -88,6 +88,8 @@ in {
description = "View published at the site root. The other one is published under /timeline/ or /grid/.";
};
manage.enable = lib.mkEnableOption "the /manage pages for editing and deleting published photos (served behind the same htpasswd as /upload)";
nginx = {
enable = lib.mkEnableOption "nginx virtual host for photogallery";
@@ -100,7 +102,7 @@ in {
htpasswdFile = lib.mkOption {
type = lib.types.path;
example = "/etc/nginx/.htpasswd-gallery";
description = "Path to htpasswd file protecting the /upload endpoint.";
description = "Path to htpasswd file protecting the /upload and /manage endpoints.";
};
enableACME = lib.mkOption {
@@ -140,7 +142,7 @@ in {
User = "photogallery";
Group = "photogallery";
ExecStart = lib.escapeShellArgs [
ExecStart = lib.escapeShellArgs ([
"${pkg}/bin/photogallery"
"--content" cfg.contentDir
"--output" cfg.outputDir
@@ -155,7 +157,7 @@ in {
"--ml-family" cfg.mlFamily
"--page-size" (toString cfg.pageSize)
"--default-view" cfg.defaultView
];
] ++ lib.optional cfg.manage.enable "--manage");
Restart = "on-failure";
RestartSec = "5s";
@@ -191,6 +193,12 @@ in {
basicAuthFile = cfg.nginx.htpasswdFile;
extraConfig = "client_max_body_size 20M;";
};
locations."/manage" = lib.mkIf cfg.manage.enable {
proxyPass = "http://127.0.0.1:${toString cfg.port}";
basicAuth = "gallery";
basicAuthFile = cfg.nginx.htpasswdFile;
};
};
};
})