Compare commits

..

No commits in common. "0a3ef4c170f092868b3ef60c5753c42413523757" and "14c62374ba088fa868d1fd3d5842fba562bceda4" have entirely different histories.

2 changed files with 20 additions and 63 deletions

View File

@ -344,8 +344,6 @@ IMAGE_FORMATS=jpeg|jpg|png|pdf|svg|eps
SPREADS_DIR=spreads/ SPREADS_DIR=spreads/
# if non-empty link link images to matching ones from this directory... # if non-empty link link images to matching ones from this directory...
# NOTE: this is ignored if --graphicx-path is passed or GRAPHICX_PATH
# is set.
IMAGE_HIRES_DIR= IMAGE_HIRES_DIR=
# directory where external captions are stored... # directory where external captions are stored...
@ -372,10 +370,6 @@ IMAGE_SPREAD=(
[0]=text-spread [0]=text-spread
[2]=image-image [2]=image-image
) )
# if set (or --graphicx-path is passed) the images are identified by their
# basename so as to let graphicx package resolve the paths internally.
GRAPHICX_PATH=1
``` ```
An explicit configuration file can be manually specified: An explicit configuration file can be manually specified:

View File

@ -132,9 +132,6 @@ printhelp(){
echo " - text spread default template (default: ${IMAGE_SPREAD[0]})." echo " - text spread default template (default: ${IMAGE_SPREAD[0]})."
echo " --captions PATH" echo " --captions PATH"
echo " - path to search for captions (default: $CAPTION_DIR)." echo " - path to search for captions (default: $CAPTION_DIR)."
echo " --graphicx-path"
echo " - reference images by their basenames and let graphicx manage"
echo " searching."
echo echo
echo "Parameters:" echo "Parameters:"
echo " PATH - path to root pages directory (default: $SPREADS_DIR)" echo " PATH - path to root pages directory (default: $SPREADS_DIR)"
@ -217,11 +214,6 @@ while true ; do
shift 2 shift 2
continue continue
;; ;;
--graphicx-path)
GRAPHICX_PATH=1
shift
continue
;;
# handle unknown options... # handle unknown options...
-*|--*) -*|--*)
@ -358,12 +350,6 @@ templateSlots(){
# usage: # usage:
# populateTemplate SPREAD TEMPLATE ITEMS... # populateTemplate SPREAD TEMPLATE ITEMS...
# #
# closure: $populateTemplate_img, $populateTemplate_txt
#
# NOTE: this is the least hacky/ugly but could not figure out a better
# way to update a list from within a function...
populateTemplate_img=
populateTemplate_txt=
populateTemplate(){ populateTemplate(){
local spread="$1" local spread="$1"
local tpl="$2" local tpl="$2"
@ -388,16 +374,6 @@ populateTemplate(){
txt+=("$elem") txt+=("$elem")
fi fi
done done
local global_img=
if ! [ -z $populateTemplate_img ] ; then
global_img=1
img=(${populateTemplate_img[@]})
fi
local global_txt=
if ! [ -z $populateTemplate_txt ] ; then
global_txt=1
txt=(${populateTemplate_txt[@]})
fi
local var local var
local val local val
@ -436,9 +412,6 @@ populateTemplate(){
text=$(echo "${text}" | \ text=$(echo "${text}" | \
sed "s/\${${var}}/${val%.*}/g") sed "s/\${${var}}/${val%.*}/g")
done done
if ! [ -z $global_img ] ; then
populateTemplate_img=("${populateTemplate_img[@]:$i}")
fi
# pass 2: captions... # pass 2: captions...
for var in ${slots[@]} ; do for var in ${slots[@]} ; do
@ -483,9 +456,6 @@ populateTemplate(){
text=$(echo "${text}" | \ text=$(echo "${text}" | \
sed "s/\${${var}}/${val}/g") sed "s/\${${var}}/${val}/g")
done done
if ! [ -z $global_txt ] ; then
populateTemplate_txt=("${txt[@]}")
fi
# print out the filled template... # print out the filled template...
echo % template: $tpl echo % template: $tpl
@ -498,7 +468,7 @@ populateTemplate(){
# usage: # usage:
# handleSpread SPREAD # handleSpread SPREAD
# #
# closure: $GRAPHICX_PATH, $IMAGE_HIRES_DIR, $IMAGE_SPREAD # closure: $IMAGE_HIRES_DIR, $IMAGE_SPREAD
handleSpread(){ handleSpread(){
local spread="$1" local spread="$1"
# skip non-spreads... # skip non-spreads...
@ -532,32 +502,21 @@ handleSpread(){
fi fi
done done
# graphicx paths...
if ! [ -z $GRAPHICX_PATH ] ; then
local C=0
for image in "${img[@]}" ; do
local new=`basename ${image}`
new="${new#+([0-9])-}"
img[$C]=$new
C=$(( C + 1 ))
done
# get hi-res image paths... # get hi-res image paths...
elif ! [ -z $IMAGE_HIRES_DIR ] ; then if ! [ -z $IMAGE_HIRES_DIR ] ; then
local C=0 local C=0
for image in "${img[@]}" ; do for image in "${img[@]}" ; do
# skip non-images... # skip non-images...
local new=`basename ${image}` local new="$IMAGE_HIRES_DIR/`basename ${image/[0-9]-/}`"
new="$IMAGE_HIRES_DIR/${new#+([0-9])-}"
# ignore file ext for availability test... # ignore file ext for availability test...
# NOTE: the first match may be an unsupported format... # NOTE: the first match may be an unsupported format...
new="${new%.*}" new="${new%.*}"
local target=$new
new=($new.*) new=($new.*)
if [ -e "${new[0]}" ] ; then if [ -e "${new[0]}" ] ; then
img[$C]=${new[0]} img[$C]=${new[0]}
else else
echo % echo %
echo "% WARNING: hi-res image not found for: \"${image}\" -> \"${target}\"" \ echo "% WARNING: hi-res image not found for: \"${image}\" -> \"${new}\"" \
| tee >(cat >&2) | tee >(cat >&2)
echo % echo %
fi fi
@ -606,37 +565,43 @@ handleSpread(){
cat "${template}" cat "${template}"
fi fi
fi fi
populateTemplate_img=("${img[@]}")
populateTemplate_txt=("${txt[@]}")
for elem in "${items[@]}" ; do for elem in "${items[@]}" ; do
C=$(( C + 1 )) C=$(( C + 1 ))
P=$([ $C == 1 ] \ P=$([ $C == 1 ] \
&& echo "left" \ && echo "left" \
|| echo "right") || echo "right")
# XXX need to use populateTemplate here...
# ...to do this need to somehow remove the used
# slots/files from list...
# image... # image...
if [[ "${elem,,}" =~ $IMAGE_FORMATS ]] ; then if [[ "${elem,,}" =~ $IMAGE_FORMATS ]] ; then
echo % echo %
echo "% $P page (image)..." echo "% $P page (image)..."
template=`getTemplate "$spread" "$IMAGE_PAGE"` template=`getTemplate "$spread" "$IMAGE_PAGE"`
populateTemplate "$spread" "$template" echo % template: $template
anotatePath "${elem}"
local caption=$(getCaption "$spread" "${elem}")
caption=$(readCaption "$caption")
cat "${template}" \
| sed -e "s%\${IMAGE0\?}%${elem%.*}%" \
-e "s%\${CAPTION0\?}%${caption}%"
# text... # text...
else else
echo % echo %
echo "% $P page (text)..." echo "% $P page (text)..."
template=$(getTemplate "$spread" "$TEXT_PAGE") template=$(getTemplate "$spread" "$TEXT_PAGE")
populateTemplate "$spread" "$template" echo % template: $template
cat "${template}" \
| sed "s%\${TEXT}%${elem}%"
fi fi
# reset for next page... # reset for next page...
template= template=
# ignore the rest of the items when we are done # ignore the rest of the items when we are done
# creating two pages... # creating two pages...
if [ $C == 2 ] ; then [ $C == 2 ] \
populateTemplate_img= && return
populateTemplate_txt=
return
fi
done done
fi fi
fi fi
@ -656,8 +621,6 @@ handleSpread(){
fi fi
fi fi
populateTemplate_img=
populateTemplate_txt=
populateTemplate "$spread" "$template" "${img[@]}" "${txt[@]}" populateTemplate "$spread" "$template" "${img[@]}" "${txt[@]}"
return $? return $?