mirror of
				https://github.com/flynx/photobook.git
				synced 2025-11-04 05:10:08 +00:00 
			
		
		
		
	better template indexing...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									7ae71693ec
								
							
						
					
					
						commit
						5d0a593026
					
				@ -223,20 +223,23 @@ getCaption(){
 | 
				
			|||||||
	echo ${C[*]}
 | 
						echo ${C[*]}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# XXX EXPERIMENTAL...
 | 
					# XXX EXPERIMENTAL index template variables...
 | 
				
			||||||
# index ${VAR} variables in templates...
 | 
					 | 
				
			||||||
declare -A TEMPLATE_INDEX
 | 
					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(){
 | 
					indexTemplates(){
 | 
				
			||||||
	#echo indexing templates...
 | 
						#echo indexing templates...
 | 
				
			||||||
	local lst
 | 
					 | 
				
			||||||
	local tpl
 | 
						local tpl
 | 
				
			||||||
	for tpl in "${TEMPLATE_PATH}"/* ; do
 | 
						for tpl in "${TEMPLATE_PATH}"/* ; do
 | 
				
			||||||
		#echo ${tpl}...
 | 
							#echo ${tpl}...
 | 
				
			||||||
		lst=( $(cat "${tpl}" \
 | 
							templateVars "${tpl}" > /dev/null
 | 
				
			||||||
			| grep -o '\${[A-Z0-9]\+}' \
 | 
					 | 
				
			||||||
			| sed 's/\${\(.*\)}/\1/g' \
 | 
					 | 
				
			||||||
			| sort) )
 | 
					 | 
				
			||||||
		TEMPLATE_INDEX[$(basename "${tpl}")]=${lst[@]}
 | 
					 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -273,6 +276,8 @@ anotatePath(){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#----------------------------------------------------------------------
 | 
					#----------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#indexTemplates
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo %----------------------------------------------------------------------
 | 
					echo %----------------------------------------------------------------------
 | 
				
			||||||
echo %
 | 
					echo %
 | 
				
			||||||
@ -431,6 +436,10 @@ for spread in "${IMAGE_DIR}"/* ; do
 | 
				
			|||||||
		# formatting done...
 | 
							# formatting done...
 | 
				
			||||||
		[ -z $TEMPLATE ] && continue
 | 
							[ -z $TEMPLATE ] && continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							# XXX index the manual template...
 | 
				
			||||||
 | 
							#if [ -z ${TEMPLATE_INDEX[$TEMPLATE]}] ; then
 | 
				
			||||||
 | 
							#fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		# format...
 | 
							# format...
 | 
				
			||||||
		TEMPLATE=${TEMPLATE/$spread\//}
 | 
							TEMPLATE=${TEMPLATE/$spread\//}
 | 
				
			||||||
		TEMPLATE=${TEMPLATE/[0-9]-/}
 | 
							TEMPLATE=${TEMPLATE/[0-9]-/}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user