summaryrefslogtreecommitdiffstats
path: root/generate_gallery.sh
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2009-10-13 16:53:39 +0200
committerFlorian Pritz <bluewind@xssn.at>2009-10-13 16:53:39 +0200
commit75df9781ed50760a157d667d74aef3a7bcbd6357 (patch)
tree79e26d917e6896163adcec3e721c06e8a5c64a84 /generate_gallery.sh
parenta56b3ab0b8428a380d9918f27a68210309e6892b (diff)
downloadbin-75df9781ed50760a157d667d74aef3a7bcbd6357.tar.gz
bin-75df9781ed50760a157d667d74aef3a7bcbd6357.tar.xz
add generate-gallery.sh
this needs template.html Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'generate_gallery.sh')
-rwxr-xr-xgenerate_gallery.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/generate_gallery.sh b/generate_gallery.sh
new file mode 100755
index 0000000..62cea79
--- /dev/null
+++ b/generate_gallery.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+#----------------------------------------------------
+# Version: 0.1.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"
+scriptdir="$(dirname "$0")"
+
+html_template="$scriptdir/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 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"
+ popd &>/dev/null
+done
+
+rm $tempfile