blob: 33b192e171989acfcfded5e50d5ae0842e1cf969 (
plain)
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
|
#!/bin/bash
#----------------------------------------------------
# Version: 0.2.0
# Author: Florian "Bluewind" Pritz <flo@xssn.at>
#
# Licensed under WTFPL v2
# (see COPYING for full license text)
#
#----------------------------------------------------
# put images in folder "foo" and run "$0 foo"
#----------------------------------------------------
startdir="$PWD"
datadir="$(dirname "$0")/generate_gallery.d"
html_template="$datadir/template.html"
tempfile=$(mktemp "/tmp/image-gallery.XXXXXX")
for i in "$@"; do
pushd "$i" &>/dev/null
echo > $tempfile
for img in *; do
filename="$(basename "$img")"
pushd "$(dirname "$img")" &>/dev/null
mkdir -p thumbs
if file -b --mime-type "$img" | grep -q "image/.*"; then
if [ ! -e "thumbs/$filename" ]; then
echo "processing: $i/$img"
convert "$filename" -thumbnail 200x200 "thumbs/$filename"
fi
echo "<div class=\"thumbnail\">" \
" <a rel=\"lytebox[pictures]\" class=\"thumbnail\" href=\"$img\">" \
" <img class=\"thumbnail\" alt=\"\" src=\"thumbs/$img\" />" \
" </a>" \
"</div>" | sed -r 's/\/\//\//g' >> $tempfile
else
echo "ignoring non-image: $i/$img"
fi
popd &>/dev/null
done
cd "$startdir"
sed -r \
-e "/%%CONTENT%%/r $tempfile" \
-e '/%%CONTENT/d' \
"$html_template" > "$i/index.html"
cp -r "$datadir/lytebox" "$i"
popd &>/dev/null
done
rm $tempfile
|