X-Git-Url: https://git.sommitrealweird.co.uk/bpgallery.git/blobdiff_plain/4e9ad17280e911da8026f21269285aed622de238..c757ab6dcdf959f0bb5fcf5fe23c7e94a4c6b819:/bpgallery.sh diff --git a/bpgallery.sh b/bpgallery.sh index f6fdfed..e6c6f9f 100755 --- a/bpgallery.sh +++ b/bpgallery.sh @@ -52,7 +52,7 @@ else caption_alt=$caption fi cat << END -
+ END } @@ -70,18 +70,18 @@ declare -rf bpgallery_default_tail function bpgallery_default_stylesheet() { cat <"
+fi
+
if [[ -z $1 ]]; then
$ECHOCOMMAND "No path given"
usage
@@ -321,12 +451,36 @@ if ( ! $FINDCOMMAND . $FINDIMAGESOPTIONS > /dev/null 2>/dev/null ); then
exit 4
fi
+if [ ! -w . ]; then
+ $ECHOCOMMAND "Can't write to images directory, exiting"
+ exit 8
+fi
+
+if [ -e index.html ] && [ ! -w index.html ]; then
+ $ECHOCOMMAND "Can't write index.html, exiting"
+ exit 8
+fi
+
+if [ -e style.css ] && [ ! -w style.css ]; then
+ $ECHOCOMMAND "Can't write style.css, exiting"
+ exit 8
+fi
+
if [ ! -d icons ]; then
mkdir icons
fi
+if [ ! -w icons ]; then
+ $ECHOCOMMAND "Can't write to icons directory, exiting"
+ exit 16
+fi
+
generate_thumbs
+if [ $GENERATEPAGESFORFULLSIZE != 0 ]; then
+ generate_pages
+fi
+
if [ -r description.txt ] ; then
DESCRIPTION=$($SEDCOMMAND -e '1 { s/^//; }; /^$/ { s,$,
,; }; $ { s,$,
, };' description.txt)
else
@@ -334,13 +488,19 @@ else
fi
+$ECHOCOMMAND "Starting to generate page"
+
$BPGALLERY_HEAD_FUNCTION > index.html
$BPGALLERY_DESCRIPTION_FUNCTION >> index.html
-$FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 --replace $ECHOCOMMAND {} |$SORTCOMMAND -g | while read filename; do filename=${filename#./}; if [ -r captions.txt ]; then caption=$($GREPCOMMAND -E "^$filename " captions.txt); caption=${caption#* }; else caption=""; fi; filename=$(bpgallery_escape_url "$filename"); $BPGALLERY_THUMBSLINE_FUNCTION; done >> index.html
+$ECHOCOMMAND "Adding Captions"
+
+$FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 --replace $ECHOCOMMAND {} |$SORTCOMMAND -g | while read filename; do filename=${filename#./}; if [ -r captions.txt ]; then caption=$($GREPCOMMAND -E "^$filename " captions.txt); caption=${caption#* }; else caption=""; fi; if [ $GENERATEPAGESFORFULLSIZE != 0 ]; then link=$(bpgallery_escape_url "${filename}.html"); else link=$(bpgallery_escape_url "$filename"); fi; filename=$(bpgallery_escape_url "$filename"); $BPGALLERY_THUMBSLINE_FUNCTION; done >> index.html
$BPGALLERY_TAIL_FUNCTION >> index.html
+$ECHOCOMMAND "Finished generating the page"
+$ECHOCOMMAND "Generating stylesheet"
cd icons
MAXHEIGHT=$($FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 $IDENTIFYCOMMAND -format "%h\n" | $GREPCOMMAND -v "^$" | $SORTCOMMAND -g -r | $HEADCOMMAND -n 1)
@@ -353,3 +513,8 @@ MAXHEIGHT=$((MAXHEIGHT+$CAPTIONHEIGHT))
$BPGALLERY_STYLESHEET_FUNCTION > style.css
+$ECHOCOMMAND "All done"
+
+if [[ $OUTPUTHTML != 0 ]]; then
+ $ECHOCOMMAND ""
+fi