#===================================================================
# Generate trnpix galleries locally, but do not upload them.
# Run this script in its own folder, with 'bash _generate.sh'.
#
# This Unix Bash script is demo only: it requires a common.sh (not
# included), and either Cygwin, WSL, or DOS translation on Windows.
#
# As of May 2022, this makes 3 cross-linked variants of the index
# page: fixed and dynamic layout, and dynamic + thumbs-only mode.
# The subfolders made for all 3 are identical, except that their
# viewer-pages' Index buttons link to the index which opens them.
#
# Besides direct use, this is also run:
#
# - As a subscript from this folder's _publish.py, prior to
# automatic uploads.
#
# - By thumbspage's examples/trnpix, to ensure that trnpix results
# it copies are ~current (but examples/dynamiclayout does not).
#
#---------------------------------------------------------------------
#
# UPDATE: in 2.3, this now also builds a second index page for the
# gallery, with thumbspage (TP) dynamic-index layout to avoid all
# horizontal scrolling on mobile devices (i.e., candy-bar phones).
# Open its index-dynamic.html to view the alternative index page.
# A link to the other index is added to both indexes automatically.
#
# Details: as coded, the dynamic-alternative build creates a second
# index page, but also remakes both thumbnails and viewer pages in a
# second folder. It's possible to instead reuse a single and shared
# thumbs+viewers folder and skip thumbnail rebuilds (by simply using
# the default folder name in the second build below). But a second
# folder allows thumbs size to vary if desired (e.g., smaller for
# mobile), and also ensures that each variant's viewer pages return
# to their own index page on Index button taps. This also replaces
# a _HEADER.html tag to make HEADER.html twice, for preamble links.
#
# Discussion: 2.3's new .5 'em' dynamic-layout scheme packs labels
# tighter, so the new dynamic variant now renders as more than one
# column on larger phones. It's still not the index.html default,
# because it can leave some extra empty space on the right for some
# window sizes on desktop, and this website's traffic is 71% desktop
# over the last year (and probably higher, given analytics disabling).
#
# Moreover, fixed layout may be preferred for the 26% mobile-browser
# audience too. Fixed requires minor horizontal scrolling in portrait
# on mobile, but not once a user is inside the gallery. And smaller
# phones may still display just one column of thumbnails in dynamic
# layout, which makes for a lot more vertical scrolling in this > 100
# image gallery; dynamic largely trades hscrolls for vscrolls.
#
# OTOH, most full-size photos are larger in portrait, so rotating
# to landscape to reduce hscrolls isn't a good workaround for mobile.
# The real issue here is that most mobiles' form factors make them
# inherently subpar for viewing nontrivial content; see foldables.
#
#---------------------------------------------------------------------
#
# UPDATE: this script was augmented after TP's 2.3 May release to
# also build a third thumbs-only variant: index-thumbsonly.html. This
# mode isn't as useful for this gallery, despite its per-image notes:
# filenames are descriptive and, with > 100 images, helpful.
#
#---------------------------------------------------------------------
#
# UPDATE: changed popupFgColor from 'tan' to 'wheat' in Oct-2022.
# It's still less harsh than white (or goldenrod or cornsilk), but
# a bit brighter than tan (and #ddd or its ilk). Colors are hard.
#
#---------------------------------------------------------------------
#
# UPDATE: now uses thumbspage 3.0, so some of the name=value arguments
# here are optional. 3.0's preset index mode is now dynamic (which
# proved better in practice across a range of devices), and most of
# the dynamic build's former arguments here are now preset defaults.
# Fixed is now just an outlier demo here, and thumbs-only is dynamic.
#
# Because this script uses explicit configs via command-line arguments
# instead of relying on console inputs or config-file presets, no mods
# were required here to build with 3.0. This is suggested practice.
# Console inputs could be dropped, but they're a legacy convenience.
#
#=====================================================================
# Common defs and aliases (yours will vary)
source ~/MY-STUFF/Websites/_admin/BUILD-THUMBSPAGE-CLIENTS/common.sh
#---------------------------------------------------------------------
# 1) Default index page: fixed layout ([3.0] now an option)
# Makes thumbs, viewer pages, and default index.html + _thumbspage/
#---------------------------------------------------------------------
# Replace header tag
note='dynamic-layout flavor \
avoids horizontal scrolls and its \
thumbs-only cut omits labels'
py3 -c \
"open('HEADER.html', 'w', encoding='utf8').write( \
open('_HEADER.html', 'r', encoding='utf8').read().replace('\$ALTPAGE\$', '$note'))"
# Build gallery
py3 $C/thumbspage/thumbspage.py . \
useDynamicIndexLayout=False \
omitIndexPageLabels=False \
inputThumbsPerRow=4 \
inputThumbMaxSize=100 \
inputCleanThumbsFolder=True \
inputUseViewerPages=True
#---------------------------------------------------------------------
# 2) Alternative index page: dynamic layout ([3.0] now preset default)
# Makes new thumbs and viewer pages, and unique index-dynamic.html
#---------------------------------------------------------------------
# Replace header tag
note='fixed-layout flavor \
expands to fill space and its \
thumbs-only cut omits labels'
py3 -c \
"open('HEADER.html', 'w', encoding='utf8').write( \
open('_HEADER.html', 'r', encoding='utf8').read().replace('\$ALTPAGE\$', '$note'))"
# Build gallery
py3 $C/thumbspage/thumbspage.py . \
INDEX=\'index-dynamic\' \
THUMBS=\'_thumbspage-dynamic\' \
useDynamicIndexLayout=True \
omitIndexPageLabels=False \
dynamicLayoutPaddingH=\'6px\' \
dynamicLayoutPaddingV=\'6px\' \
inputThumbMaxSize=100 \
inputCleanThumbsFolder=True \
inputUseViewerPages=True
#---------------------------------------------------------------------
# 3) Alternative index page: thumbs-only mode (+ dynamic layout)
# Makes new thumbs and viewer pages, and unique index-thumbsonly.html
#---------------------------------------------------------------------
# Replace header tag
note='fixed-layout flavor \
expands to fill space and its \
dynamic-layout cut \
avoids horizontal scrolls'
py3 -c \
"open('HEADER.html', 'w', encoding='utf8').write( \
open('_HEADER.html', 'r', encoding='utf8').read().replace('\$ALTPAGE\$', '$note'))"
# Build gallery
py3 $C/thumbspage/thumbspage.py . \
INDEX=\'index-thumbsonly\' \
THUMBS=\'_thumbspage-thumbsonly\' \
useDynamicIndexLayout=True \
omitIndexPageLabels=True \
dynamicLayoutPaddingH=\'16px\' \
dynamicLayoutPaddingV=\'16px\' \
inputThumbMaxSize=100 \
inputCleanThumbsFolder=True \
inputUseViewerPages=True
#---------------------------------------------------------------------
# Prior build-command form (doc only)
# No longer required if use input*=value command-line arguments
#---------------------------------------------------------------------
## Old style build: use bash "here" document for console inputs.
## Uses all defaults except muted white popup text (#dddddd == #ddd).
##
## [3.0] Explicit cmd args are better: inputs may and do change over time
## (in fact, there is now one less input here for default dynamic layout).
##
## py3 $C/thumbspage/thumbspage.py . popupFgColor=\'#dddddd\' <<-EOF
##
##
##
## EOF