special-gallery: scope image prev/next/back to special galleries; add tests

This commit is contained in:
2026-03-27 21:04:18 -04:00
parent 0e48a5d9bd
commit 21a3ab40c5
6 changed files with 145 additions and 63 deletions

View File

@@ -115,11 +115,22 @@ def render_image(request, path_text, full_path, special=None):
next_url = None
if prev_path is not None:
rel = prev_path.relative_to(settings.GALLERY_ROOT)
prev_url = gallery_url(rel, False, query_state)
# When viewing from a special gallery, route prev/next through the
# special gallery URL so subsequent navigation preserves the special
# gallery context. Otherwise use the normal gallery URL for the file.
if special is not None:
rel_text = str(rel).replace("\\", "/")
prev_url = append_query(f"/gallery/{special}/{rel_text}/", query_state)
else:
prev_url = gallery_url(rel, False, query_state)
if next_path is not None:
rel = next_path.relative_to(settings.GALLERY_ROOT)
next_url = gallery_url(rel, False, query_state)
if special is not None:
rel_text = str(rel).replace("\\", "/")
next_url = append_query(f"/gallery/{special}/{rel_text}/", query_state)
else:
next_url = gallery_url(rel, False, query_state)
# Back (directory) and Home (root) links and thumbnails
dir_rel = None