From 3d23d6bc29dcbf714c916281091ebc594d3bc667 Mon Sep 17 00:00:00 2001 From: "Paul Buetow (mars.fritz.box)" Date: Fri, 27 Dec 2013 13:07:33 +0100 Subject: some version which does not work yet --- src/photoalbum | 50 +++++++++++++++++++++++++++++++++++++-------- src/photoalbum.default.conf | 4 +++- 2 files changed, 44 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/photoalbum b/src/photoalbum index d020446..fec60ab 100755 --- a/src/photoalbum +++ b/src/photoalbum @@ -1,7 +1,6 @@ #!/bin/bash -source photoalbum.conf - +declare -r ARG="${1}" ; shift declare -r VERSION='PHOTOALBUMVERSION' function createdirs () { @@ -27,7 +26,7 @@ function template () { } function scale () { - cd ${INCOMING} && find ./ -type f | sort | while read photo; do + cd ${INCOMING_DIR} && find ./ -type f | sort | while read photo; do if [ ! -f "../photos/${photo}" ]; then # Flatten directories / to __ @@ -54,7 +53,7 @@ function scale () { cd .. } -function generate () { +function makedist () { local num=${1} ; shift local name=page-${num} local -i i=0 @@ -126,8 +125,41 @@ function generate () { done } -createdirs -scale -find ./html -type f -name \*.html -delete -generate 1 -template index index . +function init () { + [ ! -d "${INCOMING_DIR}" ] && mkdir "${INCOMING_DIR}" && echo "Created ${INCOMING_DIR}" + [ -d ./dist ] && rm -rf ./dist && echo Cleaned up ./dist + mkdir ./dist && echo Created ./dist +} + +function generate () { + if [ ! -d "${INCOMING_DIR}" ]; then + echo "ERROR: You may run init first, no such directory: ${INCOMING_DIR}" >&2 + exit 1 + fi + + createdirs + scale + find ./html -type f -name \*.html -delete + makedist 1 + template index index . +} + +if [ -f ~/.photoalbumrc ]; then + source ~/.photoalbumrc +else + source /etc/default/photoalbum +fi + +case "${ARG}" in + init) + init + ;; + generate) + generate + ;; + *) + usage + ;; +esac + + diff --git a/src/photoalbum.default.conf b/src/photoalbum.default.conf index defd59e..e38b2ad 100644 --- a/src/photoalbum.default.conf +++ b/src/photoalbum.default.conf @@ -6,5 +6,7 @@ declare -i GEOMETRY=800 declare -i MAXPREVIEWS=100 declare -r TITLE='A simple Photoalbum' -declare -r INCOMING=./incoming +declare -r INCOMING_DIR=./incoming + +declare -r TEMPLATE_DIR=/usr/share/photoalbum/templates -- cgit v1.2.3