File: trnpix/_publish.sh

#===================================================================
# Automatically build+publish this folder's content, only.
# This gallery has 118 images and 86 notes at last count (dec22).
#
# This Unix Bash script is demo only: it requires a common.sh (not
# included), and on Windows either Cygwin, WSL, or DOS translation.
#
# CAUTION: requires Python 3.8 on dev host today (~.bash_profile).
#
# Launch this script from Terminal in its own folder, with:
#     cd $W/Posts/Current/Complete/trnpix
#     bash _publish.sh
#
# Also run by $W/_admin/BUILD-THUMBSPAGE-CLIENTS/_PUBLISH.sh, to 
# update all thumbspage (TP) external clients in a single step.
#
# See also: 
#   ./_generate.sh runs the thumbspage commands used to build 
#   this folder's 3 galleries, with alternative index layouts.
# 
#   TP's docetc/batchnotes.py collects .note files for spellchecks;
#   it's auto-run here, as it's referenced as a demo in TP docs.
#
#   TP's build/insert-analytics.py adds analytics JS code to HTML 
#   pages, after generation and before zip+upload. 
#
#-------------------------------------------------------------------
# Recent updates, latest last:
#
# - TP 2.3 allows console inputs to be provided with command 
#   args, instead of <<-EOF; see the new build command(s).
#
# - TP 2.3 allows popups' colors to deviate from the viewer-page
#   defaults; e.g., popupFgColor=\'#ddddd\' selects muted-white text.
#
# - The TP build command is now split off to subscript _generate.sh, 
#   for both local testing sans uploads, and TP's examples/trnpix.
#
# - Now publishes 2 alternative index pages with crosslinks:
#   fixed and dynamic layout.  See _generate.sh for the builds.
#
# - Now publishes a 3rd index-page variant: thumbs-only mode;
#   website links now prefer dynamic over both fixed and this.
#
# - tan => wheat for popups fg text; tan seems generally too 
#   dark, though this can vary per display, setting, and user.
# 
# - _HEADER: hardcoded UA analytics tag/code => replacement key,
#   so picks up GA4.  FOOTER: new, shorter link words from site.
#
# - As a temporary experiment, add analytics to all trnpix image
#   viewer pages (not just indexes); TP emits replacement keys.
#
# - thumbspage/examples/trnpix/_generate.sh runs _generate.sh here
#   but not _publish.sh here, which results in .html files without
#   analytics in $W/UNION, enen though they have analytics at live 
#   site; must rerun this _publish.sh after a thumbspage publish. 
# 
# - dec23: moved analytics tag below </head> in _HEADER.html; else
#   <title> may be missed, causing "(not set)" page titles in ga4 
#   reports (though timing dependent, and page-path reports fine).
#   the same should be done for viewer pages, but it's a tp mod.
#
#===================================================================


# common defs, aliases, scp/ssh functions with keys
source ~/MY-STUFF/Websites/_admin/BUILD-THUMBSPAGE-CLIENTS/common.sh

# save zip to $C/thumbspage/_private?
SaveInTP=y

# run note batcher in '.': it's a thumbspage 2.3 demo
py3 $C/thumbspage/docetc/batchnotes.py


#-----------------------------------------------------------------
# GALLERY: build gallery, add analytics, build website image
#-----------------------------------------------------------------

# see this folder's _generate.sh for the current build command(s)

# run new-style gallery builds, now in a subscript
bash _generate.sh

# add index analytics, no longer hardcoded in _HEADER used by all
indexpages='index.html index-dynamic.html index-thumbsonly.html'
for indexpage in $indexpages; do
    py3 $M/insert-analytics.py $indexpage
done

# add analytics to viewer pages too, temporarily (dec22)
for viewpage in $(find . -path './_thumbspage*/*.html' -print); do
    py3 $M/insert-analytics.py $viewpage
done

# copy .htaccess for nicer views of subfolders directly (mar22)
subfolders='_thumbspage _thumbspage-dynamic _thumbspage-thumbsonly'
for subfolder in $subfolders; do
    cp -p _htaccess $subfolder/.htaccess
done

# build local website image
cd $W
py3 _PUBLISH.py | tail -n 20


#-----------------------------------------------------------------
# UPLOAD: zip by ziptools, upload zip by scp, unzip at site by ssh
#-----------------------------------------------------------------

# zip
cd UNION
py3 $Z/zip-create.py trnpix.zip trnpix -skipcruft | tail -n 20

# upload
SCP trnpix.zip htdocs

# unzip
SSH <<-EOF
	cd htdocs
	rm -rf trnpix
	unzip -d . trnpix.zip
	rm trnpix.zip
	exit 
	EOF

# save
if [ $SaveInTP == 'y' ]
then
    mv trnpix.zip $C/thumbspage/_private/trnpix--$stamp.zip
else
    rm trnpix.zip
fi



[Home page] Books Code Blog Python Author Train Find ©M.Lutz