diff options
| -rw-r--r-- | share/templates/default/index.tmpl | 12 | ||||
| -rw-r--r-- | share/templates/default/redirect.tmpl | 2 | ||||
| -rwxr-xr-x | src/photoalbum.sh | 22 |
3 files changed, 17 insertions, 19 deletions
diff --git a/share/templates/default/index.tmpl b/share/templates/default/index.tmpl deleted file mode 100644 index ecfb9f6..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/redirect.tmpl b/share/templates/default/redirect.tmpl index 8edfe1c..8353e7b 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/src/photoalbum.sh b/src/photoalbum.sh index 8334872..50211d5 100755 --- a/src/photoalbum.sh +++ b/src/photoalbum.sh @@ -55,6 +55,7 @@ function generate() { 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 @@ -68,12 +69,13 @@ function generate() { fi makescale - find "${DIST_DIR}/html" -type f -name \*.html -delete + find "${DIST_DIR}" -type f -name \*.html -delete # Figure out wether we want sub-albums or not dirs=$(find "${DIST_DIR}/photos" -mindepth 1 -maxdepth 1 -type d | head | wc -l) if [[ "${SUB_ALBUMS}" != yes || ${dirs} -eq 0 ]]; then makehtml photos html thumbs .. + else find "${DIST_DIR}/photos" -mindepth 1 -maxdepth 1 -type d | while read dir; do @@ -81,6 +83,12 @@ function generate() { makehtml "photos/${basename}" "html/${basename}" "thumbs/${basename}" ../.. done fi + + # Create top level index/redirect page + HTML_DIR=./ + REDIRECT_PAGE=./html/index + template redirect index + tarball } @@ -114,6 +122,7 @@ function makescale() { } function makehtml() { + # First initialize some globals (used as template vars) PHOTOS_DIR="${1}" ; shift HTML_DIR="${1}" ; shift THUMBS_DIR="${1}" ; shift @@ -177,22 +186,23 @@ function makehtml() { declare prevredirect=${page}-0 declare nextredirect=${page}-$((lastview+1)) - redirectpage=$(( page-1 ))-${MAXPREVIEWS} + REDIRECT_PAGE=$(( page-1 ))-${MAXPREVIEWS} template redirect ${prevredirect} if [ ${lastview} -eq ${MAXPREVIEWS} ]; then - redirectpage=$(( page+1 ))-1 + REDIRECT_PAGE=$(( page+1 ))-1 else - redirectpage=${page}-${lastview} + REDIRECT_PAGE=${page}-${lastview} template redirect 0-${MAXPREVIEWS} - redirectpage=1-1 + REDIRECT_PAGE=1-1 fi template redirect ${nextredirect} done - template index ../index + REDIRECT_PAGE=page-1 + template redirect index } function makemake() { |
