version 1.5, 2012/08/28 10:44:41
|
version 1.6, 2012/08/28 12:30:30
|
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.4 2012/08/28 08:43:05 as Exp $ | # $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.5 2012/08/28 10:44:41 as Exp $ |
# |
# |
|
|
ARG_TITLE="PGallery" |
ARG_TITLE="PGallery" |
Line 19 ARG_INDEX="index.html"
|
Line 19 ARG_INDEX="index.html"
|
ARG_DIR="." |
ARG_DIR="." |
ARG_UPDATE=1 |
ARG_UPDATE=1 |
ARG_COPYRIGHT="© $(date +%Y)" |
ARG_COPYRIGHT="© $(date +%Y)" |
ARG_INFOFILE="pgallery.txt" | ARG_INFOFILE="" |
| ARG_MAILTO="" |
| ARG_MAILFROM="PGallery <${USER}@${HOST}>" |
| ARG_URL= |
|
|
BIN_CONVERT="/usr/local/bin/convert" |
BIN_CONVERT="/usr/local/bin/convert" |
BIN_EXIFAUTOTRAN="/usr/local/bin/exifautotran" |
BIN_EXIFAUTOTRAN="/usr/local/bin/exifautotran" |
BIN_IMGINFO="/usr/local/bin/imginfo" |
BIN_IMGINFO="/usr/local/bin/imginfo" |
|
BIN_SENDMAIL="/usr/sbin/sendmail" |
|
|
MKAKEFILE=".htmakefile" |
MKAKEFILE=".htmakefile" |
VERSION="pgallery-1.1" |
VERSION="pgallery-1.1" |
Line 36 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>] |
[-b <big_size>] [-c <big_quality>] | [-b <big_size>] [-c <big_quality>] [-l link] |
[-i <index>] [-C <copyright>] [-U] | -h | -v | [-i <index>] [-C <copyright>] [-F <mailfrom>] [-T <mailto>] |
| [-U] | -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) |
Line 45 Options:
|
Line 50 Options:
|
-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 |
-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 53 Options:
|
Line 59 Options:
|
-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 |
-C copyright copyright (html) string (default: $ARG_COPYRIGHT) |
-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. |
-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 |
| -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 |
Line 375 err()
|
Line 383 err()
|
exit 1 |
exit 1 |
} |
} |
|
|
|
# |
|
# mysendmail() |
|
# |
|
mysendmail() |
|
{ |
|
subject=$1 |
|
( |
|
cat <<MAIL |
|
From: $ARG_MAILFROM |
|
To: $ARG_MAILTO |
|
Subject: $subject |
|
Content-Type: text/plain; charset=iso-8859-1 |
|
X-Mailer: $VERSION |
|
|
|
$(cat) |
|
MAIL |
|
) | $BIN_SENDMAIL -t |
|
} |
|
|
# parse args |
# parse args |
while [ "$1" != "" ] |
while [ "$1" != "" ] |
do |
do |
Line 383 do
|
Line 409 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;; |
;; | |
-C) |
-C) |
ARG_COPYRIGHT=$1 |
ARG_COPYRIGHT=$1 |
shift | shift;; |
;; | -F) |
| ARG_MAILFROM=$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;; |
;; | |
*) |
*) |
echo "unknown argument $arg" |
echo "unknown argument $arg" |
exit |
exit |
Line 442 done
|
Line 464 done
|
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 |
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 473 then
|
done |
done |
fi |
fi |
|
|
echo $ARG_COPYRIGHT | # go to gallery directory |
exit | |
| |
MY=$(get_my_path) |
MY=$(get_my_path) |
cd "$ARG_DIR" || exit 1 |
cd "$ARG_DIR" || exit 1 |
|
|
|
# fix url |
|
if [ "$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" != "" ] |
then |
then |
Line 519 then
|
Line 546 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 593 echo create html index
|
Line 619 echo create html index
|
echo "<div class='c'>$ARG_TITLE $ARG_COPYRIGHT</div>" |
echo "<div class='c'>$ARG_TITLE $ARG_COPYRIGHT</div>" |
html_footer |
html_footer |
) > $ARG_INDEX |
) > $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 |