1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
#!/bin/bash
## Cataract Gallery Generator - a simple static web photo gallery
## cgg-dirgen - Directory index.xml generator
## Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
PREVIEW="no"
PREVIEW_PATH="preview"
NO_FULLSIZE="no"
EXT_THUMB="no"
EXT_THUMB_PATH="thumbnails"
print_help()
{
echo "Usage: cgg-dirgen [OPTION...] > index.xml"
echo ""
echo "Options:"
echo " -?, --help Show help options"
echo " -d, --preview [dir] Use supplied preview (web page) images"
echo " - takes optional [dir] argument (default=\"preview\")"
echo " -o, --nofullsize Do not copy original (full size) image"
echo " - deprecated, use global <nofullsize /> tag"
echo " -t, --thumbnails [dir] Use supplied thumbnails"
echo " - takes optional [dir] argument (default=\"thumbnails\")"
}
# Gather arguments
while [[ $1 = -* ]]; do
case "$1" in
-d|--preview)
PREVIEW="yes"
shift
if [[ ! $1 == -* && ! "x$1" == "x" ]]; then
PREVIEW_PATH="$1"
shift
fi
;;
-o|--nofullsize)
NO_FULLSIZE="yes"
shift
;;
-t|--thumbnails)
EXT_THUMB="yes"
shift
if [[ ! $1 == -* && ! "x$1" == "x" ]]; then
EXT_THUMB_PATH="$1"
shift
fi
;;
-h|--help|-\?)
print_help;
exit
;;
*)
echo "Error: Unknown option: $1" >&2
exit 1
;;
esac
done
# Write index file
cat << XML_HEADER_STOP
<?xml version="1.0" encoding="utf-8"?>
<gallery type="album">
<general>
<ID>Album ID</ID>
<title>Album Title</title>
<description><![CDATA[Album description<br/>
]]></description>
</general>
<items>
XML_HEADER_STOP
for i in `find -L . -maxdepth 1 -type f -iname '*.jpg' -or -iname '*.jpeg' -or -iname '*.gif' -or -iname '*.png' | sort`; do
INCL="";
if [[ ${PREVIEW} == "yes" ]]; then INCL=" preview=\"${PREVIEW_PATH}/`echo $i | cut -b 3-`\""; fi
if [[ ${EXT_THUMB} == "yes" ]]; then INCL+=" thumbnail=\"${EXT_THUMB_PATH}/`echo $i | cut -b 3-`\""; fi
if [[ ${NO_FULLSIZE} == "yes" ]]; then INCL+=">\n <nofullsize /"; fi
echo -e " <item src=\"`echo $i | cut -b 3-`\"${INCL}>\n <title> </title>\n <title_description> </title_description>\n </item>\n";
done
cat << XML_FOOTER_STOP
</items>
</gallery>
XML_FOOTER_STOP
|