From 5d0a593026e43c00e8b437dba1f09c52ed177b65 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 5 Mar 2023 01:50:13 +0300 Subject: [PATCH] better template indexing... Signed-off-by: Alex A. Naanou --- scripts/make-images.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/scripts/make-images.sh b/scripts/make-images.sh index f7d8a0f..2daf135 100644 --- a/scripts/make-images.sh +++ b/scripts/make-images.sh @@ -223,20 +223,23 @@ getCaption(){ echo ${C[*]} } -# XXX EXPERIMENTAL... -# index ${VAR} variables in templates... +# XXX EXPERIMENTAL index template variables... declare -A TEMPLATE_INDEX +templateVars(){ + if [ -z ${TEMPLATE_INDEX[$1]} ] ; then + TEMPLATE_INDEX[$1]=$(cat "$1" \ + | grep -o '\${[A-Z0-9]\+}' \ + | sed 's/\${\(.*\)}/\1/g' \ + | sort) + fi + echo ${TEMPLATE_INDEX[$1]} +} indexTemplates(){ #echo indexing templates... - local lst local tpl for tpl in "${TEMPLATE_PATH}"/* ; do #echo ${tpl}... - lst=( $(cat "${tpl}" \ - | grep -o '\${[A-Z0-9]\+}' \ - | sed 's/\${\(.*\)}/\1/g' \ - | sort) ) - TEMPLATE_INDEX[$(basename "${tpl}")]=${lst[@]} + templateVars "${tpl}" > /dev/null done } @@ -273,6 +276,8 @@ anotatePath(){ #---------------------------------------------------------------------- +#indexTemplates + echo %---------------------------------------------------------------------- echo % @@ -431,6 +436,10 @@ for spread in "${IMAGE_DIR}"/* ; do # formatting done... [ -z $TEMPLATE ] && continue + # XXX index the manual template... + #if [ -z ${TEMPLATE_INDEX[$TEMPLATE]}] ; then + #fi + # format... TEMPLATE=${TEMPLATE/$spread\//} TEMPLATE=${TEMPLATE/[0-9]-/}