summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Buetow (mars.fritz.box) <paul@buetow.org>2014-01-11 13:23:27 +0100
committerPaul Buetow (mars.fritz.box) <paul@buetow.org>2014-01-11 13:23:27 +0100
commitbae474ed42c3151658a75e250cd85bb573e02dfe (patch)
treec933fef60a87529d059292e3b81c74d611307930 /src
parent86c5276a3319163d8e183c6e91df1d30c00b5cb9 (diff)
New release
Diffstat (limited to 'src')
-rwxr-xr-xsrc/photoalbum.sh60
1 files changed, 31 insertions, 29 deletions
diff --git a/src/photoalbum.sh b/src/photoalbum.sh
index 85a1cab..38c6f09 100755
--- a/src/photoalbum.sh
+++ b/src/photoalbum.sh
@@ -1,30 +1,31 @@
-#!/bin/bash
+#!/bin/bash
-# photoalbum (c) 2011, 2012, 2013 by Paul Buetow
+# photoalbum (c) 2011 - 2014 by Paul Buetow
# http://photoalbum.buetow.org
declare -r ARG1="${1}" ; shift
declare -r VERSION='PHOTOALBUMVERSION'
+declare -r DEFAULTRC=/etc/default/photoalbum
-usage () {
+usage() {
cat - <<USAGE >&2
Usage:
$0 [clean|init|version|generate|all]
USAGE
}
-init () {
+init() {
for dir in "${INCOMING_DIR}" "${DIST_DIR}/photos" "${DIST_DIR}/thumbs" "${DIST_DIR}/html"; do
[ -d "${dir}" ] || mkdir -vp "${dir}"
done
}
-clean () {
+clean() {
echo "Not deleting ${INCOMING_DIR}"
[ -d "${DIST_DIR}" ] && rm -Rf "${DIST_DIR}"
}
-tarball () {
+tarball() {
# Cleanup tarball from prev run if any
find "${DIST_DIR}" -maxdepth 1 -type f -name \*.tar -delete
@@ -38,7 +39,7 @@ tarball () {
fi
}
-generate () {
+generate() {
if [ ! -d "${INCOMING_DIR}" ]; then
echo "ERROR: You may run init first, no such directory: ${INCOMING_DIR}" >&2
exit 1
@@ -62,41 +63,41 @@ generate () {
tarball
}
-template () {
+template() {
local -r template=${1} ; shift
local -r html=${1} ; shift
source "${TEMPLATE_DIR}/${template}.tmpl" >> "${DIST_DIR}/html/${html}.html"
}
-scale () {
+scale() {
cd "${INCOMING_DIR}" && find ./ -type f | sort | while read photo; do
- photo=$(sed 's#^\./##' <<< "${photo}")
+ photo=$(sed 's#^\./##' <<< "${photo}")
- if [ ! -f "${DIST_DIR}/photos/${photo}" ]; then
- # Flatten directories / to __
- if [[ "${photo}" =~ / ]]; then
- destphoto="${photo//\//__}"
- else
- destphoto="${photo}"
- fi
+ if [ ! -f "${DIST_DIR}/photos/${photo}" ]; then
+ # Flatten directories / to __
+ if [[ "${photo}" =~ / ]]; then
+ destphoto="${photo//\//__}"
+ else
+ destphoto="${photo}"
+ fi
- destphoto="${destphoto/./}"
+ destphoto="${destphoto/./}"
- echo "Scaling ${photo} to ${DIST_DIR}/photos/${destphoto}"
+ echo "Scaling ${photo} to ${DIST_DIR}/photos/${destphoto}"
- convert -auto-orient \
- -geometry ${GEOMETRY} "${photo}" "${DIST_DIR}/photos/${destphoto}"
- fi
-done
+ convert -auto-orient \
+ -geometry ${GEOMETRY} "${photo}" "${DIST_DIR}/photos/${destphoto}"
+ fi
+ done
-echo 'Removing spaces from file names'
-find "${DIST_DIR}/photos" -type f -name '* *' | while read file; do
-rename 's/ /_/g' "${file}"
-done
+ echo 'Removing spaces from file names'
+ find "${DIST_DIR}/photos" -type f -name '* *' | while read file; do
+ rename 's/ /_/g' "${file}"
+ done
}
-makedist () {
+makedist() {
local num=${1} ; shift
local name=page-${num}
local -i i=0
@@ -166,7 +167,7 @@ makedist () {
done
}
-source /etc/default/photoalbum
+source "${DEFAULTRC}"
if [ -f ~/.photoalbumrc ]; then
source ~/.photoalbumrc
@@ -195,4 +196,5 @@ case "${ARG1}" in
;;
esac
+exit 0