+function generate_pages() {
+ $ECHOCOMMAND "Generating Pages"
+ previouspage=""
+ currentpage=""
+ nextpage=""
+ previousimage=""
+ currentimage=""
+ nextimage=""
+
+ $FINDCOMMAND . $FINDIMAGESOPTIONS | \
+ $XARGSCOMMAND -0 --replace $ECHOCOMMAND {} | \
+ $SORTCOMMAND -g | \
+ while read imagefilename; do
+ previousimage=$currentimage
+ currentimage=$nextimage
+ nextimage=$imagefilename
+ previouspage=$currentpage
+ currentpage=$nextpage
+ nextpage=${imagefilename}.html
+ filename=${currentimage}
+ generate_general_page "$previouspage" "$currentpage" "$nextpage"
+ echo $nextimage
+ done | tail -n 2 | (
+ read previouspage
+ read currentpage
+ filename=${currentpage}
+ currentpage=${currentpage}.html
+ previouspage=${previouspage}.html
+ nextpage=""
+ generate_general_page "$previouspage" "$currentpage" ""
+ )
+}
+
+
+
+function generate_general_page() {
+
+ if [[ -z $1 ]]; then
+ previouspage=""
+ fi
+
+ if [[ -z $2 ]]; then
+ currentpage=""
+ return
+ fi
+
+ if [[ -z $3 ]]; then
+ nextpage=""
+ fi
+
+ if [ -r captions.txt ]; then
+ caption=$($GREPCOMMAND -E "^${filename} " captions.txt); caption=${caption#* }
+ else
+ caption=""
+ fi
+
+ $BPGALLERY_PAGE_FUNCTION > $currentpage
+}
+
+if [[ $OUTPUTHTML != 0 ]]; then
+ $ECHOCOMMAND "<pre>"
+fi
+