Annotation of scripts/pgallery/src/pgallery.sh, revision 1.6
1.1 as 1: #!/bin/sh
2: #
3: # THE BEER-WARE LICENSE 2012
4: # <as@paefchen.net> wrote this file. As long as you retain this notice you
5: # can do whatever you want with this stuff. If we meet some day, and you think
6: # this stuff is worth it, you can buy me a beer in return Aron Schlesinger
7: #
1.6 ! as 8: # $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.5 2012/08/28 10:44:41 as Exp $
1.1 as 9: #
10:
11: ARG_TITLE="PGallery"
12: ARG_FILES=
13: ARG_FILETYPES="jpg jpeg png gif tif tiff"
14: ARG_TNSIZE="180"
15: ARG_TNQALITY="70"
16: ARG_BIGSIZE="950"
17: ARG_BIGQALITY="90"
18: ARG_INDEX="index.html"
19: ARG_DIR="."
20: ARG_UPDATE=1
21: ARG_COPYRIGHT="© $(date +%Y)"
1.6 ! as 22: ARG_INFOFILE=""
! 23: ARG_MAILTO=""
! 24: ARG_MAILFROM="PGallery <${USER}@${HOST}>"
! 25: ARG_URL=
1.1 as 26:
27: BIN_CONVERT="/usr/local/bin/convert"
28: BIN_EXIFAUTOTRAN="/usr/local/bin/exifautotran"
29: BIN_IMGINFO="/usr/local/bin/imginfo"
1.6 ! as 30: BIN_SENDMAIL="/usr/sbin/sendmail"
1.1 as 31:
32: MKAKEFILE=".htmakefile"
1.5 as 33: VERSION="pgallery-1.1"
1.1 as 34:
35: #
36: # usage()
37: #
38: usage()
39: {
40: cat <<USAGE
41: usage $0: ( [-f <files>] | [-s <suffix>] ) [-d <dir>] [-n <name>]
42: [-t <thumbnail_size>] [-u <thumbnail_quality>]
1.6 ! as 43: [-b <big_size>] [-c <big_quality>] [-l link]
! 44: [-i <index>] [-C <copyright>] [-F <mailfrom>] [-T <mailto>]
! 45: [-U] | -h | -v
1.1 as 46: Options:
47: -b size size from big images in pixel (default: $ARG_BIGSIZE)
48: -c quality quality from big images 0-100% (default: $ARG_BIGQALITY)
49: -d dir gallery dir (default: $ARG_DIR)
50: -f files gallery images
51: -h this page
52: -i name index file name (default: $ARG_INDEX)
1.6 ! as 53: -l url gallery link
1.1 as 54: -n name page title (default: $ARG_TITLE)
55: -s suffix list of suffix. if no \`\`-f'' defined, used to find images
56: in \`\`-d'' directoy. case insensitive
57: (default: $ARG_FILETYPES)
58: -t size size from thumbnail images in pixel (default: $ARG_TNSIZE)
59: -u quality quality from thumbnail images 0-100% (default: $ARG_BIGQALITY)
1.4 as 60: -v print version
61: -C copyright copyright (html) string (default: $ARG_COPYRIGHT)
1.6 ! as 62: -F from mail sender (default: $ARG_MAILFROM)
1.5 as 63: -I file info text file for pgallery. info file paras prefered.
64: the syntax of the file is MAKE(1)
1.6 ! as 65: supported variable: TITLE COPYRIGHT INDEX FILETYPES TNSIZE URL
! 66: TNQALITY BIGSIZE BIGQALITY MAILTO MAILFROM
! 67: -T mailto send update infos to this address. if not set, no mail delivery
1.1 as 68: -U no update, new calculation of all images.
69: normally only new and modified images will calculated
70: USAGE
71: exit
72: }
73:
74: #
75: # get_my_path()
76: #
77: get_my_path()
78: {
79: current=$(pwd)
80: cd $(dirname $0)
81: echo $(pwd)/$(basename $0)
82: cd "$current"
83: }
84:
85: #
86: # html_header()
87: #
88: html_header()
89: {
90: cat <<HTML
91: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
92: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
93: <html xmlns="http://www.w3.org/1999/xhtml">
94: <head>
95: <title>$ARG_TITLE</title>
96: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
97: <style type="text/css">
98: <!--
99: body {
100: background-color: #464646;
101: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYB\
102: AMAAACDuy0HAAAAG1BMVEX+/v4BAQH///8KCgoDAwN/f3/19fWAgID8/PzhDwT2AAAACXRSTlMFBQUFBQU\
103: FBQWHDtP9AAALwklEQVR4Xg3KOWOyWhAA0Bn2ci57eXEvQY1JCZp8sQTjVo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YpwVGj53lNiPMY9Rltgd4icp82fvN69zkSBUI40nJSRTeHz7h1IX42Cr0klWjxjO05MSX1IaTeDmTRGEeK\
142: vAvtaaBaLQnjftGJz+4cjFyy6/iCjLGF2/gW+jQhEUxbEBPyQzXi+Bb4kc9wK4jIwNLWbwQAOtYKRLaipD\
143: H+X4TPPOG8DCNY4IC9yBk1qcibjhUgRnDcf35pl9d5otbvQjOIXlEu5dVtm5LRaK5KWcD/PX6LaGd25CuN\
144: HG/vgeIB1kcpCme+J8idlcjfBALAJSggznsGHGOAJgdGduMnZg+bAaeGASGV9bh/X2wPsVTmBLxmTTQsBG\
145: FkEOkZJTsGAm+HrtMDbWwvTXOutX1u7BxIq9Xib6DkFMbUitNdrYsULkahsAhBEh9FjdzL9BNARxTSr7T3\
146: u1rE+IWUmCIpwTZHZCu5l9THCuCcOhZqfekuQxjQ7EoyGUJAwCv/q1JOuJeCc/3lknb76zAquO/DAQhK/6\
147: 2cP8X2s3+IBLIhvL8RHopoHpIArJysYTTmMMeubPXh8W760AvMVH67jqgg06+/ne5MZ631z6yROhloh3dP\
148: QirZoEpr80wgt/cEbhbAQTmRLtGh8lxCwDBBb5OeJ4aEq25XBNMT2rzWedW2zIzj+CCDKlnlyJBzT81qBW\
149: p69h7vlb3TmEV+DNm2rqj1iT7BQuwVVsuPkwq1e5P8tgNjVbIlMzwXeM11kZqjx3KKFOJzc3CAyFVhi8fx\
150: VZ5FvhdAM5mM6kS6OgKu16MFglq3/b/QVIwdw7HUCyeW04JPjC5dO+GC9OfqfB4VX+wwuift+ths2Ss3i6\
151: nkOE+JFyD+wKFL+WMX6nwwDva0S1/O8Mlnida69Ph96fuFvCoRMvXnCfsLPPmC/hA5RnMNE4fDK0pVOQ4B\
152: HLaErzv/wD99ABmjNZk0AAAAABJRU5ErkJggg==");
153: margin: 10px auto;
154: font-family: Geneva,Arial,sans-serif;
155: font-size: 12px;
1.2 as 156: text-shadow: 1px 1px 1px #000;
1.1 as 157: }
158: div.tn {
159: float: left;
160: width: ${ARG_TNSIZE}px;
161: height: ${ARG_TNSIZE}px;
162: vertical-align:text-top;
163: text-align: center;
164: margin: 4px;
165: }
166: div.tn a {
167: position: relative;
168: display: inline-block;
169: height: ${ARG_TNSIZE}px;
170: }
171: div.tn, div.big {
172: background-color: black;
173: border-width: 1px;
174: border-style: solid;
175: border-color: gray;
176: box-shadow: 1px 1px 2px #000;
177: padding: 1px;
1.4 as 178: border-radius: 3px;
1.1 as 179: }
180: div.tn:hover {
181: background-color: #222;
182: }
183: div.big {
184: display: inline-block;
185: width: ${ARG_BIGSIZE}px;
186: }
187: div.over {
188: width: ${ARG_BIGSIZE}px;
189: position: absolute;
190: top: 30px;
191: padding: 1px;
192: }
193: div.over a.left, div.over a.right {
194: display: block;
1.2 as 195: /* shell fuck of: missing CTLARI (shouldn't happen) - WTF?! */
196: width: $(($ARG_BIGSIZE / 2))px;
1.1 as 197: position: relative;
198: top: 1px;
199: left: 1px;
200: background-repeat: no-repeat;
201: }
202: div.over a.left:hover {
203: background-position: 5% center;
204: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\
205: AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAh9JREFUeNrE2L1Lw0A\
206: UAHATSivSZii0ldpBnMU6SgYJpQUJDlk7dLV+LTqIiIv4B7kLolBKQRA6GLqUDMEhqKAlhUIR4125SHo0b\
207: XJ51x68pDSX+3G5I/dyguM4S/MuMfeHIAiQ7Yo+//+OocAYPm+jWEXxg8JC8erCgvt4AXrqgkkUJRRZ6jq\
208: G71EMRcAeil6wWq2uGYZx1ul0jjRNy5Jey6PauKcRJ5NIhklCoaE4QODNYDCwHVJ6vd5HIpE4xNdQxKOiM\
209: 0G3FIvFc4Imo6CBQV3XXwioje5jREOBkiQdE3SLFWUFFXJfaJQVLP2DIWdvFDA+9pYKiMKBAVFYMAAKD85\
210: A+YBTUH6gD8oXnIDyB31QviCFzgekUPxYVe4ghW7ixhRFueQKUmgZN9hut1s0aNv2V6FQOAUBqRvT+IAaX\
211: 6crWZb1hsqQJFfPkPnpJz6YpmnQlXK5XD6TycRIcrUDib7jQ71ev+v3+9/eSqlUKt1qtU4IvIFid2x9jDC\
212: muJE9PG6qql7jcaTHttvt6gh2J1MZYva6ees+d9jnjcQXnoDyh31WGb7wlPWUHzwjc+ADB8iR4OGA2SAsH\
213: CLvhYNDZvgwMMO3THSY8auNBS6xfrVFhZUoaGjYk+qA7DkEgmu12i1Bs1C7K1NhvLviecTLEOhEuFKpXDW\
214: bzcdGo/Egy/KFZzKJPHbMVsiEyVPXTRRPeMdMWMQuqLi0gPInwACOBcZx3lRFMwAAAABJRU5ErkJggg==");
215: }
216: div.over a.right:hover {
217: background-position: 95% center;
218: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\
219: AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAiJJREFUeNrE2D1Lw0A\
220: YAOAmlNbBdii0FVM6OEu7SgcJpRUJDlk7dE21uuggIi7iD/IX+AGlFAXBDqVLyVCCBBW0JFhwMN7JHRxnY\
221: 5PcnX3hhSM58nB3+Xhzkud5sf8OiWjLPn2+eGF4gHEChLkOcgUdt0E+isAlhCVAbiGQjGeQ1yBdHjAeKZ7\
222: SCgR1Xc8Nh8M90zQPG42GAo7lQFZBLhOzwSXgKI1kMrk7mUxePBTT6dQB8Dk8B1IHmUbTLrOMFI8WjsIol\
223: 8tHHhW8YRKV0QWNwWDwIBKm0RK8aDqdbouEaRReQBUNkygJV0XCNBojnldh8CxUOOyHCoX/QoXB81AhcBC\
224: UOxwU5QqHQbnBYVFWODLKDEdFo8IanGYWNBSsquoJgkus6C+4UCgcOI7zRsP9fv8OoTWM8qh57mHlaFnWp\
225: 23bFn1SUZQiambm1bphYgMWddlsNp7P51fpk+Px2ETNV1YUf383Qa5BsNfr7adSqQzZyXXd91ardUmUs8x\
226: rWYNrBcD2aDQa0GsJ11fTtDO0ntssd28UcAfXzSxvpLBg5DcSKyhH/cowgVG+p8xg2MqBCximRuIGBq0Gu\
227: YJB6l7u4LwKXwjo9y8jFPT7a6uKBGehqmiQRhO45BAJ0ijcQTGazeaFSJBGl/DUkrsrvMFZa/pzE1UqleN\
228: Op3PV7XZv6vX6KU+QRMkdM3gzFal+TyBvQX7w3DGTFrELKscWEN8CDADBm8pgcciwqgAAAABJRU5ErkJgg\
229: g==");
230: }
231: div.big a {
232: position: relative;
233: display: inline-block;
234: width: ${ARG_BIGSIZE}px;
235: }
236: div.box {
237: text-align: center;
238: width: ${ARG_BIGSIZE}px;
239: margin: auto;
240: }
241: div.box div.c {
242: width: ${ARG_BIGSIZE}px;
243: text-align: right;
244: font-size: 90%;
245: color: #808080;
246: height: 25px;
247: line-height: 25px;
248: position: relative;
249: left: 4px;
250: }
251: body > div.c {
252: text-align: center;
253: font-size: 90%;
254: color: #808080;
255: height: 25px;
256: line-height: 25px;
257: position: relative;
258: margin: 4px;
259: }
260: a img {
261: border-width: 0;
262: }
263: a {
264: }
265: div.nav {
266: width: ${ARG_BIGSIZE}px;
267: height: 20px;
268: }
269: div.nav a {
270: color: #FFF;
271: text-decoration: none;
272: }
273: div.nav a:hover {
274: text-decoration: underline;
275: }
276: div.nav div.top {
277: position: absolute;
278: text-align: center;
1.2 as 279: width: $(($ARG_BIGSIZE - 100))px;
280: margin: 0 50px;
1.1 as 281: }
282: .left {
283: float: left;
284: }
285: .right {
286: float: right;
287: }
288: .clear {
289: clear: both;
290: }
291: -->
292: </style>
293: </head>
294: <body>
295: HTML
296: }
297:
298: #
299: # html_footer()
300: #
301: html_footer()
302: {
303: cat <<HTML
304: </body></html>
305: HTML
306: }
307:
308: #
309: # html_tn()
310: #
311: html_tn()
312: {
313: tn=$1
314: link=$2
315:
316: info=$($BIN_IMGINFO -f $tn)
317: width=$(echo $info | awk '{print $3}')
318: height=$(echo $info | awk '{print $4}')
319: top=$(($(($ARG_TNSIZE - $height)) / 2))
320:
321: cat <<HTML
322: <div class="tn">
323: <a href="$link" style="top:${top}px">
324: <img alt="$tn" width="$width" height="$height" src="$tn" />
325: </a>
326: </div>
327: HTML
328: }
329:
330: #
331: # html_img()
332: #
333: html_img()
334: {
335: img=$1
336: link=$2
337: linkb=$3
338: linkn=$4
339:
1.3 as 340: info=$($BIN_IMGINFO -f $img)
341: width=$(echo $info | awk '{print $3}')
342: height=$(echo $info | awk '{print $4}')
1.1 as 343:
344: if [ "$linkb" != "" ]
345: then
346: hlinkb="<a href='$linkb'>zurück</a>"
347: olinkb="<a class='left' style='height:${height}px' href='$linkb'></a>"
348: fi
349:
350: if [ "$linkn" != "" ]
351: then
352: hlinkn="<a href="$linkn">weiter</a>"
353: olinkn="<a class='right' style='height:${height}px' href='$linkn'></a>"
354: fi
355:
356: cat <<HTML
357: <div class="box">
358: <div class="nav">
1.2 as 359: <div class="top"><a href="$link">Index</a></div>
1.1 as 360: <div class="left">$hlinkb</div>
361: <div class="right">$hlinkn</div>
362: </div>
363: <div class="big">
1.3 as 364: <img alt="$img" width="$width" height="$height" src="$img" />
1.1 as 365: </div>
366: <div class="c">
367: $ARG_TITLE $ARG_COPYRIGHT
368: </div>
369: <div class="over" style='height:${height}px'>
370: $olinkb
371: $olinkn
372: </div>
373: </div>
374: HTML
375: }
376:
377: #
378: # err
379: #
380: err()
381: {
382: echo "$1" >&2
383: exit 1
384: }
385:
1.6 ! as 386: #
! 387: # mysendmail()
! 388: #
! 389: mysendmail()
! 390: {
! 391: subject=$1
! 392: (
! 393: cat <<MAIL
! 394: From: $ARG_MAILFROM
! 395: To: $ARG_MAILTO
! 396: Subject: $subject
! 397: Content-Type: text/plain; charset=iso-8859-1
! 398: X-Mailer: $VERSION
! 399:
! 400: $(cat)
! 401: MAIL
! 402: ) | $BIN_SENDMAIL -t
! 403: }
1.1 as 404:
405: # parse args
406: while [ "$1" != "" ]
407: do
408: arg=$1
409: shift
410: case $arg in
411: -h)
1.6 ! as 412: usage;;
1.1 as 413: -n)
414: ARG_TITLE=$1
1.6 ! as 415: shift;;
1.1 as 416: -t)
417: ARG_TNSIZE=$1
1.6 ! as 418: shift;;
1.1 as 419: -u)
420: ARG_TNQALITY=$1
1.6 ! as 421: shift;;
1.1 as 422: -b)
423: ARG_BIGSIZE=$1
1.6 ! as 424: shift;;
1.1 as 425: -c)
426: ARG_BIGQALITY=$1
1.6 ! as 427: shift;;
1.1 as 428: -f)
429: ARG_FILES=$1
1.6 ! as 430: shift;;
! 431: -l)
! 432: ARG_URL=$1
! 433: shift;;
1.1 as 434: -s)
435: ARG_FILETYPES=$1
1.6 ! as 436: shift;;
1.1 as 437: -d)
438: ARG_DIR=$1
1.6 ! as 439: shift;;
1.1 as 440: -C)
441: ARG_COPYRIGHT=$1
1.6 ! as 442: shift;;
! 443: -F)
! 444: ARG_MAILFROM=$1
! 445: shift;;
1.5 as 446: -I)
447: ARG_INFOFILE=$1
1.6 ! as 448: shift;;
! 449: -T)
! 450: ARG_MAILTO=$1
! 451: shift;;
1.1 as 452: -U)
1.6 ! as 453: ARG_UPDATE=0;;
1.1 as 454: -v)
455: echo $VERSION
1.6 ! as 456: exit;;
1.1 as 457: *)
458: echo "unknown argument $arg"
459: exit
460: esac
461: done
462:
1.5 as 463: # parese info file
464: if [ "$ARG_INFOFILE" != "" ]
465: then
466: test -f $ARG_INFOFILE || err "info file not found \`\`$ARG_INFOFILE''"
1.6 ! as 467: for n in TITLE COPYRIGHT INDEX FILETYPES TNSIZE TNQALITY BIGSIZE \
! 468: BIGQALITY MAILTO MAILFROM URL
1.5 as 469: do
470: v=$(make -f $ARG_INFOFILE -V$n)
471: test "$v" = "" && continue
472: eval "ARG_$n='$v'"
473: done
474: fi
475:
1.6 ! as 476: # go to gallery directory
1.1 as 477: MY=$(get_my_path)
478: cd "$ARG_DIR" || exit 1
479:
1.6 ! as 480: # fix url
! 481: if [ "$ARG_URL" != "" ]
! 482: then
! 483: echo "$ARG_URL" | grep -q '/$' || ARG_URL="${ARG_URL}/"
! 484: fi
! 485:
1.1 as 486: # if no images defined, find files
487: if [ "$ARG_FILES" = "" -a "$ARG_FILETYPES" != "" ]
488: then
489: match=
490: for type in $ARG_FILETYPES
491: do
492: match="$match *.$(echo $type | tr '[:lower:]' '[:upper:]')"
493: match="$match *.$(echo $type | tr '[:upper:]' '[:lower:]')"
494: done
495: ARG_FILES=$(cd $ARG_DIR && ls $match 2>/dev/null)
496: fi
497:
498: # Filter big and thumbnails
499: echo -n "find images"
500: FLIST=
501: for file in $ARG_FILES
502: do
503: test $(echo $file | grep -E '\.(tn|big)\.jpg$') && continue
504: FLIST="$FLIST $file"
505: echo -n " $file"
506: done
507: echo
508:
509: test $(echo $FLIST | wc -w) -eq 0 && err "error: no image found in \`\`$ARG_DIR''"
510:
1.5 as 511: # find new and to update images
512: FLIST_NEW=
513: FLIST_UPDATE=
514: echo "all: tns" > $MKAKEFILE
515: targets=""
516: for file in $FLIST
517: do
518: tn="${file}.tn.jpg"
519: if [ ! -f $tn ]
520: then
521: FLIST_NEW="$FLIST_NEW $file"
522: continue
523: fi
524:
525: targets="$targets $tn"
526: (
527: cat <<MAKE
528: $tn: $file
529: @echo ${file}
530: MAKE
531: ) >> $MKAKEFILE
532: done
533: echo "tns: $targets" >> $MKAKEFILE
534: FLIST_UPDATE=$(make -f $MKAKEFILE)
535: rm $MKAKEFILE
536:
537: # update and no new and update images found
538: if [ $ARG_UPDATE -eq 1 -a "$FLIST_NEW" = "" -a "$FLIST_UPDATE" = "" ]
539: then
540: echo nothing to do
541: exit 1
542: fi
543:
544: if [ $ARG_UPDATE -eq 1 ]
545: then
546: echo new images: $FLIST_NEW
547: echo update images: $FLIST_UPDATE
548: fi
549:
1.1 as 550: # Create make file to rotate und convert all big and thumbnails.
551: # Is needed to define the new real image sizes.
552: echo "all: tns" > $MKAKEFILE
553: targets=""
554: for file in $FLIST
555: do
556: tn="${file}.tn.jpg"
557: big="${file}.big.jpg"
558: targets="$targets $tn"
559:
560: target=
561: if [ $ARG_UPDATE -eq 1 ]
562: then
563: target="$tn: $ME $file"
564: else
565: target="$tn::"
566: fi
567:
568: (
1.5 as 569: cat <<MAKE
1.1 as 570: $target
571: $BIN_EXIFAUTOTRAN $file
572: $BIN_CONVERT -verbose -thumbnail ${ARG_TNSIZE}x${ARG_TNSIZE} -quality $ARG_TNQALITY $file $tn
573: $BIN_CONVERT -verbose -thumbnail ${ARG_BIGSIZE}x${ARG_BIGSIZE} -quality $ARG_BIGQALITY $file $big
574: MAKE
575: ) >> $MKAKEFILE
576: done
577: echo "tns: $targets" >> $MKAKEFILE
578:
579: make -f $MKAKEFILE
580: rm $MKAKEFILE
581:
582: # create single html files
583: index=""
584: i=0
585: echo -n "create single html files "
586: for file in $FLIST
587: do
588: h=$i
589: i=$(($i + 1))
590: j=$(($i + 1))
591:
592: tn="${file}.tn.jpg"
593: big="${file}.big.jpg"
594: imglink="${file}.html"
595:
596: if [ $i -ne 1 ]
597: then
598: linkb=$(echo $FLIST | awk "{print \$$h}").html
599: fi
600: linkn=$(echo $FLIST | awk "{print \$$j}")
601: test "$linkn" != "" && linkn="$linkn.html"
602:
603: echo -n .
604: index="$index $(html_tn $tn $imglink)"
605: (
606: html_header
607: html_img $big $ARG_INDEX "$linkb" "$linkn"
608: html_footer
609: ) > $imglink
610: done
611: echo
612:
613: # create html index
614: echo create html index
615: (
616: html_header
617: echo $index
618: echo "<div class='clear'></div>"
619: echo "<div class='c'>$ARG_TITLE $ARG_COPYRIGHT</div>"
620: html_footer
621: ) > $ARG_INDEX
1.6 ! as 622:
! 623:
! 624: test "$ARG_MAILTO" = "" && exit 0
! 625:
! 626: # send info mail
! 627: if [ "$FLIST_NEW" != "" -o "$FLIST_UPDATE" != "" ]
! 628: then
! 629: echo "send mail to $ARG_MAILTO"
! 630: (
! 631: echo "Hallo,"
! 632: echo
! 633: echo -n "the gallery $ARG_TITLE has been updated"
! 634: if [ "$ARG_URL" != "" ]
! 635: then
! 636: echo ":"
! 637: echo $ARG_URL
! 638: else
! 639: echo "."
! 640: fi
! 641:
! 642: suffix=
! 643: test "$ARG_URL" != "" && suffix=.html
! 644:
! 645: if [ "$FLIST_NEW" != "" ]
! 646: then
! 647: echo
! 648: echo "add pictures:"
! 649: for file in $FLIST_NEW
! 650: do
! 651: echo "- ${ARG_URL}${file}${suffix}"
! 652: done
! 653: fi
! 654:
! 655: if [ "$FLIST_UPDATE" != "" ]
! 656: then
! 657: echo
! 658: echo "update pictures:"
! 659: for file in $FLIST_UPDATE
! 660: do
! 661: echo "- ${ARG_URL}${file}${suffix}"
! 662: done
! 663: fi
! 664: ) | mysendmail "PGallery Update: $ARG_TITLE"
! 665: fi