summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-15 13:55:32 +0300
committerPaul Buetow <paul@buetow.org>2026-06-15 23:50:40 +0300
commitbe6ae2c9541a01927616b46cf6a683d7ce4519ff (patch)
tree53161337bae46495b8e88b96f1b28b1bd6f9c2ca /tests
parent6e47246dbbc97821b97aa9c45352abc9c2a9aa4a (diff)
Per-camera mini-albums: full-width grid + camera-scoped view navigation
Two fixes to the per-camera pages: - The camera thumbnail grid is now full-width and reflows with the window like the main album. Previously it sat inside the 900px-wide stats column, so wide thumbnails only fit ~2 per row. camera.tmpl now puts the grid in a full-width sibling block (centered by the body, like the album's direct thumbnail children); the heading/back-link stay in the narrow stats column. - Each camera is now a self-contained mini album. Thumbnails link to per-camera view pages (camera-<slug>--<index>.html) whose prev/next cycle only through that camera's photos, instead of linking into the shared album view pages (where next/prev walked the whole album and left the camera). The view pages reuse the album's look (blurred background, EXIF tooltip, animation) and offer Gallery / Details (to the album details page) / Direct-link nav. The "--" index separator can never collide with a gallery name since slugs never contain "--". Adds cameraview.tmpl + its render field, _stats_render_camera_{gallery,views} and the cameraview body builders. Tests updated for the new thumbnail links and extended to assert the per-camera view pages and their camera-scoped navigation; required-context-vars test now also covers the camera and cameraview templates. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/cli.sh63
1 files changed, 48 insertions, 15 deletions
diff --git a/tests/cli.sh b/tests/cli.sh
index 14439bf..a05485c 100755
--- a/tests/cli.sh
+++ b/tests/cli.sh
@@ -3061,6 +3061,7 @@ test::stats_identify_output() {
test_generate_stats_pages_created_and_nav_linked() {
local camera_html
+ local camera_view_html
local config_file
local fake_bin
local -i nav_links
@@ -3093,16 +3094,22 @@ test_generate_stats_pages_created_and_nav_linked() {
test::assert_contains 'background-image: url("./blurs/' \
"$(<"$TEST_TMPDIR/dist/stats.html")"
- # Camera-page thumbnails link into the album view pages (behave like the main
- # album), not the raw image, and point at the thumbs.
+ # The camera gallery is a mini album: thumbnails link to per-camera view
+ # pages (camera-<slug>--<n>.html), not the album view pages or raw images.
camera_html=$(<"$TEST_TMPDIR/dist/camera-canon-eos-r5.html")
test::assert_contains 'src="./thumbs/' "$camera_html"
+ test::assert_contains 'href="./camera-canon-eos-r5--1.html"' "$camera_html"
test::assert_not_contains 'href="./photos/' "$camera_html"
- if ! grep -Eq 'href="\./[0-9]+-[0-9]+\.html"' <<< "$camera_html"; then
- printf 'FAIL: camera page does not link thumbnails to album view pages\n' \
- >&2
- exit 1
- fi
+
+ # A per-camera view page exists and its navigation stays within the camera:
+ # prev/next point at this camera's view pages, plus links back to the gallery
+ # and to the album details page for the photo.
+ test::assert_file_exists "$TEST_TMPDIR/dist/camera-canon-eos-r5--1.html"
+ camera_view_html=$(<"$TEST_TMPDIR/dist/camera-canon-eos-r5--1.html")
+ test::assert_contains 'href="./camera-canon-eos-r5--2.html"' "$camera_view_html"
+ test::assert_contains 'href="./camera-canon-eos-r5.html">Gallery</a>' \
+ "$camera_view_html"
+ test::assert_contains '-details.html">Details</a>' "$camera_view_html"
# The header bar links to the stats page on at least one generated page.
nav_links=$(grep -lF 'stats.html">Stats' "$TEST_TMPDIR"/dist/*.html | wc -l)
@@ -3853,6 +3860,8 @@ test_template_required_context_vars_come_from_render_specs() {
local output
expected=$(cat <<'END'
+camera:backhref camera_name camera_thumbs html_dir
+cameraview:cameraview_body html_dir
details:animation_class backhref exif_details exif_tooltip html_dir page_num photo photos_dir preview_num
footer:backhref html_dir tarball_name
header:backhref background_image blurs_dir html_dir show_header_bar
@@ -3870,6 +3879,8 @@ END
repo_root="$1"; shift
template_name=''
declare -a template_names=(
+ camera
+ cameraview
details
footer
header
@@ -4021,6 +4032,15 @@ SHURIKEN_OUTPUT_MODE=quiet
RANDOM_SEED=camera-test
apply_config_defaults
+# The per-camera view pages read each photo's EXIF tooltip from INCOMING_DIR, so
+# provide empty stand-in files (no ImageMagick here, so the tooltip is empty but
+# the view pages still render with full camera navigation).
+INCOMING_DIR="$dist_dir/incoming"
+mkdir -p "$INCOMING_DIR"
+for stub in a.jpg b.jpg c.png d.jpg; do
+ : > "$INCOMING_DIR/$stub"
+done
+
feed() {
reset_photo_exif_stats
accumulate_photo_stats 'a.jpg' <<'EXIF'
@@ -4058,26 +4078,39 @@ BASH
test::assert_file_exists "$dist_dir/run1/camera-canon-eos-5d-2.html"
test::assert_file_exists "$dist_dir/run1/camera-nikon-co-z6.html"
- # The Canon EOS 5D page lists exactly its two photos as thumbnails, and not
- # the other camera's photo. With no album rendered here, the thumbnail link
- # falls back to the full image under photos/; the img carries a thumb class
- # (plus a seeded animation class) pointing at thumbs/.
+ # The Canon EOS 5D gallery lists exactly its two photos as thumbnails linking
+ # to this camera's own view pages (camera-<slug>--<n>.html), not the other
+ # camera's photo. The img carries a thumb class (plus a seeded animation
+ # class) pointing at thumbs/.
html=$(cat "$dist_dir/run1/camera-canon-eos-5d.html")
- test::assert_contains '<a href="../photos/a.jpg">' "$html"
+ test::assert_contains 'href="../camera-canon-eos-5d--1.html"' "$html"
test::assert_contains 'class="thumb ' "$html"
test::assert_contains 'src="../thumbs/a.jpg" />' "$html"
- test::assert_contains '<a href="../photos/b.jpg">' "$html"
+ test::assert_contains 'href="../camera-canon-eos-5d--2.html"' "$html"
test::assert_not_contains 'photos/c.png' "$html"
test::assert_not_contains 'photos/d.jpg' "$html"
+ test::assert_not_contains 'href="../photos/' "$html"
# Heading shows the (trusted) camera label and a back-to-stats link.
test::assert_contains 'Canon EOS 5D' "$html"
test::assert_contains '<a href="../stats.html">Back to stats</a>' "$html"
- # The EXIF-derived label with & and < is HTML-escaped in the heading.
+ # Each per-camera view page exists and its prev/next stay within the camera
+ # (two photos, so view 1's prev and next both point at view 2), with a link
+ # back to the gallery.
+ test::assert_file_exists "$dist_dir/run1/camera-canon-eos-5d--1.html"
+ test::assert_file_exists "$dist_dir/run1/camera-canon-eos-5d--2.html"
+ html=$(cat "$dist_dir/run1/camera-canon-eos-5d--1.html")
+ test::assert_contains 'href="../camera-canon-eos-5d--2.html" class="arrow"' \
+ "$html"
+ test::assert_contains 'href="../camera-canon-eos-5d.html">Gallery</a>' "$html"
+ test::assert_contains 'src=' "$html"
+
+ # The EXIF-derived label with & and < is HTML-escaped in the heading, and its
+ # single photo links to that camera's own view page.
html=$(cat "$dist_dir/run1/camera-nikon-co-z6.html")
test::assert_contains 'Nikon &amp; Co &lt;Z6&gt;' "$html"
test::assert_not_contains 'Nikon & Co <Z6>' "$html"
- test::assert_contains '<a href="../photos/c.png">' "$html"
+ test::assert_contains 'href="../camera-nikon-co-z6--1.html"' "$html"
# Output is deterministic: the second run is byte-identical to the first.
html=$(cat "$dist_dir/run1/camera-canon-eos-5d.html")