Diff for /scripts/pgallery/src/pgallery.sh between versions 1.5 and 1.23

version 1.5, 2012/08/28 10:44:41 version 1.23, 2012/09/11 16:24:46
Line 1 Line 1
#!/bin/sh#!/home/as/sh
 #  #
 # THE BEER-WARE LICENSE 2012  # THE BEER-WARE LICENSE 2012
 # <as@paefchen.net> wrote this file. As long as you retain this notice you  # <as@paefchen.net> 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  # 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  # this stuff is worth it, you can buy me a beer in return Aron Schlesinger
 #  #
# $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.4 2012/08/28 08:43:05 as Exp $# $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.22 2012/09/11 15:40:43 as Exp $
 #  #
   . $(dirname $0)/libpgallery
   
 ARG_TITLE="PGallery"  ARG_TITLE="PGallery"
 ARG_FILES=  ARG_FILES=
Line 19  ARG_INDEX="index.html" Line 20  ARG_INDEX="index.html"
 ARG_DIR="."  ARG_DIR="."
 ARG_UPDATE=1  ARG_UPDATE=1
 ARG_COPYRIGHT="&copy; $(date +%Y)"  ARG_COPYRIGHT="&copy; $(date +%Y)"
ARG_INFOFILE="pgallery.txt"ARG_INFOFILE=""
 ARG_MAILTO=""
 ARG_MAILFROM="PGallery <${USER}@${HOST}>"
 ARG_URL=
 ARG_EXIF="0x920a 0x829d 0x829a ISO 0x8827 / 0x010f - 0x0110"
 ARG_INDEXIMG=
 ARG_STARTTS=
 ARG_ENDTS=
 ARG_LINK=
 ARG_NAVI=0
   
 BIN_CONVERT="/usr/local/bin/convert"  
 BIN_EXIFAUTOTRAN="/usr/local/bin/exifautotran"  
 BIN_IMGINFO="/usr/local/bin/imginfo"  
   
 MKAKEFILE=".htmakefile"  MKAKEFILE=".htmakefile"
 VERSION="pgallery-1.1"  
   
 #  #
 # usage()  # usage()
