diff options
| author | Paul Buetow (mars.fritz.box) <paul@buetow.org> | 2013-12-29 15:33:05 +0100 |
|---|---|---|
| committer | Paul Buetow (mars.fritz.box) <paul@buetow.org> | 2013-12-29 15:33:05 +0100 |
| commit | 5eb6987795bb88ba690dc9ba80716f50da05e075 (patch) | |
| tree | 48be6a2a750d9f9ee00cae3994c7d369184e43d7 | |
| parent | 4ba4bc0bca96709da0d4032634221cd409c97848 (diff) | |
Next Friday will not be your lucky day. As a matter of fact, you don't
have a lucky day this year.
| -rw-r--r-- | photoalbum.conf | 17 | ||||
| -rwxr-xr-x | photoalbum.sh | 143 |
2 files changed, 0 insertions, 160 deletions
diff --git a/photoalbum.conf b/photoalbum.conf deleted file mode 100644 index 64012f0..0000000 --- a/photoalbum.conf +++ /dev/null @@ -1,17 +0,0 @@ -#set -e -#set -x - -declare -i THUMBGEOMETRY=250 -declare -i GEOMETRY=800 -declare -i MAXPREVIEWS=100 - -declare -r TITLE='A simple Photoalbum' -declare -r INCOMING=./incoming - -# Includes a .tar of the incoming dir in the dist, can be yes or no -declare -r INCLUDETARBALL=yes - -# If INCLUDETARBALL=yes, set the Name of the tarball -declare -r TARBALLNAME=all-$(date +'%Y-%m-%d-%H%M%S') -declare -r TARBALLSUFFIX=.tar -declare -r TAROPTS='-c' diff --git a/photoalbum.sh b/photoalbum.sh deleted file mode 100755 index 57d953e..0000000 --- a/photoalbum.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/bash - -# Small quick n dirty photo album script -# 2011, 2012, 2013 Paul Buetow - -source photoalbum.conf - -function template () { - local -r template=${1} ; shift - local -r html=${1} ; shift - local destdir=${1} ; shift - - if [ -z "${destdir}" ]; then - destdir=./dist/html/ - fi - - if [ -d ./templates/ ]; then - source ./templates/${template}.tmpl >> ${destdir}/${html}.html - else - source ../../templates/${template}.tmpl >> ../../${destdir}/${html}.html - fi -} - -function createdirs () { - for dir in ./dist/{photos,thumbs,html}; do - [ -d ${dir} ] || mkdir -vp ${dir} - done -} - -function scale () { - cd "${INCOMING}" || exit 1 - find . -type f | sed 's#^\./##' | - while read photo; do - # Flatten directories / to __ - destphoto="${photo//\//__}" - - if [ ! -f "../dist/photos/${destphoto}" ]; then - echo "Scaling ${photo} to ../dist/photos/${destphoto}" - - convert -auto-orient \ - -geometry ${GEOMETRY} "${photo}" "../dist/photos/${destphoto}" - fi - done - cd - &>/dev/null - - echo 'Removing spaces from file names' - find ./dist/photos -type f -name '* *' | - while read file; do - rename 's/ /_/g' "${file}" - done -} - -function generate () { - local num=1 - local name=page-${num} - local -i i=0 - - template header ${name} - template header-first-add ${name} - - cd ./dist/photos || exit 1 - - find ./ -type f | sort | sed 's#^\./##' | - while read photo; do - : $(( i++ )) - - if [ ${i} -gt ${MAXPREVIEWS} ]; then - i=1 - : $(( num++ )) - - next=page-${num} - template next ${name} - template footer ${name} - - prev=${name} - name=${next} - template header ${name} - template prev ${name} - fi - - # Preview page - template preview ${name} - - # View page - template header ${num}-${i} - template view ${num}-${i} - template footer ${num}-${i} - - if [ ! -f "../thumbs/${photo}" ]; then - echo "Creating thumb for ${photo}"; - convert -geometry x${THUMBGEOMETRY} "${photo}" \ - "../thumbs/${photo}" - fi - done - - cd - &>/dev/null - - template footer $(cd ./dist/html;ls -t page-*.html | head -n 1 | sed 's/.html//') - - # Generate HTTP redirect pages - ls ./dist/html/*.html | grep -v page- | cut -d'-' -f1 | uniq | - while read prefix; do - declare page=$(ls -t ${prefix}-*.html | head -n 1 | sed 's#./dist/html/\(.*\)-.*.html#\1#') - declare lastview=$(ls -t ${prefix}-*.html | head -n 1 | sed 's/.*-\(.*\).html/\1/') - - declare prevredirect=${page}-0 - declare nextredirect=${page}-$((lastview+1)) - - redirectpage=$(( page-1 ))-${MAXPREVIEWS} - template redirect ${prevredirect} - - if [ ${lastview} -eq ${MAXPREVIEWS} ]; then - redirectpage=$(( page+1 ))-1 - else - redirectpage=${page}-${lastview} - template redirect 0-${MAXPREVIEWS} - - redirectpage=1-1 - fi - - template redirect ${nextredirect} - done -} - -function tarball () { - # Cleanup tarball from prev run if any - find ./dist/ -maxdepth 1 -type f -name \*.tar -delete - - if [ "${INCLUDETARBALL}" = 'yes' ]; then - echo Creating tarball - mv "${INCOMING}" "${TARBALLNAME}" - tar $TAROPTS -f "./dist/${TARBALLNAME}${TARBALLSUFFIX}" "${TARBALLNAME}" - mv "${TARBALLNAME}" "${INCOMING}" - fi -} - -createdirs -scale -find ./dist/ -type f -name \*.html -delete -template index index ./dist -generate -tarball - |
