mirror of
https://github.com/flynx/photobook.git
synced 2025-10-29 10:20:08 +00:00
now the config is quite a bit more flexible...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
99f3b45d8b
commit
2855a9126d
1
examples/spread generation/spreads/00/text.txt
Normal file
1
examples/spread generation/spreads/00/text.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
page text
|
||||||
1
examples/spread generation/spreads/02/02.txt
Normal file
1
examples/spread generation/spreads/02/02.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
caption text
|
||||||
@ -127,8 +127,6 @@ shopt -s nullglob extglob
|
|||||||
|
|
||||||
# defaults...
|
# defaults...
|
||||||
|
|
||||||
CFG_FILE=`basename $0`.cfg
|
|
||||||
|
|
||||||
TEMPLATE_PATH=templates/
|
TEMPLATE_PATH=templates/
|
||||||
|
|
||||||
IMAGE_DIR=pages/
|
IMAGE_DIR=pages/
|
||||||
@ -140,15 +138,31 @@ CAPTIONS=captions/
|
|||||||
TEXT_FORMATS='.*\.txt$'
|
TEXT_FORMATS='.*\.txt$'
|
||||||
IMAGE_FORMATS='.*\.(jpeg|jpg|png|pdf|svg|eps)$'
|
IMAGE_FORMATS='.*\.(jpeg|jpg|png|pdf|svg|eps)$'
|
||||||
|
|
||||||
|
|
||||||
# Default timplates
|
# Default timplates
|
||||||
TEXT_SPREAD=text-spread
|
# NOTE: if a template is not found we will try and build a spread from
|
||||||
SINGLE_IMAGE_SPREAD=imagebleedleft
|
# page components...
|
||||||
DOUBLE_IMAGE_SPREAD=image-image
|
|
||||||
|
# page templates...
|
||||||
|
TEXT_PAGE=textpage
|
||||||
|
IMAGE_PAGE=imagepage
|
||||||
|
|
||||||
|
# dynamic spread templates...
|
||||||
|
# NOTE: the index here is the number of images found in a spread directory...
|
||||||
|
IMAGE_SPREAD=(
|
||||||
|
[0]=text-spread
|
||||||
|
[1]=imagebleedleft
|
||||||
|
[2]=image-image
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# load config...
|
# load config...
|
||||||
[ -e $CFG_FILE ] && source $CFG_FILE
|
|
||||||
|
|
||||||
|
CFG_FILE=$(basename ${0%.*}).cfg
|
||||||
|
|
||||||
|
[ -e $CFG_FILE ] \
|
||||||
|
&& source "$CFG_FILE"
|
||||||
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
@ -164,11 +178,11 @@ printhelp(){
|
|||||||
echo " --templates=PATH"
|
echo " --templates=PATH"
|
||||||
echo " - path to search for templates (default: $TEMPLATE_PATH)."
|
echo " - path to search for templates (default: $TEMPLATE_PATH)."
|
||||||
echo " --single-image-tpl=NAME"
|
echo " --single-image-tpl=NAME"
|
||||||
echo " - single image default template (default: $SINGLE_IMAGE_SPREAD)."
|
echo " - single image default template (default: ${IMAGE_SPREAD[1]})."
|
||||||
echo " --double-image-tpl=NAME"
|
echo " --double-image-tpl=NAME"
|
||||||
echo " - double image default template (default: $DOUBLE_IMAGE_SPREAD)."
|
echo " - double image default template (default: ${IMAGE_SPREAD[2]})."
|
||||||
echo " --text-spread-tpl=NAME"
|
echo " --text-spread-tpl=NAME"
|
||||||
echo " - text spread default template (default: $TEXT_SPREAD)."
|
echo " - text spread default template (default: ${IMAGE_SPREAD[0]})."
|
||||||
echo
|
echo
|
||||||
echo "Parameters:"
|
echo "Parameters:"
|
||||||
echo " PATH - path to root pages directory (default: $IMAGE_DIR)"
|
echo " PATH - path to root pages directory (default: $IMAGE_DIR)"
|
||||||
@ -213,17 +227,17 @@ while true ; do
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--single-image-tpl)
|
--single-image-tpl)
|
||||||
SINGLE_IMAGE_SPREAD=$2
|
IMAGE_SPREAD[1]=$2
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--double-image-tpl)
|
--double-image-tpl)
|
||||||
DOUBLE_IMAGE_SPREAD=$2
|
IMAGE_SPREAD[2]=$2
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--text-spread-tpl)
|
--text-spread-tpl)
|
||||||
TEXT_SPREAD=$2
|
IMAGE_SPREAD[0]=$2
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
@ -425,7 +439,7 @@ populateTemplate(){
|
|||||||
# usage:
|
# usage:
|
||||||
# handleSpread SPREAD
|
# handleSpread SPREAD
|
||||||
#
|
#
|
||||||
# closure: $IMAGE_HIRES_DIR, $SINGLE_IMAGE_SPREAD, $TEXT_SPREAD
|
# closure: $IMAGE_HIRES_DIR, $IMAGE_SPREAD
|
||||||
handleSpread(){
|
handleSpread(){
|
||||||
local spread="$1"
|
local spread="$1"
|
||||||
# skip non-spreads...
|
# skip non-spreads...
|
||||||
@ -494,18 +508,13 @@ handleSpread(){
|
|||||||
# XXX this will also eat 0-imagepage.tpl / 20-textpage.tpl -- do a better pattern...
|
# XXX this will also eat 0-imagepage.tpl / 20-textpage.tpl -- do a better pattern...
|
||||||
if ! [ -z $template ] ; then
|
if ! [ -z $template ] ; then
|
||||||
template=(`ls "$spread/"*.tpl \
|
template=(`ls "$spread/"*.tpl \
|
||||||
| egrep -v '.*-(imagepage|textpage)\.tpl'`)
|
| egrep -v '.*-('${IMAGE_PAGE}'|'${TEXT_PAGE}')\.tpl'`)
|
||||||
fi
|
fi
|
||||||
# no template explicitly defined -> match auto-template...
|
# no template explicitly defined -> match auto-template...
|
||||||
if [ -z $layout ] && [ -z $template ] ; then
|
if [ -z $layout ] && [ -z $template ] ; then
|
||||||
# no images...
|
# N images...
|
||||||
# XXX check if template exists...
|
if [ -z $template ] && [ -n ${IMAGE_SPREAD[${#img[@]}]} ] ; then
|
||||||
if [ ${#img[@]} == 0 ] ; then
|
template=$(getTemplate "$spread" "${IMAGE_SPREAD[${#img[@]}]}")
|
||||||
template=$(getTemplate "$spread" "$TEXT_SPREAD")
|
|
||||||
fi
|
|
||||||
# single image...
|
|
||||||
if [ -z $template ] && [ ${#img[@]} == 1 ] ; then
|
|
||||||
template=$(getTemplate "$spread" "$SINGLE_IMAGE_SPREAD")
|
|
||||||
fi
|
fi
|
||||||
# build spread from pages...
|
# build spread from pages...
|
||||||
if [ -z $template ] ; then
|
if [ -z $template ] ; then
|
||||||
@ -526,7 +535,7 @@ handleSpread(){
|
|||||||
if [[ "$elem" =~ $IMAGE_FORMATS ]] ; then
|
if [[ "$elem" =~ $IMAGE_FORMATS ]] ; then
|
||||||
echo %
|
echo %
|
||||||
echo "% $P page (image)..."
|
echo "% $P page (image)..."
|
||||||
template=`getTemplate "$spread" "imagepage"`
|
template=`getTemplate "$spread" "$IMAGE_PAGE"`
|
||||||
echo % template: $template
|
echo % template: $template
|
||||||
anotatePath "${elem}"
|
anotatePath "${elem}"
|
||||||
local caption=$(getCaption "$spread" "${elem}")
|
local caption=$(getCaption "$spread" "${elem}")
|
||||||
@ -538,7 +547,7 @@ handleSpread(){
|
|||||||
else
|
else
|
||||||
echo %
|
echo %
|
||||||
echo "% $P page (text)..."
|
echo "% $P page (text)..."
|
||||||
template=$(getTemplate "$spread" "textpage")
|
template=$(getTemplate "$spread" "$TEXT_PAGE")
|
||||||
echo % template: $template
|
echo % template: $template
|
||||||
cat "${template}" \
|
cat "${template}" \
|
||||||
| sed "s%\${TEXT}%${elem}%"
|
| sed "s%\${TEXT}%${elem}%"
|
||||||
@ -560,7 +569,10 @@ handleSpread(){
|
|||||||
template=${template/$spread\//}
|
template=${template/$spread\//}
|
||||||
template=${template/[0-9]-/}
|
template=${template/[0-9]-/}
|
||||||
# get...
|
# get...
|
||||||
template="$TEMPLATE_PATH/${template[0]%.*}.tex"
|
template="${template[0]%.*}.tex"
|
||||||
|
if ! [ -e "$template" ] ; then
|
||||||
|
template="$TEMPLATE_PATH/${template[0]%.*}.tex"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
populateTemplate "$spread" "$template" "${img[@]}" "${txt[@]}"
|
populateTemplate "$spread" "$template" "${img[@]}" "${txt[@]}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user