#===================================================================
# Automatically build+publish this folder's content, only.
#
# Launch this script from Terminal in its own folder, with:
#     cd $C/mergeall/mergeall-android-scripts
#     bash _publish.sh
#
# Also run by $W/_admin/BUILD-THUMBSPAGE-CLIENTS/_PUBLISH.sh, to 
# update all thumbspage external clients in a single step.
#===================================================================

# get common defs
source ~/MY-STUFF/Websites/_admin/BUILD-THUMBSPAGE-CLIENTS/common.sh

galleries='. EXFAT-BUG PYDROID3-TKINTER EXFAT-BUG/FIXED-IN-ANDROID-10'

for gallery in $galleries; do
    py3 $C/thumbspage/thumbspage.py _readme-items/$gallery <<-EOF
	
	3
	
	
	EOF
done

cd $C/mergeall
py3 $Z/zip-create.py mergeall-android-scripts.zip mergeall-android-scripts \
        -skipcruft | tail -n 20

pubdir=$W/Programs/Current/Complete
rm -rf $pubdir/mergeall-android-scripts
cp -p  mergeall-android-scripts.zip $pubdir
cp -Rp mergeall-android-scripts $pubdir
mv mergeall-android-scripts.zip _private_/mergeall-android-scripts--${stamp}.zip

cd $pubdir/mergeall-android-scripts
py3 $M/insert-analytics.py _README.html
for gallery in $galleries; do
    py3 $M/insert-analytics.py _readme-items/$gallery/index.html
done

cd $W
py3 _PUBLISH.py | tail -n 20

cd UNION
SCP mergeall-android-scripts.zip htdocs
SSH <<-EOF
	cd htdocs
	rm -rf mergeall-android-scripts
	unzip -d . mergeall-android-scripts.zip
	exit
	EOF

# replace unzipped analytics parts (improve me?)
cd mergeall-android-scripts
SCP _README.html htdocs/mergeall-android-scripts
for gallery in $galleries; do
    SCP _readme-items/$gallery/index.html \
        htdocs/mergeall-android-scripts/_readme-items/$gallery
done

# keeps .zip both on server and local (survives site _PUBLISH)
