summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow (mars.fritz.box) <paul@buetow.org>2013-12-29 17:57:36 +0100
committerPaul Buetow (mars.fritz.box) <paul@buetow.org>2013-12-29 17:57:36 +0100
commit448f785c5fba56ab3e5bf01b05e7827ed4321e6a (patch)
tree80ae5a03f1c3ab30fa126677277898c516cb7df3
parent9bf8f9ba9f5e957f77a894fb08235e3fe0904646 (diff)
theoretically i can include tarballs in photoalbums now
-rw-r--r--Makefile2
-rw-r--r--debian/changelog6
-rw-r--r--share/templates/footer.tmpl4
-rw-r--r--src/photoalbum.default.conf7
-rwxr-xr-xsrc/photoalbum.sh (renamed from src/photoalbum)90
5 files changed, 72 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index e89e992..c34a8ce 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ NAME=photoalbum
all: version documentation build
build:
test ! -d ./bin && mkdir ./bin || exit 0
- sed "s/PHOTOALBUMVERSION/$$(cat .version)/" src/$(NAME) > ./bin/$(NAME)
+ sed "s/PHOTOALBUMVERSION/$$(cat .version)/" src/$(NAME).sh > ./bin/$(NAME)
chmod 0755 ./bin/$(NAME)
install:
test ! -d $(DESTDIR)/usr/bin && mkdir -p $(DESTDIR)/usr/bin || exit 0
diff --git a/debian/changelog b/debian/changelog
index e8d5d96..674de25 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+photoalbum (0.1.3-develop) UNRELEASED; urgency=low
+
+ * Initial develop version
+
+ -- Paul Buetow <paul@buetow.org> Sun, 29 Dec 2013 17:40:51 +0100
+
photoalbum (0.1.2) stable; urgency=low
* add copyright header
diff --git a/share/templates/footer.tmpl b/share/templates/footer.tmpl
index fa9f675..0de72ce 100644
--- a/share/templates/footer.tmpl
+++ b/share/templates/footer.tmpl
@@ -3,9 +3,9 @@ cat <<END
<hr />
END
-if [ "${INCLUDETARBALL}" = 'yes' ]; then
+if [ "${TARBALL_INCLUDE}" = 'yes' ]; then
cat <<END
-Download all photos in original size <a href='../${TARBALLNAME}${TARBALLSUFFIX}'>here</a><br /><br />
+Download all photos in original size <a href='../${TARBALL_NAME}'>here</a><br /><br />
END
fi
diff --git a/src/photoalbum.default.conf b/src/photoalbum.default.conf
index 20ac490..3e8cf10 100644
--- a/src/photoalbum.default.conf
+++ b/src/photoalbum.default.conf
@@ -11,6 +11,13 @@ INCOMING_DIR=$(pwd)/incoming
DIST_DIR=$(pwd)/dist
TEMPLATE_DIR=/usr/share/photoalbum/templates
+# Includes a .tar of the incoming dir in the dist, can be yes or no
+declare -r TARBALL_INCLUDE=yes
+
+# If INCLUDETARBALL=yes, set the Name of the tarball
+declare -r TARBALL_SUFFIX=.tar
+declare -r TAR_OPTS='-c'
+
# Some debugging options
#set -e
#set -x
diff --git a/src/photoalbum b/src/photoalbum.sh
index 2418463..ffe2bf0 100755
--- a/src/photoalbum
+++ b/src/photoalbum.sh
@@ -6,48 +6,70 @@
declare -r ARG1="${1}" ; shift
declare -r VERSION='PHOTOALBUMVERSION'
-function usage () {
-cat - <<USAGE >&2
-Usage:
+usage () {
+ cat - <<USAGE >&2
+ Usage:
$0 [clean|init|version|generate|all]
-USAGE
+ USAGE
}
-function init () {
+init () {
for dir in "${INCOMING_DIR}" "${DIST_DIR}/photos" "${DIST_DIR}/thumbs" "${DIST_DIR}/html"; do
[ -d "${dir}" ] || mkdir -vp "${dir}"
done
+
+ 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
}
-function clean () {
+clean () {
echo "Not deleting ${INCOMING_DIR}"
[ -d "${DIST_DIR}" ] && rm -Rf "${DIST_DIR}"
}
-function 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
-
- scale
- find "${DIST_DIR}/html" -type f -name \*.html -delete
- makedist 1
- template index ../index
+tarball () {
+ # Cleanup tarball from prev run if any
+ find "${DIST_DIR}" -maxdepth 1 -type f -name \*.tar -delete
+
+ 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
+}
+
+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
+
+ scale
+ find "${DIST_DIR}/html" -type f -name \*.html -delete
+ makedist 1
+ template index ../index
+ tarball
}
-function template () {
+template () {
local -r template=${1} ; shift
local -r html=${1} ; shift
source "${TEMPLATE_DIR}/${template}.tmpl" >> "${DIST_DIR}/html/${html}.html"
}
-function scale () {
+scale () {
cd "${INCOMING_DIR}" && find ./ -type f | sort | while read photo; do
if [ ! -f "${DIST_DIR}/photos/${photo}" ]; then
@@ -65,15 +87,15 @@ function scale () {
convert -auto-orient \
-geometry ${GEOMETRY} "${photo}" "${DIST_DIR}/photos/${destphoto}"
fi
- done
+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
}
-function makedist () {
+makedist () {
local num=${1} ; shift
local name=page-${num}
local -i i=0
@@ -84,29 +106,29 @@ function makedist () {
cd "${DIST_DIR}/photos" && find ./ -type f | sort | sed 's;^\./;;' |
while read photo; do
: $(( i++ ))
-
+
if [ ${i} -gt ${MAXPREVIEWS} ]; then
i=1
: $(( num++ ))
-
+
next=page-${num}
template next ${name}
template footer ${name}
-
+
prev=${name}
name=${next}
template header ${name}
template prev ${name}
fi
-
+
# Preview page
template preview ${name}
-
+
# View page
template header ${num}-${i}
template view ${num}-${i}
template footer ${num}-${i}
-
+
if [ ! -f "${DIST_DIR}/thumbs/${photo}" ]; then
echo "Creating thumb for ${photo}";
convert -geometry x${THUMBGEOMETRY} "${photo}" \