summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/templates/default/footer.tmpl4
-rw-r--r--share/templates/default/header.tmpl31
-rw-r--r--share/templates/default/index.tmpl2
-rw-r--r--share/templates/default/preview.tmpl4
-rw-r--r--share/templates/default/view.tmpl6
-rw-r--r--share/templates/minimal/footer.tmpl4
-rw-r--r--share/templates/minimal/header-first-add.tmpl3
-rw-r--r--share/templates/minimal/header.tmpl22
-rw-r--r--share/templates/minimal/index.tmpl12
-rw-r--r--share/templates/minimal/next.tmpl4
-rw-r--r--share/templates/minimal/prev.tmpl3
-rw-r--r--share/templates/minimal/preview.tmpl3
-rw-r--r--share/templates/minimal/redirect.tmpl9
-rw-r--r--share/templates/minimal/view.tmpl3
-rwxr-xr-xsrc/photoalbum.sh84
15 files changed, 80 insertions, 114 deletions
diff --git a/share/templates/default/footer.tmpl b/share/templates/default/footer.tmpl
index 0de72ce..18e3512 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); &lt;photoalbum@mx.buetow.org&gt;
+Page generated at $(date) using Bash and ImageMagick at $(uname); &lt;photoalbum@mx.buetow.org&gt;
</body>
</html>
END
diff --git a/share/templates/default/header.tmpl b/share/templates/default/header.tmpl
index b21a200..3c0a2e7 100644
--- a/share/templates/default/header.tmpl
+++ b/share/templates/default/header.tmpl
@@ -1,24 +1,27 @@
+if [ "$IS_SUB" = yes ]; then
+ TOP="<br /><a href='${BACKHREF}/index.html'>Go to top</a>"
+fi
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;
- }
+ 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>
-$TITLE
+$TITLE $TOP
<hr />
END
diff --git a/share/templates/default/index.tmpl b/share/templates/default/index.tmpl
index 2ec99d7..ecfb9f6 100644
--- a/share/templates/default/index.tmpl
+++ b/share/templates/default/index.tmpl
@@ -3,7 +3,7 @@ cat <<END
<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">
+<meta http-equiv="refresh" content="0; URL=./${html}/page-1.html">
</head>
<body>
Redirecting to Page 1
diff --git a/share/templates/default/preview.tmpl b/share/templates/default/preview.tmpl
index a5e4bdc..646fc5c 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/view.tmpl b/share/templates/default/view.tmpl
index abf577a..43930de 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">&gt;&gt;&gt;</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>
+<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.sh b/src/photoalbum.sh
index 6180571..b639b6b 100755
--- a/src/photoalbum.sh
+++ b/src/photoalbum.sh
@@ -69,16 +69,28 @@ function generate() {
makescale
find "${DIST_DIR}/html" -type f -name \*.html -delete
- makehtml "${DIST_DIR}/photos" "${DIST_DIR}/html"
- template index ../index
+
+ # Figure out wether we want sub-albums or not
+ dirs=$(find "${DIST_DIR}/photos" -mindepth 1 -maxdepth 1 -type d | head | wc -l)
+ if [ ${dirs} -eq 0 ]; then
+ makehtml photos html thumbs ..
+ else
+ find "${DIST_DIR}/photos" -mindepth 1 -maxdepth 1 -type d |
+ while read dir; do
+ basename=$(basename "${dir}")
+ makehtml "photos/${basename}" "html/${basename}" "thumbs/${basename}" ../..
+ done
+ fi
tarball
}
function template() {
- local -r template=${1} ; shift
- local -r html=${1} ; shift
+ local -r template=${1} ; shift
+ local -r html=${1} ; shift
+ local -r dist_html=${1} ; shift
- source "${TEMPLATE_DIR}/${template}.tmpl" >> "${DIST_DIR}/html/${html}.html"
+ echo "Creating ${dist_html}/${html}.html from ${template}.tmpl"
+ source "${TEMPLATE_DIR}/${template}.tmpl" >> "${dist_html}/${html}.html"
}
function makescale() {
@@ -101,16 +113,21 @@ function makescale() {
}
function makehtml() {
- local dist_photo="${1}" ; shift
- local dist_html="${1}" ; shift
+ PHOTOS_DIR="${1}" ; shift
+ HTML_DIR="${1}" ; shift
+ THUMBS_DIR="${1}"; shift
+ BACKHREF="${1}" ; shift
+ local -r dist_html="${DIST_DIR}/${HTML_DIR}"
local -i num=1
local -i i=0
local name=page-${num}
- template header ${name}
- template header-first-add ${name}
+ [ ! -d "${dist_html}" ] && mkdir -p "${dist_html}"
+
+ template header ${name} "${dist_html}"
+ template header-first-add ${name} "${dist_html}"
- cd "${dist_photo}" && find ./ -type f | sort | sed 's;^\./;;' |
+ cd "${DIST_DIR}/${PHOTOS_DIR}" && find ./ -type f | sort | sed 's;^\./;;' |
while read photo; do
: $(( i++ ))
@@ -119,35 +136,36 @@ function makehtml() {
: $(( num++ ))
next=page-${num}
- template next ${name}
- template footer ${name}
+ template next ${name} "${dist_html}"
+ template footer ${name} "${dist_html}"
prev=${name}
name=${next}
- template header ${name}
- template prev ${name}
+ template header ${name} "${dist_html}"
+ template prev ${name} "${dist_html}"
fi
# Preview page
- template preview ${name}
+ template preview ${name} "${dist_html}"
# View page
- template header ${num}-${i}
- template view ${num}-${i}
- template footer ${num}-${i}
+ template header ${num}-${i} "${dist_html}"
+ template view ${num}-${i} "${dist_html}"
+ template footer ${num}-${i} "${dist_html}"
- if [ ! -f "${DIST_DIR}/thumbs/${photo}" ]; then
- echo "Creating thumb for ${photo}";
- dirname=$(dirname "${DIST_DIR}/thumbs/${photo}")
+ if [ ! -f "${DIST_DIR}/${THUMBS_DIR}/${photo}" ]; then
+ echo "Creating thumb ${DIST_DIR}/${THUMBS_DIR}/${photo}";
+ dirname=$(dirname "${DIST_DIR}/${THUMBS_DIR}/${photo}")
[ ! -d "${dirname}" ] && mkdir -p "${dirname}"
convert -geometry x${THUMBGEOMETRY} "${photo}" \
- "${DIST_DIR}/thumbs/${photo}"
+ "${DIST_DIR}/${THUMBS_DIR}/${photo}"
else
- echo "Not creating thumb for ${photo}, already exists";
+ echo "Not creating thumb ${DIST_DIR}/${THUMBS_DIR}/${photo}, already exists";
fi
done
- template footer $(cd "${DIST_DIR}/html";ls -t page-*.html | head -n 1 | sed 's/.html//')
+ template footer $(cd "${dist_html}";ls -t page-*.html |
+ head -n 1 | sed 's/.html//') "${dist_html}"
cd "${dist_html}" && ls *.html | grep -v page- | cut -d'-' -f1 | uniq |
while read prefix; do
@@ -161,19 +179,21 @@ function makehtml() {
declare nextredirect=${page}-$((lastview+1))
redirectpage=$(( page-1 ))-${MAXPREVIEWS}
- template redirect ${prevredirect}
+ template redirect ${prevredirect} "${dist_html}"
if [ ${lastview} -eq ${MAXPREVIEWS} ]; then
redirectpage=$(( page+1 ))-1
else
redirectpage=${page}-${lastview}
- template redirect 0-${MAXPREVIEWS}
+ template redirect 0-${MAXPREVIEWS} "${dist_html}"
redirectpage=1-1
fi
- template redirect ${nextredirect}
+ template redirect ${nextredirect} "${dist_html}"
done
+
+ template index ../index "${dist_html}"
}
function makemake() {
@@ -187,10 +207,12 @@ MAKEFILE
echo You may now customize ./photoalbumrc and run make
}
-source "${RC}"
-
-if [ -f ~/.photoalbumrc ]; then
- source ~/.photoalbumrc
+if [ -f "${RC}" ]; then
+ source "${RC}"
+else
+ if [ -f ~/.photoalbumrc ]; then
+ source ~/.photoalbumrc
+ fi
fi
case "${ARG1}" in