mirror of
https://github.com/flynx/photobook.git
synced 2025-10-29 10:20:08 +00:00
refactored and cleaned up template search...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6845c059fe
commit
91932d3137
@ -280,28 +280,41 @@ readCaption(){
|
|||||||
#
|
#
|
||||||
# XXX REVISE...
|
# XXX REVISE...
|
||||||
getTemplate(){
|
getTemplate(){
|
||||||
local SPREAD=$1
|
local spread=$1
|
||||||
local TYPE=$2
|
local type=$2
|
||||||
local TEMPLATE=($SPREAD/*-$TYPE.tex)
|
local template
|
||||||
if [ -z $TEMPLATE ] ; then
|
|
||||||
TEMPLATE=($SPREAD/*-$TYPE.tpl)
|
# already an existing template...
|
||||||
if ! [ -z $TEMPLATE ] ; then
|
if [[ $type =~ .*\.tex ]] && [ -e "$type" ] ; then
|
||||||
#TEMPLATE=${TEMPLATE_DIR}/$(echo "${TEMPLATE[0]}" \
|
echo $type
|
||||||
# | sed -e "s/$S{PREAD}\///" \
|
|
||||||
# -e 's/^[0-9]\+-//' \
|
|
||||||
# -e "s/-${TYPE}\.*$//").tex
|
|
||||||
TEMPLATE=${TEMPLATE/$SPREAD\//}
|
|
||||||
TEMPLATE=${TEMPLATE/[0-9]-/}
|
|
||||||
TEMPLATE="$TEMPLATE_DIR/${TEMPLATE[0]%-${TYPE}.*}.tex"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [ -z $TEMPLATE ] ; then
|
|
||||||
TEMPLATE="$TEMPLATE_DIR/${TYPE}.tex"
|
|
||||||
fi
|
|
||||||
if ! [ -e $TEMPLATE ] ; then
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
echo $TEMPLATE
|
|
||||||
|
# normalize template name...
|
||||||
|
if [[ $type =~ .*\.tpl ]] ; then
|
||||||
|
type=$( echo $type \
|
||||||
|
| sed \
|
||||||
|
-e 's/.tpl$//' \
|
||||||
|
-e "s%$spread/%%" \
|
||||||
|
-e 's/^[0-9]\+-//' )
|
||||||
|
fi
|
||||||
|
|
||||||
|
# local template...
|
||||||
|
template=($spread/*-$type.tex)
|
||||||
|
if [ ${#template[@]} != 0 ] ; then
|
||||||
|
template=${template[0]}
|
||||||
|
else
|
||||||
|
template=($spread/$type.tex)
|
||||||
|
fi
|
||||||
|
# global template...
|
||||||
|
if [ -z $template ] || ! [ -e "$template" ] ; then
|
||||||
|
template="$TEMPLATE_DIR/${type}.tex"
|
||||||
|
fi
|
||||||
|
# check if the thing exists...
|
||||||
|
if ! [ -e $template ] ; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo $template
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -585,14 +598,8 @@ handleSpread(){
|
|||||||
[ -z $template ] \
|
[ -z $template ] \
|
||||||
&& return 0
|
&& return 0
|
||||||
|
|
||||||
# format template path...
|
# XXX check for errors...
|
||||||
template=${template/$spread\//}
|
template=$(getTemplate "$spread" "$template")
|
||||||
template=${template/[0-9]-/}
|
|
||||||
# get...
|
|
||||||
template="${template[0]%.*}.tex"
|
|
||||||
if ! [ -e "$template" ] ; then
|
|
||||||
template="$TEMPLATE_DIR/${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