summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul C. Buetow (mars.fritz.box) <paul@buetow.org>2014-05-09 20:47:24 +0200
committerPaul C. Buetow (mars.fritz.box) <paul@buetow.org>2014-05-09 20:47:24 +0200
commit2840f3a2e8d471dc083e3cdf2e78f3de7a7d6bc4 (patch)
treec0656beff44fd2ac3f112eaf0d13f20163ddf3a1
parenta1500f699618928e52a90dc1c564c4d3e328e736 (diff)
refactor
-rw-r--r--docs/photoalbum.15
-rw-r--r--docs/photoalbum.pod6
-rw-r--r--docs/photoalbum.txt4
-rwxr-xr-xsrc/photoalbum.sh19
4 files changed, 15 insertions, 19 deletions
diff --git a/docs/photoalbum.1 b/docs/photoalbum.1
index 5f47e06..b635a41 100644
--- a/docs/photoalbum.1
+++ b/docs/photoalbum.1
@@ -133,7 +133,7 @@
photoalbum \- photoalbum is a minimal bash script for linux to generate static web photo albums.
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
-photoalbum clean|version|generate|all [rcfile]
+photoalbum clean|version|generate [rcfile]
photoalbum makemake
.IP "clean" 4
.IX Item "clean"
@@ -144,9 +144,6 @@ Prints out the version
.IP "generate" 4
.IX Item "generate"
Generates the static photoalbum
-.IP "all" 4
-.IX Item "all"
-This just runs 'clean generate' right after another.
.IP "makemake" 4
.IX Item "makemake"
Creates a Makefile and photoalbumrc in the current working directory.
diff --git a/docs/photoalbum.pod b/docs/photoalbum.pod
index e265954..242860f 100644
--- a/docs/photoalbum.pod
+++ b/docs/photoalbum.pod
@@ -4,7 +4,7 @@ photoalbum - photoalbum is a minimal bash script for linux to generate static we
=head1 SYNOPSIS
-photoalbum clean|version|generate|all [rcfile]
+photoalbum clean|version|generate [rcfile]
photoalbum makemake
=over
@@ -21,10 +21,6 @@ Prints out the version
Generates the static photoalbum
-=item all
-
-This just runs 'clean generate' right after another.
-
=item makemake
Creates a Makefile and photoalbumrc in the current working directory.
diff --git a/docs/photoalbum.txt b/docs/photoalbum.txt
index c2cfb8a..093e3a4 100644
--- a/docs/photoalbum.txt
+++ b/docs/photoalbum.txt
@@ -3,7 +3,7 @@ NAME
static web photo albums.
SYNOPSIS
- photoalbum clean|version|generate|all [rcfile] photoalbum makemake
+ photoalbum clean|version|generate [rcfile] photoalbum makemake
clean
Cleans up the working space
@@ -14,8 +14,6 @@ SYNOPSIS
generate
Generates the static photoalbum
- all This just runs 'clean generate' right after another.
-
makemake
Creates a Makefile and photoalbumrc in the current working
directory.
diff --git a/src/photoalbum.sh b/src/photoalbum.sh
index 35002e7..94d54e9 100755
--- a/src/photoalbum.sh
+++ b/src/photoalbum.sh
@@ -5,8 +5,8 @@
declare -r VERSION='0.3.1develop'
declare -r DEFAULTRC=/etc/default/photoalbum
-declare -r ARG1="${1}" ; shift
-declare RC_FILE="${1}" ; shift
+declare -r ARG1="${1}" ; shift
+declare RC_FILE="${1}" ; shift
function usage() {
cat - <<USAGE >&2
@@ -70,8 +70,10 @@ function albumhtml() {
declare html_dir="${1}" ; shift
declare thumbs_dir="${1}" ; shift
declare backhref="${1}" ; shift
+
declare -i num=1
declare -i i=0
+
declare name=page-${num}
declare next=''
@@ -105,9 +107,10 @@ function albumhtml() {
template footer ${num}-${i}
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}"
+
+ echo "Creating thumb ${DIST_DIR}/${thumbs_dir}/${photo}";
convert -geometry x${THUMBGEOMETRY} "${photo}" \
"${DIST_DIR}/${thumbs_dir}/${photo}"
fi
@@ -149,8 +152,8 @@ function albumhtml() {
function albumindexhtml() {
declare -a dirs=( "${1}" )
declare is_subalbum=no
- html_dir=html
- backhref=..
+ declare html_dir=html
+ declare backhref=..
template header index
template header-first-add index
@@ -161,10 +164,12 @@ function albumindexhtml() {
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)
- declare pages=$(( $pictures / $MAXPREVIEWS + 1))
+
[ $pages -gt 1 ] && s=s || s=''
declare description="${pictures} pictures / ${pages} page$s"
template index-preview index
@@ -203,6 +208,7 @@ function generate() {
albumhtml \
"photos/${basename}" "html/${basename}" "thumbs/${basename}" ../..
done
+
# Create an album selection screen
albumindexhtml "${dirs[*]}"
fi
@@ -233,7 +239,6 @@ fi
source "${RC_FILE}"
case "${ARG1}" in
- all) clean; generate;;
clean) [ -d "${DIST_DIR}" ] && rm -Rf "${DIST_DIR}";;
generate) generate;;
version) echo "This is Photoalbum Version ${VERSION}";;