# Album photo listing and random selection. Split out of # album-render.source.sh (task ar0) so the "which photos are in this album, in # what order, and which one do we pick for a background/splash" concern lives # apart from the page orchestration, the tile-layout deciders and the thumbnail # HTML. This is selection POLICY (shuffle/sort/chronological, splash-requires-a- # blur, seeded random pick) and changes for different reasons than the # rendering plumbing. # # These helpers are called by the orchestrator (album-render.source.sh) and by # the per-page render jobs at runtime; all libs are sourced before any code runs, # so availability does not depend on source order. # Main album display order, in precedence order (task 8v0): # 1. CHRONOLOGICAL_ORDER=yes -> chronological_photo_files (EXIF date taken, # ascending, falling back to filename order for photos without a usable # one). # 2. otherwise -> the historical maybe_shuffle path (seeded/random SHUFFLE, or # plain filename sort when SHUFFLE=no). # CHRONOLOGICAL_ORDER therefore takes precedence over SHUFFLE when both are # set: a chronological album is meant to read as a timeline, so an enabled # shuffle must not silently re-scramble it. This is deliberately a config-level # choice rather than an error, so flipping SHUFFLE on/off (e.g. via the CLI # flags) while experimenting does not require also touching # CHRONOLOGICAL_ORDER. Unlike the other photo listings this one keeps its own # find rather than using list_photos (photo-list.source.sh): both order modes # need the raw filename list before applying their own ordering, not a plain # sort. Uses $FIND (compat.source.sh) since -printf is a GNU-only action. album_photo_files() { local -r photos_dir="$1"; shift if [ "$CHRONOLOGICAL_ORDER" = yes ]; then chronological_photo_files "$photos_dir" return fi "$FIND" "$DIST_DIR/$photos_dir" -maxdepth 1 -type f -printf '%f\n' \ | maybe_shuffle } # Digital cameras were not commercially available before the 1990s, and a # long tail of camera bodies -- including the Fujifilm X100V that motivated # this constant -- silently default their clock to "2000-01-01" (or similar) # once its battery dies, then stamp every EXIF timestamp with that bogus date # instead of omitting it. An EXIF year below this is therefore treated as # unusable rather than real, so a whole clock-reset camera roll does not sort # to the very front of an otherwise correctly-dated album (see # chronological_sort_key_for_photo). readonly CHRONOLOGICAL_MIN_PLAUSIBLE_YEAR=2001 # Build the sort key chronological_photo_files uses to order one photo: a # tab-separated "\t