--- scripts/pgallery/src/pgallery.sh 2012/08/31 14:26:58 1.19 +++ scripts/pgallery/src/pgallery.sh 2017/12/07 14:24:00 1.28 @@ -1,14 +1,16 @@ -#!/bin/sh +#!/usr/local/libexec/pgallerysh # -# THE BEER-WARE LICENSE 2012 +# THE BEER-WARE LICENSE 2012,13 +# # wrote this file. As long as you retain this notice you # 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.18 2012/08/31 12:33:07 as Exp $ +# $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.27 2013/04/03 08:14:52 as Exp $ # -. $(dirname $0)/libpgallery +. /usr/local/libexec/libpgallery + ARG_TITLE="PGallery" ARG_FILES= ARG_FILETYPES="jpg jpeg png gif tif tiff" @@ -26,8 +28,11 @@ ARG_MAILFROM="PGallery <${USER}@${HOST}>" ARG_URL= ARG_EXIF="0x920a 0x829d 0x829a ISO 0x8827 / 0x010f - 0x0110" ARG_INDEXIMG= +ARG_NOINDEX= ARG_STARTTS= ARG_ENDTS= +ARG_LINK= +ARG_NAVI=0 MKAKEFILE=".htmakefile" @@ -38,10 +43,10 @@ usage() { cat <] | [-s ] ) [-d ] [-n ] - [-t ] [-u ] + [-t ] [-u ] [-H ] [-b ] [-c ] [-l link] [-e ] [-i ] [-C ] [-F ] [-T ] - [-U] | -h | -v + [-U] [-w] | -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) @@ -51,6 +56,7 @@ Options: -f files gallery images -h this page -i name index file name (default: $ARG_INDEX) + -x ignore gallery on index -l url gallery link -m image image for pgalleryindex. default the first image -n name page title (default: $ARG_TITLE) @@ -60,13 +66,15 @@ Options: -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 + -w enable navi width link in the overview -C copyright copyright (html) string (default: $ARG_COPYRIGHT) -F from mail sender (default: $ARG_MAILFROM) + -L link optional home link -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 - EXIF INDEXIMG + EXIF INDEXIMG LINK NAVI NOINDEX -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 @@ -86,8 +94,6 @@ do test $arg = -d && is_dir=1 done -echo $ARG_DIR - # load save args if [ -f "$ARG_DIR/$ARGFILE" ] then @@ -139,6 +145,9 @@ do -F) ARG_MAILFROM=$1 shift;; + -L) + ARG_LINK=$1 + shift;; -I) ARG_INFOFILE=$1 shift;; @@ -150,6 +159,10 @@ do -v) echo $VERSION exit;; + -w) + ARG_NAVI=1;; + -x) + ARG_NOINDEX=1;; *) echo "unknown argument $arg" exit @@ -165,7 +178,7 @@ if [ "$ARG_INFOFILE" != "" ] then test -f $ARG_INFOFILE || err "info file not found \`\`$ARG_INFOFILE''" for n in TITLE COPYRIGHT INDEX FILETYPES TNSIZE TNQALITY BIGSIZE \ - BIGQALITY MAILTO MAILFROM URL EXIF INDEXIMG + BIGQALITY MAILTO MAILFROM URL EXIF INDEXIMG NOINDEX LINK NAVI do v=$(make -f $ARG_INFOFILE -V$n) test "$v" = "" && continue @@ -173,11 +186,11 @@ then done fi -#paras from iso to utf-8 +# paras from iso to utf-8 for n in $(set | awk -F= '{print $1}') do echo "$n" | grep -q '^ARG_' || continue - eval "$n=\"\$(echo \"\$$n\" | iconv -f ISO-8859-1 -t UTF-8)\"" + eval "$n=\"\$(echo \"\$$n\" | $BIN_ICONV -f ISO-8859-1 -t UTF-8)\"" done # fix url @@ -200,12 +213,13 @@ else FLIST="$ARG_FILES" fi -# Filter big and thumbnails +# Filter big, thumbnails and curipted images echo -n "find images" FLISTF= for file in $FLIST do test $(echo $file | grep -E '\.(tn|big)\.jpg$') && continue + test $($BIN_JPEGINFO $file | grep -Eq 'WARNING|ERROR') && continue FLISTF="$FLISTF $file" echo -n " $file" done @@ -229,6 +243,11 @@ test "$ARG_INDEXIMG" = "" && ARG_INDEXIMG=$(echo $FLIS # find start and end ts ARG_STARTTS=$(get_exif_ts $(echo $FLIST | awk '{print $1}')) +# XXX: +if [ "$ARG_STARTTS" = "-1" ] +then + ARG_STARTTS=$(get_exif_ts $(echo $FLIST | awk '{print $2}')) +fi ARG_ENDTS=$(get_exif_ts $(echo $FLIST | awk '{print $NF}')) # find new and to update images @@ -263,6 +282,7 @@ echo "save settings" set | while read n do echo "$n" | grep -q '^ARG_' || continue + echo "$n" | grep -q '^ARG_UPDATE' && continue echo "$n" >> $ARGFILE done @@ -308,13 +328,14 @@ MAKE done echo "tns: $targets" >> $MKAKEFILE -#make -f $MKAKEFILE +make -f $MKAKEFILE rm $MKAKEFILE # create html index echo create html index ( html_header + startdate= test $ARG_STARTTS -ne -1 && startdate=$(date -r $ARG_STARTTS "+%d.%m.%Y") enddate= @@ -322,8 +343,10 @@ echo create html index date= test "$startdate" != "" && date="$startdate" test "$enddate" != "$startdate" && date="$date - $enddate" + link= + test "$ARG_LINK" != "" && link="overview" + html_title "$ARG_TITLE" "$link" "$date" - html_title "$ARG_TITLE" "$date" for file in $FLIST do tn="${file}.tn.jpg"