diff options
| author | admin (centauri.fritz.box) <puppet@mx.buetow.org> | 2014-05-17 13:08:27 +0200 |
|---|---|---|
| committer | admin (centauri.fritz.box) <puppet@mx.buetow.org> | 2014-05-17 13:08:27 +0200 |
| commit | 27eb43d176a8eb8218dd05f0b0dadbc110311607 (patch) | |
| tree | 9a7f2f7a35dd1553e02397fb97c3dc0853a66c6d | |
| parent | a7344846c22ca257701d4572bd631b9afd6ace1a (diff) | |
| parent | 5d975e3c1edd86f372ba1fadce35128c873e8493 (diff) | |
Merge branch 'master' of git.buetow.org:/git/photoalbum
25 files changed, 249 insertions, 258 deletions
@@ -1 +1 @@ -0.3.0 +0.4.1 diff --git a/debian/changelog b/debian/changelog index 35267b3..337c81b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,25 @@ +photoalbum (0.4.1) stable; urgency=low + + * Fix the version string + + -- Paul Buetow <paul@buetow.org> Tue, 13 May 2014 22:16:57 +0200 + +photoalbum (0.4.0) stable; urgency=low + + * Support of sub-albums including album overview page + * Add makemake argument + * Remove all argument + * Dont scale image if destination already exists + * Major refactoring of the bash code + + -- Paul Buetow <paul@buetow.org> Tue, 13 May 2014 22:09:28 +0200 + +photoalbum (0.3.1develop) stable; urgency=low + + * Dev version + + -- Paul Buetow <paul@buetow.org> Wed, 07 May 2014 14:58:51 +0200 + photoalbum (0.3.0) stable; urgency=low * Add another template set: minimal diff --git a/docs/photoalbum.1 b/docs/photoalbum.1 index c518477..70c217d 100644 --- a/docs/photoalbum.1 +++ b/docs/photoalbum.1 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "PHOTOALBUM 1" -.TH PHOTOALBUM 1 "2014-02-16" "photoalbum 0.3.0" "User Commands" +.TH PHOTOALBUM 1 "2014-05-13" "photoalbum 0.4.1" "User Commands" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -133,30 +133,26 @@ photoalbum \- photoalbum is a minimal bash script for linux to generate static web photo albums. .SH "SYNOPSIS" .IX Header "SYNOPSIS" -photoalbum clean|init|version|generate|all [rcfile] +photoalbum clean|version|generate [rcfile] +photoalbum makemake .IP "clean" 4 .IX Item "clean" Cleans up the working space -.IP "init" 4 -.IX Item "init" -Initializes the working space .IP "version" 4 .IX Item "version" Prints out the version .IP "generate" 4 .IX Item "generate" Generates the static photoalbum -.IP "all" 4 -.IX Item "all" -This just runs 'clean init generate' right after another. +.IP "makemake" 4 +.IX Item "makemake" +Creates a Makefile and photoalbumrc in the current working directory. .SS "\s-1RCFILE\s0" .IX Subsection "RCFILE" .SS "\s-1TUTORIAL\s0" .IX Subsection "TUTORIAL" * See if /etc/default/photoalbum fits your needs. If not, copy /etc/default/photoalbum to ~/.photoalbumrc in order to customize it. .PP -* Run 'photoalbum init' -.PP * Copy all images wanted to the incoming folder (see config file) .PP * Run 'photoalbum generate' diff --git a/docs/photoalbum.pod b/docs/photoalbum.pod index 791de48..242860f 100644 --- a/docs/photoalbum.pod +++ b/docs/photoalbum.pod @@ -4,7 +4,8 @@ photoalbum - photoalbum is a minimal bash script for linux to generate static we =head1 SYNOPSIS -photoalbum clean|init|version|generate|all [rcfile] +photoalbum clean|version|generate [rcfile] +photoalbum makemake =over @@ -12,10 +13,6 @@ photoalbum clean|init|version|generate|all [rcfile] Cleans up the working space -=item init - -Initializes the working space - =item version Prints out the version @@ -24,9 +21,9 @@ Prints out the version Generates the static photoalbum -=item all +=item makemake -This just runs 'clean init generate' right after another. +Creates a Makefile and photoalbumrc in the current working directory. =back @@ -36,8 +33,6 @@ This just runs 'clean init generate' right after another. * See if /etc/default/photoalbum fits your needs. If not, copy /etc/default/photoalbum to ~/.photoalbumrc in order to customize it. -* Run 'photoalbum init' - * Copy all images wanted to the incoming folder (see config file) * Run 'photoalbum generate' diff --git a/docs/photoalbum.txt b/docs/photoalbum.txt index fbb2d32..093e3a4 100644 --- a/docs/photoalbum.txt +++ b/docs/photoalbum.txt @@ -3,29 +3,26 @@ NAME static web photo albums. SYNOPSIS - photoalbum clean|init|version|generate|all [rcfile] + photoalbum clean|version|generate [rcfile] photoalbum makemake clean Cleans up the working space - init - Initializes the working space - version Prints out the version generate Generates the static photoalbum - all This just runs 'clean init generate' right after another. + makemake + Creates a Makefile and photoalbumrc in the current working + directory. RCFILE TUTORIAL * See if /etc/default/photoalbum fits your needs. If not, copy /etc/default/photoalbum to ~/.photoalbumrc in order to customize it. - * Run 'photoalbum init' - * Copy all images wanted to the incoming folder (see config file) * Run 'photoalbum generate' diff --git a/share/templates/default/footer.tmpl b/share/templates/default/footer.tmpl index 0de72ce..a6b5c78 100644 --- a/share/templates/default/footer.tmpl +++ b/share/templates/default/footer.tmpl @@ -5,12 +5,12 @@ END if [ "${TARBALL_INCLUDE}" = 'yes' ]; then cat <<END -Download all photos in original size <a href='../${TARBALL_NAME}'>here</a><br /><br /> +Download all photos in original size <a href='${backhref}/${tarball_name}'>here</a><br /><br /> END fi cat <<END -Page generated at $(date) using Bash, ImageMagick and Git at $(uname); <photoalbum@mx.buetow.org> +Page generated at $(date) using Bash and ImageMagick at $(uname); <photoalbum@mx.buetow.org> </body> </html> END diff --git a/share/templates/default/header.tmpl b/share/templates/default/header.tmpl index b21a200..b25143b 100644 --- a/share/templates/default/header.tmpl +++ b/share/templates/default/header.tmpl @@ -1,24 +1,28 @@ +if [ "${is_subalbum}" = yes ]; then + GOTO_OVERVIEW="<br /><br /><a href='${backhref}/index.html'>Go to Album overview</a>" +fi cat <<END <html> <head> -<title>$TITLE</title> +<title>${TITLE}</title> <style type="text/css"> - body { - background-color: #000000; - color: #FFFFFF; - font-family: verdana, sans-serif; - } - a { - color: #FFFFFF; - } - hr { - color: #FFFFFF; - background-color: #FFFFFF; - height: 1px; - } + body { + background-color: #000000; + color: #FFFFFF; + font-family: verdana, sans-serif; + width: 100%; + } + a { + color: #FFFFFF; + } + hr { + color: #FFFFFF; + background-color: #FFFFFF; + height: 1px; + } </style> </head> <body> -$TITLE +${TITLE} ${GOTO_OVERVIEW} <hr /> END diff --git a/share/templates/default/index-preview.tmpl b/share/templates/default/index-preview.tmpl new file mode 100644 index 0000000..a4cc0a4 --- /dev/null +++ b/share/templates/default/index-preview.tmpl @@ -0,0 +1,6 @@ +cat <<END +<h2>Album ${album} (${description})</h2> +<a name='${album}' href='${album}/index.html'> + <img border='0' src='${backhref}/${random_thumb}' /> +</a> +END diff --git a/share/templates/default/index.tmpl b/share/templates/default/index.tmpl deleted file mode 100644 index 2ec99d7..0000000 --- a/share/templates/default/index.tmpl +++ /dev/null @@ -1,12 +0,0 @@ -cat <<END -<html> -<head> -<title>$TITLE</title> -<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"> -<meta http-equiv="refresh" content="0; URL=./html/page-1.html"> -</head> -<body> -Redirecting to Page 1 -</body> -</html> -END diff --git a/share/templates/default/next.tmpl b/share/templates/default/next.tmpl index a7f7c76..f943bca 100644 --- a/share/templates/default/next.tmpl +++ b/share/templates/default/next.tmpl @@ -1,4 +1,4 @@ cat <<END <br /> -<a href='${next}.html'>Next $MAXPREVIEWS pictures</a> +<a href='${next}.html'>Next ${MAXPREVIEWS} pictures of current Album</a> END diff --git a/share/templates/default/prev.tmpl b/share/templates/default/prev.tmpl index bdabae2..62d5a35 100644 --- a/share/templates/default/prev.tmpl +++ b/share/templates/default/prev.tmpl @@ -1,4 +1,4 @@ cat <<END -<a href='${prev}.html'>Previous $MAXPREVIEWS pictures</a> +<a href='${prev}.html'>Previous ${MAXPREVIEWS} pictures of current Album</a> <p align='right'> END diff --git a/share/templates/default/preview.tmpl b/share/templates/default/preview.tmpl index a5e4bdc..feaa1cf 100644 --- a/share/templates/default/preview.tmpl +++ b/share/templates/default/preview.tmpl @@ -1,3 +1,5 @@ cat <<END -<a name='$photo' href='../html/${num}-${i}.html'><img border='0' src='../thumbs/$photo' /></a> +<a name='${photo}' href='${backhref}/${html_dir}/${num}-${i}.html'> + <img border='0' src='${backhref}/${thumbs_dir}/${photo}' /> +</a> END diff --git a/share/templates/default/redirect.tmpl b/share/templates/default/redirect.tmpl index 8edfe1c..aaf95c9 100644 --- a/share/templates/default/redirect.tmpl +++ b/share/templates/default/redirect.tmpl @@ -1,7 +1,7 @@ cat <<END <html> <head> -<meta http-equiv='refresh' content='0; url=${redirectpage}.html'> +<meta http-equiv='refresh' content='0; url=${redirect_page}.html'> </head> <body> </body> diff --git a/share/templates/default/view.tmpl b/share/templates/default/view.tmpl index abf577a..04962b5 100644 --- a/share/templates/default/view.tmpl +++ b/share/templates/default/view.tmpl @@ -4,9 +4,11 @@ cat <<END <a href="${num}-$((i+1)).html">>>></a> <br /> <br /> -<a href="${num}-$((i+1)).html"><img border='0' src='../photos/$photo' /></a> +<a href="${num}-$((i+1)).html"> + <img border='0' src='${backhref}/${photos_dir}/${photo}' /> +</a> <br /> <br /> -<a href="../photos/$photo">Direct link</a> -<h3>$photo</h3> +<a href="${backhref}/${photos_dir}/${photo}">Direct link</a> +<h3>${photo}</h3> END diff --git a/share/templates/minimal/footer.tmpl b/share/templates/minimal/footer.tmpl deleted file mode 100644 index 6473552..0000000 --- a/share/templates/minimal/footer.tmpl +++ /dev/null @@ -1,4 +0,0 @@ -cat <<END -</body> -</html> -END diff --git a/share/templates/minimal/header-first-add.tmpl b/share/templates/minimal/header-first-add.tmpl deleted file mode 100644 index f11a346..0000000 --- a/share/templates/minimal/header-first-add.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -cat <<END -<p align='left'> -END diff --git a/share/templates/minimal/header.tmpl b/share/templates/minimal/header.tmpl deleted file mode 100644 index 8b20b53..0000000 --- a/share/templates/minimal/header.tmpl +++ /dev/null @@ -1,22 +0,0 @@ -cat <<END -<html> -<head> -<title>$TITLE</title> -<style type="text/css"> - body { - background-color: #000000; - color: #FFFFFF; - font-family: verdana, sans-serif; - } - a { - color: #FFFFFF; - } - hr { - color: #FFFFFF; - background-color: #FFFFFF; - height: 1px; - } -</style> -</head> -<body> -END diff --git a/share/templates/minimal/index.tmpl b/share/templates/minimal/index.tmpl deleted file mode 100644 index 2ec99d7..0000000 --- a/share/templates/minimal/index.tmpl +++ /dev/null @@ -1,12 +0,0 @@ -cat <<END -<html> -<head> -<title>$TITLE</title> -<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"> -<meta http-equiv="refresh" content="0; URL=./html/page-1.html"> -</head> -<body> -Redirecting to Page 1 -</body> -</html> -END diff --git a/share/templates/minimal/next.tmpl b/share/templates/minimal/next.tmpl deleted file mode 100644 index a7f7c76..0000000 --- a/share/templates/minimal/next.tmpl +++ /dev/null @@ -1,4 +0,0 @@ -cat <<END -<br /> -<a href='${next}.html'>Next $MAXPREVIEWS pictures</a> -END diff --git a/share/templates/minimal/prev.tmpl b/share/templates/minimal/prev.tmpl deleted file mode 100644 index 64d15d8..0000000 --- a/share/templates/minimal/prev.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -cat <<END -<a href='${prev}.html'>Previous $MAXPREVIEWS pictures</a> -END diff --git a/share/templates/minimal/preview.tmpl b/share/templates/minimal/preview.tmpl deleted file mode 100644 index a5e4bdc..0000000 --- a/share/templates/minimal/preview.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -cat <<END -<a name='$photo' href='../html/${num}-${i}.html'><img border='0' src='../thumbs/$photo' /></a> -END diff --git a/share/templates/minimal/redirect.tmpl b/share/templates/minimal/redirect.tmpl deleted file mode 100644 index 8edfe1c..0000000 --- a/share/templates/minimal/redirect.tmpl +++ /dev/null @@ -1,9 +0,0 @@ -cat <<END -<html> -<head> -<meta http-equiv='refresh' content='0; url=${redirectpage}.html'> -</head> -<body> -</body> -</html> -END diff --git a/share/templates/minimal/view.tmpl b/share/templates/minimal/view.tmpl deleted file mode 100644 index c93a82b..0000000 --- a/share/templates/minimal/view.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -cat <<END -<a href="${num}-$((i+1)).html"><img border='0' src='../photos/$photo' /></a> -END diff --git a/src/photoalbum.default.conf b/src/photoalbum.default.conf index 2a85fc7..160a8ed 100644 --- a/src/photoalbum.default.conf +++ b/src/photoalbum.default.conf @@ -8,6 +8,8 @@ MAXPREVIEWS=100 # Diverse directories, need to be full paths, not relative! INCOMING_DIR=$(pwd)/incoming +# Set to yes if per directory sub-albums are wanted +SUB_ALBUMS=no DIST_DIR=$(pwd)/dist TEMPLATE_DIR=/usr/share/photoalbum/templates/default #TEMPLATE_DIR=/usr/share/photoalbum/templates/minimal diff --git a/src/photoalbum.sh b/src/photoalbum.sh index dc536b6..a047339 100755 --- a/src/photoalbum.sh +++ b/src/photoalbum.sh @@ -1,120 +1,85 @@ #!/bin/bash -# photoalbum (c) 2011 - 2014 by Paul Buetow +# photoalbum (c) 2011 - 2014 by Paul C. Buetow # http://photoalbum.buetow.org -declare -r ARG1="${1}"; shift -declare RC="${1}" ; shift - declare -r VERSION='PHOTOALBUMVERSION' declare -r DEFAULTRC=/etc/default/photoalbum +declare -r ARG1="${1}" ; shift +declare RC_FILE="${1}" ; shift -if [ -z "${RC}" ]; then - RC="${DEFAULTRC}" -fi - -if [ ! -f "${RC}" ]; then - echo "Error: Can not find config file ${RC}" >&2 - exit 1 -fi - -usage() { +function usage() { cat - <<USAGE >&2 Usage: $0 clean|init|version|generate|all [rcfile] USAGE } -init() { - for dir in "${INCOMING_DIR}" "${DIST_DIR}/photos" "${DIST_DIR}/thumbs" "${DIST_DIR}/html"; do - [ -d "${dir}" ] || mkdir -vp "${dir}" - done +function makemake() { + [ ! -f ./photoalbumrc ] && cp /etc/default/photoalbum ./photoalbumrc + cat <<MAKEFILE > ./Makefile +all: + photoalbum generate photoalbumrc +clean: + photoalbum clean photoalbumrc +MAKEFILE + echo You may now customize ./photoalbumrc and run make } -clean() { - echo "Not deleting ${INCOMING_DIR}" - [ -d "${DIST_DIR}" ] && rm -Rf "${DIST_DIR}" -} - -tarball() { +function tarball() { # Cleanup tarball from prev run if any find "${DIST_DIR}" -maxdepth 1 -type f -name \*.tar -delete + declare -r base=$(basename "${INCOMING_DIR}") - if [ "${TARBALL_INCLUDE}" = yes ]; then - local -r BASE=$(basename "${INCOMING_DIR}") - - echo "Creating tarball ${DIST_DIR}/${TARBALL_NAME} from ${INCOMING_DIR}" - cd $(dirname "${INCOMING_DIR}") - tar $TAR_OPTS -f "${DIST_DIR}/${TARBALL_NAME}" "${BASE}" - cd - &>/dev/null - fi + echo "Creating tarball ${DIST_DIR}/${tarball_name} from ${INCOMING_DIR}" + cd $(dirname "${INCOMING_DIR}") + tar $TAR_OPTS -f "${DIST_DIR}/${tarball_name}" "${base}" + cd - &>/dev/null } -generate() { - if [ ! -d "${INCOMING_DIR}" ]; then - echo "ERROR: You may run init first, no such directory: ${INCOMING_DIR}" >&2 - exit 1 - fi - if [ ! -d "${DIST_DIR}" ]; then - echo "ERROR: You may run init first, no such directory: ${DIST_DIR}" >&2 - exit 1 - fi - - if [ "${TARBALL_INCLUDE}" = yes ]; then - local -r BASE=$(basename "${INCOMING_DIR}") - local -r NOW=$(date +'%Y-%m-%d-%H%M%S') - # New global variable - TARBALL_NAME="${BASE}-${NOW}${TARBALL_SUFFIX}" - fi - - scale - find "${DIST_DIR}/html" -type f -name \*.html -delete - makedist 1 - template index ../index - tarball -} +function template() { + declare -r template=${1} ; shift + declare -r html=${1} ; shift + declare -r dist_html="${DIST_DIR}/${html_dir}" -template() { - local -r template=${1} ; shift - local -r html=${1} ; shift - - source "${TEMPLATE_DIR}/${template}.tmpl" >> "${DIST_DIR}/html/${html}.html" + # Creating ${dist_html}/${html}.html from ${template}.tmpl + [ ! -d "${dist_html}" ] && mkdir -p "${dist_html}" + source "${TEMPLATE_DIR}/${template}.tmpl" >> "${dist_html}/${html}" } -scale() { - cd "${INCOMING_DIR}" && find ./ -type f | sort | while read photo; do - photo=$(sed 's#^\./##' <<< "${photo}") - - if [ ! -f "${DIST_DIR}/photos/${photo}" ]; then - # Flatten directories / to __ - if [[ "${photo}" =~ / ]]; then - destphoto="${photo//\//__}" - else - destphoto="${photo}" - fi +function scalephotos() { + cd "${INCOMING_DIR}" && find ./ -type f | sort | + while read photo; do + declare photo=$(sed 's#^\./##' <<< "${photo}") + declare destphoto="${DIST_DIR}/photos/${photo}" + declare destphoto_nospace=${destphoto// /_} - echo "Scaling ${photo} to ${DIST_DIR}/photos/${destphoto}" + declare dirname=$(dirname "${destphoto}") + [ ! -d "${dirname}" ] && mkdir -p "${dirname}" + if [ ! -f "${destphoto_nospace}" ]; then + echo "Scaling ${photo} to ${destphoto_nospace}" convert -auto-orient \ - -geometry ${GEOMETRY} "${photo}" "${DIST_DIR}/photos/${destphoto}" + -geometry ${GEOMETRY} "${photo}" "${destphoto_nospace}" fi done - - echo 'Removing spaces from file names' - find "${DIST_DIR}/photos" -type f -name '* *' | while read file; do - rename 's/ /_/g' "${file}" - done } -makedist() { - local num=${1} ; shift - local name=page-${num} - local -i i=0 +function albumhtml() { + declare photos_dir="${1}" ; shift + declare html_dir="${1}" ; shift + declare thumbs_dir="${1}" ; shift + declare backhref="${1}" ; shift - template header ${name} - template header-first-add ${name} + declare -i num=1 + declare -i i=0 - cd "${DIST_DIR}/photos" && find ./ -type f | sort | sed 's;^\./;;' | + declare name=page-${num} + + template header ${name}.html + template header-first-add ${name}.html + + cd "${DIST_DIR}/${photos_dir}" && find ./ -type f | sort | sed 's;^\./;;' | while read photo; do : $(( i++ )) @@ -122,34 +87,38 @@ makedist() { i=1 : $(( num++ )) - next=page-${num} - template next ${name} - template footer ${name} + declare next=page-${num} + template next ${name}.html + template footer ${name}.html - prev=${name} - name=${next} - template header ${name} - template prev ${name} + declare prev=${name} + declare name=${next} + template header ${name}.html + template prev ${name}.html fi # Preview page - template preview ${name} + template preview ${name}.html # View page - template header ${num}-${i} - template view ${num}-${i} - template footer ${num}-${i} + template header ${num}-${i}.html + template view ${num}-${i}.html + template footer ${num}-${i}.html + + if [ ! -f "${DIST_DIR}/${thumbs_dir}/${photo}" ]; then + dirname=$(dirname "${DIST_DIR}/${thumbs_dir}/${photo}") + [ ! -d "${dirname}" ] && mkdir -p "${dirname}" - if [ ! -f "${DIST_DIR}/thumbs/${photo}" ]; then - echo "Creating thumb for ${photo}"; + echo "Creating thumb ${DIST_DIR}/${thumbs_dir}/${photo}"; convert -geometry x${THUMBGEOMETRY} "${photo}" \ - "${DIST_DIR}/thumbs/${photo}" + "${DIST_DIR}/${thumbs_dir}/${photo}" fi done - template footer $(cd "${DIST_DIR}/html";ls -t page-*.html | head -n 1 | sed 's/.html//') + template footer \ + $(cd "${DIST_DIR}/${html_dir}";ls -t page-*.html | head -n 1) - cd "${DIST_DIR}/html" && ls *.html | grep -v page- | cut -d'-' -f1 | uniq | + cd "${DIST_DIR}/${html_dir}" && ls *.html | grep -v page- | cut -d'-' -f1 | uniq | while read prefix; do declare page=$(ls -t ${prefix}-*.html | head -n 1 | sed 's#\(.*\)-.*.html#\1#') @@ -160,49 +129,120 @@ makedist() { declare prevredirect=${page}-0 declare nextredirect=${page}-$((lastview+1)) - redirectpage=$(( page-1 ))-${MAXPREVIEWS} - template redirect ${prevredirect} + declare redirect_page=$(( page-1 ))-${MAXPREVIEWS} + template redirect ${prevredirect}.html if [ ${lastview} -eq ${MAXPREVIEWS} ]; then - redirectpage=$(( page+1 ))-1 - else - redirectpage=${page}-${lastview} - template redirect 0-${MAXPREVIEWS} + declare redirect_page=$(( page+1 ))-1 - redirectpage=1-1 + else + declare redirect_page=${page}-${lastview} + template redirect 0-${MAXPREVIEWS}.html + redirect_page=1-1 fi + template redirect ${nextredirect}.html + done - template redirect ${nextredirect} + # Create per album index/redirect page + declare redirect_page=page-1 + template redirect index.html +} + +function albumindexhtml() { + declare -a dirs=( "${1}" ) + declare is_subalbum=no + declare html_dir=html + declare backhref=.. + + template header index.html + template header-first-add index.html + + for dir in ${dirs[*]}; do + declare basename=$(basename "$dir") + declare album=$basename + declare thumbs_dir="${DIST_DIR}/thumbs/${basename}" + declare pictures=$(ls "${thumbs_dir}" | wc -l) + declare random_num=$(( 1 + $RANDOM % $pictures )) + declare pages=$(( $pictures / $MAXPREVIEWS + 1 )) + + declare random_thumb="./thumbs/${basename}"/$(find \ + "${thumbs_dir}" -type f -printf "%f\n" | + head -n ${random_num} | tail -n 1) + + [ ${pages} -gt 1 ] && declare s=s || declare s='' + declare description="${pictures} pictures / ${pages} page${s}" + template index-preview index.html done + + template footer index.html +} + +function generate() { + if [ ! -d "${INCOMING_DIR}" ]; then + echo "ERROR: You have to create ${INCOMING_DIR} first" >&2 + exit 1 + fi + + if [ "${TARBALL_INCLUDE}" = yes ]; then + declare -r base=$(basename "${INCOMING_DIR}") + declare -r now=$(date +'%Y-%m-%d-%H%M%S') + declare -r tarball_name="${base}-${now}${TARBALL_SUFFIX}" + fi + + scalephotos + + find "${DIST_DIR}" -type f -name \*.html -delete + declare -a dirs=( $(find "${DIST_DIR}/photos" \ + -mindepth 1 -maxdepth 1 -type d | sort) ) + + # Figure out wether we want sub-albums or not + if [[ "${SUB_ALBUMS}" != yes || ${#dirs[*]} -eq 0 ]]; then + declare is_subalbum=no + albumhtml photos html thumbs .. + + else + declare is_subalbum=yes + for dir in ${dirs[*]}; do + declare basename=$(basename "${dir}") + albumhtml \ + "photos/${basename}" "html/${basename}" "thumbs/${basename}" ../.. + done + + # Create an album selection screen + albumindexhtml "${dirs[*]}" + fi + + # Create top level index/redirect page + declare html_dir=./ + declare redirect_page=./html/index + template redirect index.html + + if [ "${TARBALL_INCLUDE}" = yes ]; then + tarball + fi } -source "${RC}" +if [ -z "${RC_FILE}" ]; then + if [ -f ~/.photoalbumrc ]; then + RC_FILE=~/.photoalbumrc + else + RC_FILE="${DEFAULTRC}" + fi +fi -if [ -f ~/.photoalbumrc ]; then - source ~/.photoalbumrc +if [ ! -f "${RC_FILE}" ]; then + echo "Error: Can not find config file ${RC_FILE}" >&2 + exit 1 fi +source "${RC_FILE}" + case "${ARG1}" in - all) - clean - init - generate - ;; - init) - init - ;; - clean) - clean - ;; - generate) - generate - ;; - version) - echo "This is Photoalbum Version ${VERSION}" - ;; - *) - usage - ;; + clean) [ -d "${DIST_DIR}" ] && rm -Rf "${DIST_DIR}";; + generate) generate;; + version) echo "This is Photoalbum Version ${VERSION}";; + makemake) makemake;; + *) usage;; esac exit 0 |
