Diff for /scripts/pgallery/src/pgallery.sh between versions 1.12 and 1.17

version 1.12, 2012/08/29 12:30:35 version 1.17, 2012/08/29 14:44:04
Line 5 Line 5
 # 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.11 2012/08/29 11:21:41 as Exp $# $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.16 2012/08/29 14:15:50 as Exp $
 #  #
   
 ARG_TITLE="PGallery"  ARG_TITLE="PGallery"
Line 33  BIN_EXIFTRAN="/usr/local/bin/exiftran" Line 33  BIN_EXIFTRAN="/usr/local/bin/exiftran"
 BIN_EXIF="/usr/local/bin/exif"  BIN_EXIF="/usr/local/bin/exif"
   
 MKAKEFILE=".htmakefile"  MKAKEFILE=".htmakefile"
VERSION="pgallery-1.2"VERSION="pgallery-1.3"
   
 #  #
 # usage()  # usage()
Line 94  get_my_path() Line 94  get_my_path()
 html_header()  html_header()
 {  {
         cat <<HTML          cat <<HTML
   <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">  <html xmlns="http://www.w3.org/1999/xhtml">
 <head>  <head>
         <title>$ARG_TITLE</title>          <title>$ARG_TITLE</title>
                <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
                <style type="text/css">        <style type="text/css">
                <!--        <!--
 body {  body {
         background-color: #464646;          background-color: #464646;
         background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYB\          background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYB\
Line 360  html_img() Line 361  html_img()
   
         if [ "$linkb" != "" ]          if [ "$linkb" != "" ]
         then          then
                hlinkb="<a href='$linkb'>back</a>"                hlinkb="<a href='$linkb'>prev</a>"
                 olinkb="<a class='left' style='height:${height}px' href='$linkb'></a>"                  olinkb="<a class='left' style='height:${height}px' href='$linkb'></a>"
         fi          fi
   
         if [ "$linkn" != "" ]          if [ "$linkn" != "" ]
         then          then
                hlinkn="<a href="$linkn">forward</a>"                hlinkn="<a href="$linkn">next</a>"
                 olinkn="<a class='right' style='height:${height}px' href='$linkn'></a>"                  olinkn="<a class='right' style='height:${height}px' href='$linkn'></a>"
         fi          fi
   
Line 374  html_img() Line 375  html_img()
 <div class="box">  <div class="box">
         <div class="nav">          <div class="nav">
                 <div class="top">                  <div class="top">
                        <a href="$link">Index</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="$orig">original</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;$num/$all                        <a href="$link">index</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="$orig">original</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;$num/$all
                 </div>                  </div>
                 <div class="left">$hlinkb</div>                  <div class="left">$hlinkb</div>
                 <div class="right">$hlinkn</div>                  <div class="right">$hlinkn</div>
Line 429  MAIL Line 430  MAIL
 get_exif_desc()  get_exif_desc()
 {  {
         img=$1          img=$1
        $BIN_EXIF --ifd=0 --tag=0x010e -m $img 2> /dev/null | iconv -t ISO-8859-1 -f UTF-8 | while read line        $BIN_EXIF --ifd=0 --tag=0x010e -m $img 2> /dev/null | while read line
         do          do
                 echo "$line<br />"                  echo "$line<br />"
         done          done
Line 442  get_exif_ts() Line 443  get_exif_ts()
 {  {
         img=$1          img=$1
         date=$($BIN_EXIF --ifd=EXIF --tag=0x9003 -m $img 2> /dev/null)          date=$($BIN_EXIF --ifd=EXIF --tag=0x9003 -m $img 2> /dev/null)
        test "$date" = "" && return 1        if [ "$date" = "" ]
         then
                 echo "-1"
                 return 1
         fi
         date -j -f "%Y:%m:%d %T" "$date" "+%s"          date -j -f "%Y:%m:%d %T" "$date" "+%s"
 }  }
   
Line 484  get_exif_info() Line 489  get_exif_info()
                         exifinfo="$exifinfo$exif "                          exifinfo="$exifinfo$exif "
                 fi                  fi
         done          done
        echo $exifinfo | sed -E -e 's/ mm /mm /' -e 's/ sec./s/' -e 's/ ISO / ISO/' -e 's/ ISO(\/| )/ \1/'        echo $exifinfo | sed -E -e 's/ mm /mm /' -e 's/ se(c|k)./s/' -e 's/ ISO / ISO/' -e 's/ ISO(\/| )/ \1/'
 }  }
   
 #  #
Line 562  do Line 567  do
         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
Line 575  then Line 584  then
         done              done    
 fi  fi
   
# go to gallery directory# paras from iso to utf-8
MY=$(get_my_path)for n in $(set | awk -F= '{print $1}')
cd "$ARG_DIR" || exit 1do
         echo "$n" | grep -q '^ARG_' || continue
         eval "$n=\"\$(echo \"\$$n\" | iconv -f ISO-8859-1 -t UTF-8)\""
 done
   
 # fix url  # fix url
 if [ "$ARG_URL" != "" ]  if [ "$ARG_URL" != "" ]
Line 610  echo  Line 622  echo 
   
 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}'
   )
   
 # find new and to update images  # find new and to update images
 FLIST_NEW=  FLIST_NEW=
 FLIST_UPDATE=  FLIST_UPDATE=
Line 678  MAKE Line 700  MAKE
 done  done
 echo "tns: $targets" >> $MKAKEFILE  echo "tns: $targets" >> $MKAKEFILE
   
#make -f $MKAKEFILEmake -f $MKAKEFILE
 rm $MKAKEFILE  rm $MKAKEFILE
   
 # create html index  # create html index
Line 733  do Line 755  do
         ) > $imglink          ) > $imglink
 done  done
 echo  echo
   
   # .htaccess
   if [ -f .htaccess ]
   then
           grep -q 'AddCharset UTF-8 .html' < .htaccess || echo "AddCharset UTF-8 .html" >> .htaccess
   else
           echo "AddCharset UTF-8 .html" > .htaccess
   fi
   
 test "$ARG_MAILTO" = "" && exit 0  test "$ARG_MAILTO" = "" && exit 0
   

Removed from v.1.12  
changed lines
  Added in v.1.17