summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-15 22:56:32 +0300
committerPaul Buetow <paul@buetow.org>2026-06-15 23:50:41 +0300
commit06b910863906faa5f01d7f7067cdbaa8af89dfba (patch)
tree27035bd88aa8ac25976d6313779a994abbaf34a0 /bin
parent441f64ac277cf87179c97a1e4ec5a95f69dfe25e (diff)
Stats backgrounds: fit the category instead of album-wide random
The filter mini-album pages all drew their blurred background from the whole album, so a filter page's background did not relate to its category. Mirror the main album instead: - A filter gallery's background is now a random photo from THAT filter's own set (like the album preview pages pick a random album photo). - A filter view page's background is the photo it shows (like the album view pages). - The stats overview still uses a random album-wide photo. Adds _stats_pick_background (random pick from a filter's photo list) and drops the now-unused album-wide background preload from render_filter_pages. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/shuriken32
1 files changed, 27 insertions, 5 deletions
diff --git a/bin/shuriken b/bin/shuriken
index 2e021d0..71c2407 100755
--- a/bin/shuriken
+++ b/bin/shuriken
@@ -3762,6 +3762,26 @@ _stats_random_background() {
printf '%s' "${STATS_BG_PHOTOS[index]}"
}
+# Pick a seeded-random photo from a newline-separated list (a filter's own
+# photos) for a filter gallery's blurred background, so the background fits the
+# category. Empty when the list is empty.
+_stats_pick_background() {
+ local -r context="$1"; shift
+ local -r photos="$1"; shift
+ local -a list=()
+ local photo
+ local -i index
+
+ while IFS= read -r photo; do
+ [ -n "$photo" ] && list+=("$photo")
+ done <<< "$photos"
+ if (( ${#list[@]} == 0 )); then
+ return
+ fi
+ index=$(random_index "photo:filter:$context" "${#list[@]}")
+ printf '%s' "${list[index]}"
+}
+
render_stats_page() {
local -r html_dir="$1"; shift
local -r backhref="$1"; shift
@@ -3869,7 +3889,10 @@ _stats_render_filter_gallery() {
thumbs=$(_stats_build_filter_thumbs \
"$backhref_html" "${STATS_FILTER_PHOTOS[$pagebase]}")
- background_image=$(_stats_random_background "$pagebase/index")
+ # Background fits the category: a random photo from this filter's own set,
+ # mirroring how the album preview pages pick a random album photo.
+ background_image=$(_stats_pick_background \
+ "$pagebase" "${STATS_FILTER_PHOTOS[$pagebase]}")
template header index.html \
html_dir "$html_dir" backhref "$backhref" \
blurs_dir "$STATS_BLURS_DIR" background_image "$background_image" \
@@ -3897,7 +3920,9 @@ _stats_render_filter_view_page() {
body=$(_stats_build_filterview_body \
"$STATS_FILTER_BACKHREF" "$photo" "$prev" "$next")
- background_image=$(_stats_random_background "$pagebase/$index")
+ # The view page's blurred background is the photo it shows, exactly like the
+ # album view pages.
+ background_image="$photo"
template header "$page" \
html_dir "$html_dir" backhref "$backhref" \
blurs_dir "$STATS_BLURS_DIR" background_image "$background_image" \
@@ -4029,9 +4054,6 @@ render_filter_pages() {
if (( ${#STATS_FILTER_PHOTOS[@]} == 0 )); then
return
fi
- # Load the background photo list once now so every forked render job inherits
- # the cached array rather than rescanning the photos directory per page.
- _stats_load_background_photos
while IFS= read -r pagebase; do
_stats_enqueue_filter_album "$pagebase" \
render_job_pids render_job_statuses render_job_labels render_failed