Line 35  usage() Line 40  usage()
 {  {
         cat <<USAGE          cat <<USAGE
 usage $0: ( [-f <files>] | [-s <suffix>] ) [-d <dir>] [-n <name>]  usage $0: ( [-f <files>] | [-s <suffix>] ) [-d <dir>] [-n <name>]
                [-t <thumbnail_size>] [-u <thumbnail_quality>]                [-t <thumbnail_size>] [-u <thumbnail_quality>] [-H <link>]
                [-b <big_size>] [-c <big_quality>]                [-b <big_size>] [-c <big_quality>] [-l link] [-e <exif>]
                [-i <index>] [-C <copyright>] [-U] | -h | -v                [-i <index>] [-C <copyright>] [-F <mailfrom>] [-T <mailto>]
                 [-U] [-w] | -h | -v
 Options:  Options:
   -b size       size from big images in pixel (default: $ARG_BIGSIZE)    -b size       size from big images in pixel (default: $ARG_BIGSIZE)
   -c quality    quality from big images 0-100% (default: $ARG_BIGQALITY)    -c quality    quality from big images 0-100% (default: $ARG_BIGQALITY)
   -d dir        gallery dir (default: $ARG_DIR)    -d dir        gallery dir (default: $ARG_DIR)
     -e exif       list of tags in hex. (default: $ARG_EXIF)
                   see: http://www.exiv2.org/tags.html
   -f files      gallery images    -f files      gallery images
   -h            this page    -h            this page
   -i name       index file name (default: $ARG_INDEX)    -i name       index file name (default: $ARG_INDEX)
     -l url        gallery link
     -m image      image for pgalleryindex. default the first image
   -n name       page title (default: $ARG_TITLE)    -n name       page title (default: $ARG_TITLE)
   -s suffix     list of suffix. if no \`\`-f'' defined, used to find images    -s suffix     list of suffix. if no \`\`-f'' defined, used to find images
                 in \`\`-d'' directoy. case insensitive                  in \`\`-d'' directoy. case insensitive
Line 52  Options: Line 62  Options:
   -t size       size from thumbnail images in pixel (default: $ARG_TNSIZE)    -t size       size from thumbnail images in pixel (default: $ARG_TNSIZE)
   -u quality    quality from thumbnail images 0-100% (default: $ARG_BIGQALITY)    -u quality    quality from thumbnail images 0-100% (default: $ARG_BIGQALITY)
   -v            print version    -v            print version
     -w            enable navi width link in the overview
   -C copyright  copyright (html) string (default: $ARG_COPYRIGHT)    -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.    -I file       info text file for pgallery. info file paras prefered.
                 the syntax of the file is MAKE(1)                  the syntax of the file is MAKE(1)
                supported variable: TITLE COPYRIGHT INDEX FILETYPES TNSIZE                supported variable: TITLE COPYRIGHT INDEX FILETYPES TNSIZE URL
                                    TNQALITY BIGSIZE BIGQALITY                                    TNQALITY BIGSIZE BIGQALITY MAILTO MAILFROM
                                     EXIF INDEXIMG LINK NAVI
   -T mailto     send update infos to this address. if not set, no mail delivery
   -U            no update, new calculation of all images.    -U            no update, new calculation of all images.
                 normally only new and modified images will calculated                  normally only new and modified images will calculated
 USAGE  USAGE
         exit          exit
 }  }
   
## first find image dir
# get_my_path()is_dir=0
#for arg in $*
get_my_path()do
{        if [ $is_dir -eq 1 ]
        current=$(pwd) 
        cd $(dirname $0) 
        echo $(pwd)/$(basename $0) 
        cd "$current" 
} 
 
# 
# html_header() 
# 
html_header() 
{ 
        cat <<HTML 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
        <title>$ARG_TITLE</title> 
                <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> 
                <style type="text/css"> 
                <!-- 
body { 
        background-color: #464646; 
        background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYB\ 
AMAAACDuy0HAAAAG1BMVEX+/v4BAQH///8KCgoDAwN/f3/19fWAgID8/PzhDwT2AAAACXRSTlMFBQUFBQU\ 
FBQWHDtP9AAALwklEQVR4Xg3KOWOyWhAA0Bn2ci57eXEvQY1JCZp8sQTjVoJLTAkaE0swbj/7ve4UB37FL\ 
W4q86Lwwlh86J/ASAkpWaj+Krbb31HzH0Kjc2tIl7SADaWbpZBPE5dds6jJNyNdjAyKWqdroIixWRQIY6E\ 
/kOY7hIciL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xbEBPyQzXi+Bb4kc9wK4jIwNLWbwQAOtYKRLaipD\ 
H+X4TPPOG8DCNY4IC9yBk1qcibjhUgRnDcf35pl9d5otbvQjOIXlEu5dVtm5LRaK5KWcD/PX6LaGd25CuN\ 
HG/vgeIB1kcpCme+J8idlcjfBALAJSggznsGHGOAJgdGduMnZg+bAaeGASGV9bh/X2wPsVTmBLxmTTQsBG\ 
FkEOkZJTsGAm+HrtMDbWwvTXOutX1u7BxIq9Xib6DkFMbUitNdrYsULkahsAhBEh9FjdzL9BNARxTSr7T3\ 
u1rE+IWUmCIpwTZHZCu5l9THCuCcOhZqfekuQxjQ7EoyGUJAwCv/q1JOuJeCc/3lknb76zAquO/DAQhK/6\ 
2cP8X2s3+IBLIhvL8RHopoHpIArJysYTTmMMeubPXh8W760AvMVH67jqgg06+/ne5MZ631z6yROhloh3dP\ 
QirZoEpr80wgt/cEbhbAQTmRLtGh8lxCwDBBb5OeJ4aEq25XBNMT2rzWedW2zIzj+CCDKlnlyJBzT81qBW\ 
p69h7vlb3TmEV+DNm2rqj1iT7BQuwVVsuPkwq1e5P8tgNjVbIlMzwXeM11kZqjx3KKFOJzc3CAyFVhi8fx\ 
VZ5FvhdAM5mM6kS6OgKu16MFglq3/b/QVIwdw7HUCyeW04JPjC5dO+GC9OfqfB4VX+wwuift+ths2Ss3i6\ 
nkOE+JFyD+wKFL+WMX6nwwDva0S1/O8Mlnida69Ph96fuFvCoRMvXnCfsLPPmC/hA5RnMNE4fDK0pVOQ4B\ 
HLaErzv/wD99ABmjNZk0AAAAABJRU5ErkJggg=="); 
        margin: 10px auto; 
        font-family: Geneva,Arial,sans-serif; 
        font-size: 12px; 
        text-shadow: 1px 1px 1px #000; 
} 
div.tn { 
        float: left; 
        width: ${ARG_TNSIZE}px; 
        height: ${ARG_TNSIZE}px; 
        vertical-align:text-top; 
        text-align: center; 
        margin: 4px; 
} 
div.tn a { 
        position: relative; 
        display: inline-block; 
        height: ${ARG_TNSIZE}px; 
} 
div.tn, div.big { 
        background-color: black; 
        border-width: 1px; 
        border-style: solid; 
        border-color: gray; 
        box-shadow: 1px 1px 2px #000; 
        padding: 1px; 
        border-radius: 3px; 
} 
div.tn:hover { 
        background-color: #222; 
} 
div.big { 
        display: inline-block; 
        width: ${ARG_BIGSIZE}px; 
} 
div.over { 
        width: ${ARG_BIGSIZE}px; 
        position: absolute; 
        top: 30px; 
        padding: 1px; 
} 
div.over a.left, div.over a.right { 
        display: block; 
        /* shell fuck of: missing CTLARI (shouldn't happen) - WTF?! */ 
        width: $(($ARG_BIGSIZE / 2))px; 
        position: relative; 
        top: 1px; 
        left: 1px; 
        background-repeat: no-repeat; 
} 
div.over a.left:hover { 
        background-position: 5% center; 
        background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\ 
AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAh9JREFUeNrE2L1Lw0A\ 
UAHATSivSZii0ldpBnMU6SgYJpQUJDlk7dLV+LTqIiIv4B7kLolBKQRA6GLqUDMEhqKAlhUIR4125SHo0b\ 
XJ51x68pDSX+3G5I/dyguM4S/MuMfeHIAiQ7Yo+//+OocAYPm+jWEXxg8JC8erCgvt4AXrqgkkUJRRZ6jq\ 
G71EMRcAeil6wWq2uGYZx1ul0jjRNy5Jey6PauKcRJ5NIhklCoaE4QODNYDCwHVJ6vd5HIpE4xNdQxKOiM\ 
0G3FIvFc4Imo6CBQV3XXwioje5jREOBkiQdE3SLFWUFFXJfaJQVLP2DIWdvFDA+9pYKiMKBAVFYMAAKD85\ 
A+YBTUH6gD8oXnIDyB31QviCFzgekUPxYVe4ghW7ixhRFueQKUmgZN9hut1s0aNv2V6FQOAUBqRvT+IAaX\ 
6crWZb1hsqQJFfPkPnpJz6YpmnQlXK5XD6TycRIcrUDib7jQ71ev+v3+9/eSqlUKt1qtU4IvIFid2x9jDC\ 
muJE9PG6qql7jcaTHttvt6gh2J1MZYva6ees+d9jnjcQXnoDyh31WGb7wlPWUHzwjc+ADB8iR4OGA2SAsH\ 
CLvhYNDZvgwMMO3THSY8auNBS6xfrVFhZUoaGjYk+qA7DkEgmu12i1Bs1C7K1NhvLviecTLEOhEuFKpXDW\ 
bzcdGo/Egy/KFZzKJPHbMVsiEyVPXTRRPeMdMWMQuqLi0gPInwACOBcZx3lRFMwAAAABJRU5ErkJggg=="); 
} 
div.over a.right:hover { 
        background-position: 95% center; 
        background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\ 
AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAiJJREFUeNrE2D1Lw0A\ 
YAOAmlNbBdii0FVM6OEu7SgcJpRUJDlk7dE21uuggIi7iD/IX+AGlFAXBDqVLyVCCBBW0JFhwMN7JHRxnY\ 
5PcnX3hhSM58nB3+Xhzkud5sf8OiWjLPn2+eGF4gHEChLkOcgUdt0E+isAlhCVAbiGQjGeQ1yBdHjAeKZ7\ 
SCgR1Xc8Nh8M90zQPG42GAo7lQFZBLhOzwSXgKI1kMrk7mUxePBTT6dQB8Dk8B1IHmUbTLrOMFI8WjsIol\ 
8tHHhW8YRKV0QWNwWDwIBKm0RK8aDqdbouEaRReQBUNkygJV0XCNBojnldh8CxUOOyHCoX/QoXB81AhcBC\ 
UOxwU5QqHQbnBYVFWODLKDEdFo8IanGYWNBSsquoJgkus6C+4UCgcOI7zRsP9fv8OoTWM8qh57mHlaFnWp\ 
23bFn1SUZQiambm1bphYgMWddlsNp7P51fpk+Px2ETNV1YUf383Qa5BsNfr7adSqQzZyXXd91ardUmUs8x\ 
rWYNrBcD2aDQa0GsJ11fTtDO0ntssd28UcAfXzSxvpLBg5DcSKyhH/cowgVG+p8xg2MqBCximRuIGBq0Gu\ 
YJB6l7u4LwKXwjo9y8jFPT7a6uKBGehqmiQRhO45BAJ0ijcQTGazeaFSJBGl/DUkrsrvMFZa/pzE1UqleN\ 
Op3PV7XZv6vX6KU+QRMkdM3gzFal+TyBvQX7w3DGTFrELKscWEN8CDADBm8pgcciwqgAAAABJRU5ErkJgg\ 
g==");  
} 
div.big a { 
        position: relative; 
        display: inline-block; 
        width: ${ARG_BIGSIZE}px; 
} 
div.box { 
        text-align: center; 
        width: ${ARG_BIGSIZE}px; 
        margin: auto; 
} 
div.box div.c { 
        width: ${ARG_BIGSIZE}px; 
        text-align: right; 
        font-size: 90%; 
        color: #808080; 
        height: 25px; 
        line-height: 25px; 
        position: relative; 
        left: 4px; 
} 
body > div.c { 
        text-align: center; 
        font-size: 90%; 
        color: #808080; 
        height: 25px; 
        line-height: 25px; 
        position: relative; 
        margin: 4px; 
} 
a img { 
        border-width: 0; 
} 
a { 
} 
div.nav { 
        width: ${ARG_BIGSIZE}px; 
        height: 20px; 
} 
div.nav a { 
        color: #FFF; 
        text-decoration: none; 
} 
div.nav a:hover { 
        text-decoration: underline; 
} 
div.nav div.top { 
        position: absolute; 
        text-align: center; 
        width: $(($ARG_BIGSIZE - 100))px; 
        margin: 0 50px; 
} 
.left { 
        float: left; 
} 
.right { 
        float: right; 
} 
.clear { 
        clear: both; 
} 
                --> 
                </style> 
        </head> 
<body> 
HTML 
} 
 
# 
# html_footer() 
# 
html_footer() 
{ 
        cat <<HTML 
</body></html> 
HTML 
} 
 
# 
# html_tn() 
# 
html_tn() 
{ 
        tn=$1 
        link=$2 
 
        info=$($BIN_IMGINFO -f $tn) 
        width=$(echo $info | awk '{print $3}') 
        height=$(echo $info | awk '{print $4}') 
        top=$(($(($ARG_TNSIZE - $height)) / 2)) 
 
        cat <<HTML 
<div class="tn"> 
        <a href="$link" style="top:${top}px"> 
                <img alt="$tn" width="$width" height="$height" src="$tn" /> 
        </a> 
</div> 
HTML 
} 
 
# 
# html_img() 
# 
html_img() 
{ 
        img=$1 
        link=$2 
        linkb=$3 
        linkn=$4 
 
        info=$($BIN_IMGINFO -f $img) 
        width=$(echo $info | awk '{print $3}') 
        height=$(echo $info | awk '{print $4}') 
 
        if [ "$linkb" != "" ] 
         then          then
                hlinkb="<a href='$linkb'>zurück</a>"                ARG_DIR="$arg"
                olinkb="<a class='left' style='height:${height}px' href='$linkb'></a>"                break
         fi          fi
           test $arg = -d && is_dir=1
   done
   
        if [ "$linkn" != "" ]# load save args
        thenif [ -f "$ARG_DIR/$ARGFILE" ]
                hlinkn="<a href="$linkn">weiter</a>"then
                olinkn="<a class='right' style='height:${height}px' href='$linkn'></a>"        echo "load save settings"
        fi        . "$ARG_DIR/$ARGFILE"
 fi
   
         cat <<HTML  
 <div class="box">  
         <div class="nav">  
                 <div class="top"><a href="$link">Index</a></div>  
                 <div class="left">$hlinkb</div>  
                 <div class="right">$hlinkn</div>  
         </div>  
         <div class="big">  
                 <img alt="$img" width="$width" height="$height" src="$img" />  
         </div>  
         <div class="c">  
                 $ARG_TITLE $ARG_COPYRIGHT  
         </div>  
         <div class="over" style='height:${height}px'>  
                 $olinkb  
                 $olinkn  
         </div>  
 </div>  
 HTML  
 }  
   
 #  
 # err  
 #  
 err()  
 {  
         echo "$1" >&2  
         exit 1  
 }  
   
   
 # parse args  # parse args
 while [ "$1" != "" ]  while [ "$1" != "" ]
 do  do
Line 383  do Line 104  do
         shift          shift
         case $arg in          case $arg in
                 -h)                  -h)
                        usage                        usage;;
                        ;; 
                 -n)                  -n)
                         ARG_TITLE=$1                          ARG_TITLE=$1
                        shift                        shift;;
                        ;; 
                 -t)                  -t)
                         ARG_TNSIZE=$1                          ARG_TNSIZE=$1
                        shift                        shift;;
                        ;; 
                 -u)                  -u)
                         ARG_TNQALITY=$1                          ARG_TNQALITY=$1
                        shift                        shift;;
                        ;; 
                 -b)                  -b)
                         ARG_BIGSIZE=$1                          ARG_BIGSIZE=$1
                        shift                        shift;;
                        ;; 
                 -c)                  -c)
                         ARG_BIGQALITY=$1                          ARG_BIGQALITY=$1
                        shift                        shift;;
                        ;; 
                 -f)                  -f)
                         ARG_FILES=$1                          ARG_FILES=$1
                        shift                        shift;;
                        ;;                -l)
                         ARG_URL=$1
                         shift;;
                 -s)                  -s)
                         ARG_FILETYPES=$1                          ARG_FILETYPES=$1
                        shift                        shift;;
                        ;; 
                 -d)                  -d)
                         ARG_DIR=$1                          ARG_DIR=$1
                        shift                        shift;;
                        ;;                -e)
                         ARG_EXIF=$1
                         shift;;
                 -C)                  -C)
                         ARG_COPYRIGHT=$1                          ARG_COPYRIGHT=$1
                        shift                        shift;;
                        ;;                -F)
                         ARG_MAILFROM=$1
                         shift;;
                 -L)
                         ARG_LINK=$1
                         shift;;
                 -I)                  -I)
                         ARG_INFOFILE=$1                          ARG_INFOFILE=$1
                        shift                        shift;;
                        ;;                -T)
                         ARG_MAILTO=$1
                         shift;;
                 -U)                  -U)
                        ARG_UPDATE=0                        ARG_UPDATE=0;;
                        ;; 
                 -v)                  -v)
                         echo $VERSION                          echo $VERSION
                        exit                        exit;;
                        ;;                -w)
                         ARG_NAVI=1;;
                 *)                  *)
                         echo "unknown argument $arg"                          echo "unknown argument $arg"
                         exit                          exit
         esac          esac
 done  done
   
   # go to gallery directory
   MY=$(get_my_path)
   cd "$ARG_DIR" || exit 1
   
 # parese info file  # parese info file
 if [ "$ARG_INFOFILE" != "" ]  if [ "$ARG_INFOFILE" != "" ]
 then  then
         test -f $ARG_INFOFILE || err "info file not found \`\`$ARG_INFOFILE''"          test -f $ARG_INFOFILE || err "info file not found \`\`$ARG_INFOFILE''"
        for n in TITLE COPYRIGHT INDEX FILETYPES TNSIZE TNQALITY BIGSIZE BIGQALITY        for n in TITLE COPYRIGHT INDEX FILETYPES TNSIZE TNQALITY BIGSIZE \
                 BIGQALITY MAILTO MAILFROM URL EXIF INDEXIMG LINK NAVI
         do          do
                 v=$(make -f $ARG_INFOFILE -V$n)                  v=$(make -f $ARG_INFOFILE -V$n)
                 test "$v" = "" && continue                  test "$v" = "" && continue
Line 450  then Line 180  then
         done              done    
 fi  fi
   
echo $ARG_COPYRIGHT#paras from iso to utf-8
exit for n in $(set | awk -F= '{print $1}')
 do
         echo "$n" | grep -q '^ARG_' || continue
         eval "$n=\"\$(echo \"\$$n\" | $BIN_ICONV -f ISO-8859-1 -t UTF-8)\""
 done
   
MY=$(get_my_path)# fix url
cd "$ARG_DIR" || exit 1if [ "$ARG_URL" != "" ]
 then
         echo "$ARG_URL" | grep -q '/$' || ARG_URL="${ARG_URL}/"
 fi
   
 # if no images defined, find files  # if no images defined, find files
 if [ "$ARG_FILES" = "" -a "$ARG_FILETYPES" != "" ]  if [ "$ARG_FILES" = "" -a "$ARG_FILETYPES" != "" ]
Line 465  then Line 202  then
                 match="$match *.$(echo $type | tr '[:lower:]' '[:upper:]')"                  match="$match *.$(echo $type | tr '[:lower:]' '[:upper:]')"
                 match="$match *.$(echo $type | tr '[:upper:]' '[:lower:]')"                  match="$match *.$(echo $type | tr '[:upper:]' '[:lower:]')"
         done          done
        ARG_FILES=$(cd $ARG_DIR && ls $match 2>/dev/null)        FLIST=$(ls $match 2>/dev/null)
 else
         FLIST="$ARG_FILES"
 fi  fi
   
# Filter big and thumbnails# Filter big, thumbnails and curipted images
 echo -n "find images"  echo -n "find images"
FLIST=FLISTF=
for file in $ARG_FILESfor file in $FLIST
 do  do
         test $(echo $file | grep -E '\.(tn|big)\.jpg$') && continue          test $(echo $file | grep -E '\.(tn|big)\.jpg$') && continue
        FLIST="$FLIST $file"        test $($BIN_JPEGINFO $file | grep -Eq 'WARNING|ERROR') && continue
         FLISTF="$FLISTF $file"
         echo -n " $file"          echo -n " $file"
 done  done
echo echo
 FLIST="$FLISTF"
   
 test $(echo $FLIST | wc -w) -eq 0 && err "error: no image found in \`\`$ARG_DIR''"  test $(echo $FLIST | wc -w) -eq 0 && err "error: no image found in \`\`$ARG_DIR''"
   
   # use exif createtime to order images
   FLIST=$(
           (
                   for file in $FLIST
                   do
                           echo "$(get_exif_ts $file) $file"
                   done
           ) | sort -n | awk '{print $2}'
   )
   
   # if no master image, we use the first one
   test "$ARG_INDEXIMG" = "" && ARG_INDEXIMG=$(echo $FLIST | awk '{print $1}')
   
   # find start and end ts
   ARG_STARTTS=$(get_exif_ts $(echo $FLIST | awk '{print $1}'))
   ARG_ENDTS=$(get_exif_ts $(echo $FLIST | awk '{print $NF}'))
   
 # find new and to update images  # find new and to update images
 FLIST_NEW=  FLIST_NEW=
 FLIST_UPDATE=  FLIST_UPDATE=
Line 507  echo "tns: $targets" >> $MKAKEFILE Line 265  echo "tns: $targets" >> $MKAKEFILE
 FLIST_UPDATE=$(make -f $MKAKEFILE)  FLIST_UPDATE=$(make -f $MKAKEFILE)
 rm $MKAKEFILE  rm $MKAKEFILE
   
   # save args
   test -f $ARGFILE && rm $ARGFILE
   echo "save settings"
   set | while read n
   do
           echo "$n" | grep -q '^ARG_' || continue
           echo "$n" >> $ARGFILE
   done
   
 # update and no new and update images found  # update and no new and update images found
 if [ $ARG_UPDATE -eq 1 -a "$FLIST_NEW" = "" -a "$FLIST_UPDATE" = "" ]  if [ $ARG_UPDATE -eq 1 -a "$FLIST_NEW" = "" -a "$FLIST_UPDATE" = "" ]
 then  then
Line 519  then Line 286  then
         echo new images: $FLIST_NEW          echo new images: $FLIST_NEW
         echo update images: $FLIST_UPDATE          echo update images: $FLIST_UPDATE
 fi  fi
 exit  
   
 # Create make file to rotate und convert all big and thumbnails.  # Create make file to rotate und convert all big and thumbnails.
 # Is needed to define the new real image sizes.  # Is needed to define the new real image sizes.
Line 553  echo "tns: $targets" >> $MKAKEFILE Line 319  echo "tns: $targets" >> $MKAKEFILE
 make -f $MKAKEFILE  make -f $MKAKEFILE
 rm $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=
           test $ARG_ENDTS -ne -1 && enddate=$(date -r $ARG_ENDTS "+%d.%m.%Y")
           date=
           test "$startdate" != "" && date="$startdate"
           test "$enddate" != "$startdate" && date="$date - $enddate"
           link=
           test "$ARG_LINK" != "" && link="<a href='$ARG_LINK'>overview</a>"
           html_title "$ARG_TITLE" "$link" "$date"
   
           for file in $FLIST
           do
                   tn="${file}.tn.jpg"
                   imglink="${file}.html"
                   html_tn $tn $imglink
           done
           echo "<div class='clear'></div>"
           echo "<div class='c'>$ARG_TITLE $ARG_COPYRIGHT</div>"
           html_footer
   ) > $ARG_INDEX
   
 # create single html files  # create single html files
 index=""  
 i=0  i=0
   all=$(echo $FLIST | wc -w)
 echo -n "create single html files "  echo -n "create single html files "
 for file in $FLIST  for file in $FLIST
 do  do
Line 563  do Line 356  do
         i=$(($i + 1))          i=$(($i + 1))
         j=$(($i + 1))          j=$(($i + 1))
   
        tn="${file}.tn.jpg"        # is update mod and no new images founded
         if [ $ARG_UPDATE -eq 1 -a "$FLIST_NEW" = "" ]
         then
                 is_in_list "$FLIST_UPDATE" "$file" || continue
         fi
 
         big="${file}.big.jpg"          big="${file}.big.jpg"
         imglink="${file}.html"          imglink="${file}.html"
   
Line 575  do Line 373  do
         test "$linkn" != "" && linkn="$linkn.html"          test "$linkn" != "" && linkn="$linkn.html"
   
         echo -n .          echo -n .
         index="$index $(html_tn $tn $imglink)"  
         (          (
                 html_header                  html_header
                html_img $big $ARG_INDEX "$linkb" "$linkn"                html_img $file $i $all $big $ARG_INDEX "$linkb" "$linkn"
                 html_footer                  html_footer
         ) > $imglink          ) > $imglink
 done  done
 echo  echo
   
# create html index# .htaccess
echo create html indexif [ -f .htaccess ]
(then
        html_header        grep -q 'AddCharset UTF-8 .html' < .htaccess || echo "AddCharset UTF-8 .html" >> .htaccess
        echo $indexelse
        echo "<div class='clear'></div>"        echo "AddCharset UTF-8 .html" > .htaccess
        echo "<div class='c'>$ARG_TITLE $ARG_COPYRIGHT</div>"fi
        html_footer
) > $ARG_INDEXtest "$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

Removed from v.1.5  
changed lines
  Added in v.1.23