--- scripts/pgallery/src/pgallery.sh 2012/08/28 08:27:25 1.3 +++ scripts/pgallery/src/pgallery.sh 2012/08/28 12:30:30 1.6 @@ -5,7 +5,7 @@ # can do whatever you want with this stuff. If we meet some day, and you think # this stuff is worth it, you can buy me a beer in return Aron Schlesinger # -# $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.2 2012/08/28 08:15:13 as Exp $ +# $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.5 2012/08/28 10:44:41 as Exp $ # ARG_TITLE="PGallery" @@ -19,13 +19,18 @@ ARG_INDEX="index.html" ARG_DIR="." ARG_UPDATE=1 ARG_COPYRIGHT="© $(date +%Y)" +ARG_INFOFILE="" +ARG_MAILTO="" +ARG_MAILFROM="PGallery <${USER}@${HOST}>" +ARG_URL= BIN_CONVERT="/usr/local/bin/convert" BIN_EXIFAUTOTRAN="/usr/local/bin/exifautotran" BIN_IMGINFO="/usr/local/bin/imginfo" +BIN_SENDMAIL="/usr/sbin/sendmail" MKAKEFILE=".htmakefile" -VERSION="pgallery-1" +VERSION="pgallery-1.1" # # usage() @@ -35,8 +40,9 @@ usage() cat <] | [-s ] ) [-d ] [-n ] [-t ] [-u ] - [-b ] [-c ] - [-i ] [-U] | -h + [-b ] [-c ] [-l link] + [-i ] [-C ] [-F ] [-T ] + [-U] | -h | -v Options: -b size size from big images in pixel (default: $ARG_BIGSIZE) -c quality quality from big images 0-100% (default: $ARG_BIGQALITY) @@ -44,16 +50,23 @@ Options: -f files gallery images -h this page -i name index file name (default: $ARG_INDEX) + -l url gallery link -n name page title (default: $ARG_TITLE) -s suffix list of suffix. if no \`\`-f'' defined, used to find images in \`\`-d'' directoy. case insensitive (default: $ARG_FILETYPES) -t size size from thumbnail images in pixel (default: $ARG_TNSIZE) -u quality quality from thumbnail images 0-100% (default: $ARG_BIGQALITY) + -v print version + -C copyright copyright (html) string (default: $ARG_COPYRIGHT) + -F from mail sender (default: $ARG_MAILFROM) + -I file info text file for pgallery. info file paras prefered. + the syntax of the file is MAKE(1) + supported variable: TITLE COPYRIGHT INDEX FILETYPES TNSIZE URL + TNQALITY BIGSIZE BIGQALITY MAILTO MAILFROM + -T mailto send update infos to this address. if not set, no mail delivery -U no update, new calculation of all images. normally only new and modified images will calculated - -C copyright copyright (html) string (default: $ARG_COPYRIGHT) - -v print version USAGE exit } @@ -162,6 +175,7 @@ div.tn, div.big { border-color: gray; box-shadow: 1px 1px 2px #000; padding: 1px; + border-radius: 3px; } div.tn:hover { background-color: #222; @@ -369,7 +383,25 @@ err() exit 1 } +# +# mysendmail() +# +mysendmail() +{ + subject=$1 + ( + cat < $MKAKEFILE +targets="" +for file in $FLIST +do + tn="${file}.tn.jpg" + if [ ! -f $tn ] + then + FLIST_NEW="$FLIST_NEW $file" + continue + fi + + targets="$targets $tn" + ( + cat <> $MKAKEFILE +done +echo "tns: $targets" >> $MKAKEFILE +FLIST_UPDATE=$(make -f $MKAKEFILE) +rm $MKAKEFILE + +# update and no new and update images found +if [ $ARG_UPDATE -eq 1 -a "$FLIST_NEW" = "" -a "$FLIST_UPDATE" = "" ] +then + echo nothing to do + exit 1 +fi + +if [ $ARG_UPDATE -eq 1 ] +then + echo new images: $FLIST_NEW + echo update images: $FLIST_UPDATE +fi + # Create make file to rotate und convert all big and thumbnails. # Is needed to define the new real image sizes. echo "all: tns" > $MKAKEFILE @@ -475,7 +566,7 @@ do fi ( - cat <$ARG_TITLE $ARG_COPYRIGHT" html_footer ) > $ARG_INDEX + + +test "$ARG_MAILTO" = "" && exit 0 + +# send info mail +if [ "$FLIST_NEW" != "" -o "$FLIST_UPDATE" != "" ] +then + echo "send mail to $ARG_MAILTO" + ( + echo "Hallo," + echo + echo -n "the gallery $ARG_TITLE has been updated" + if [ "$ARG_URL" != "" ] + then + echo ":" + echo $ARG_URL + else + echo "." + fi + + suffix= + test "$ARG_URL" != "" && suffix=.html + + if [ "$FLIST_NEW" != "" ] + then + echo + echo "add pictures:" + for file in $FLIST_NEW + do + echo "- ${ARG_URL}${file}${suffix}" + done + fi + + if [ "$FLIST_UPDATE" != "" ] + then + echo + echo "update pictures:" + for file in $FLIST_UPDATE + do + echo "- ${ARG_URL}${file}${suffix}" + done + fi + ) | mysendmail "PGallery Update: $ARG_TITLE" +fi