diff options
| -rwxr-xr-x | photoalbum.sh | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/photoalbum.sh b/photoalbum.sh index b263f41..983e314 100755 --- a/photoalbum.sh +++ b/photoalbum.sh @@ -7,16 +7,16 @@ source photoalbum.conf function createdirs () { for dir in photos thumbs html; do - [ -d $dir ] || mkdir -vp $dir + [ -d ${dir} ] || mkdir -vp ${dir} done } function template () { - local -r template=$1 + local -r template=${1} local -r html=$2 local destdir=$3 - if [ -z "$destdir" ]; then + if [ -z "${destdir}" ]; then destdir=html/ fi @@ -28,60 +28,60 @@ function template () { } function scale () { - cd $INCOMING && find ./ -type f | sort | while read photo; do - if [ ! -f "../photos/$photo" ]; then - echo "Scaling $photo" + cd ${INCOMING} && find ./ -type f | sort | while read photo; do + if [ ! -f "../photos/${photo}" ]; then + echo "Scaling ${photo}" convert -auto-orient \ - -geometry $GEOMETRY "$photo" "../photos/$photo" + -geometry ${GEOMETRY} "${photo}" "../photos/${photo}" fi done echo 'Removing spaces from file names' find ../photos -type f -name '* *' | while read file; do - rename 's/ /_/g' "$file" + rename 's/ /_/g' "${file}" done cd .. } function generate () { - local num=$1 + local num=${1} local name=page-${num} local -i i=0 - template header $name - template header-first-add $name + template header ${name} + template header-first-add ${name} - cd photos && find ./ -type f | sort | sed 's;^\./;;' | + cd photos && find ./ -type f | sort | sed 's;^\./;;' | while read photo; do : $(( i++ )) - if [ $i -gt $MAXPREVIEWS ]; then + if [ ${i} -gt ${MAXPREVIEWS} ]; then i=1 : $(( num++ )) next=page-${num} - template next $name - template footer $name + template next ${name} + template footer ${name} - prev=$name - name=$next - template header $name - template prev $name + prev=${name} + name=${next} + template header ${name} + template prev ${name} fi # Preview page - template preview $name + 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" + if [ ! -f "../thumbs/${photo}" ]; then + echo "Creating thumb for ${photo}"; + convert -geometry x${THUMBGEOMETRY} "${photo}" \ + "../thumbs/${photo}" fi done @@ -91,26 +91,28 @@ function generate () { ls html/*.html | grep -v page- | cut -d'-' -f1 | uniq | while read prefix; do - declare page=$(ls -t ${prefix}-*.html | \ - head -n 1 | sed 's#html/\(.*\)-.*.html#\1#') - declare lastview=$(ls -t ${prefix}-*.html | \ - head -n 1 | sed 's/.*-\(.*\).html/\1/') + declare page=$(ls -t ${prefix}-*.html | + head -n 1 | sed 's#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 + redirectpage=$(( page-1 ))-${MAXPREVIEWS} + template redirect ${prevredirect} - if [ $lastview -eq $MAXPREVIEWS ]; then + if [ ${lastview} -eq ${MAXPREVIEWS} ]; then redirectpage=$(( page+1 ))-1 else redirectpage=${page}-${lastview} - template redirect 0-$MAXPREVIEWS + template redirect 0-${MAXPREVIEWS} redirectpage=1-1 fi - template redirect $nextredirect + template redirect ${next}redirect done } |
