diff --git a/Scripts/Functions/Render/render.sh b/Scripts/Functions/Render/render.sh index 82ef5d5..02562ae 100644 --- a/Scripts/Functions/Render/render.sh +++ b/Scripts/Functions/Render/render.sh @@ -74,6 +74,15 @@ function render { # where backend-specific directories are stored in. local RENDER_BACKEND_DIR="${FUNCDIR}/${FUNCDIRNAM}/Backends" + # Initialize extension pattern used to retrive template files as + # an empty value. The value of this variable specifies the file + # extensions that `centos-art.sh' will look for building the list + # of files to process. The list of files to process contains the + # files that satisfy this file extension pattern. The value of + # this variable is redefine later, at the moment of evaluating the + # repository renderable paths. + local RENDER_EXTENSION='' + # Interpret arguments and options passed through command-line. render_getOptions @@ -97,27 +106,30 @@ function render { # repository. cli_syncroRepoChanges - # Define action name based on action value as reference. When - # action value refers to theme-related directory structures, - # the centos-art.sh script performs theme-specific rendition. - # Otherwise, if a directory structure outside themes is - # provided, the base-rendition is performed instead. + # Define renderable directories and the way they are produced. + # To describe the way renderable directories are produced, we + # take the action value (ACTIONVAL) as reference and describe + # the production through the action name (ACTIONNAM), the + # rendition backend (RENDER_BACKEND) and the rendition + # extension (RENDER_EXTENSION) related to it. if [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/Identity/Images/Themes" ]];then ACTIONNAM="${FUNCNAME}_doThemeActions" + RENDER_BACKEND='svg' + RENDER_EXTENSION='(svgz|svg)' elif [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/Identity/Images" ]];then ACTIONNAM="${FUNCNAME}_doBaseActions" + RENDER_BACKEND='svg' + RENDER_EXTENSION='(svgz|svg)' elif [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/Manuals" ]];then ACTIONNAM="${FUNCNAME}_doBaseActions" + RENDER_BACKEND='docbook' + RENDER_EXTENSION='docbook' else - cli_printMessage "`gettext "The path provided do not support rendition."`" --as-error-line + cli_printMessage "`gettext "The path provided does not support rendition."`" --as-error-line fi # Execute action name. - if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then - eval $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" --as-error-line - fi + ${ACTIONNAM} # Commit changes from working copy to central repository only. # At this point, changes in the repository are not merged in diff --git a/Scripts/Functions/Render/render_doBaseActions.sh b/Scripts/Functions/Render/render_doBaseActions.sh index 570fd14..e665600 100755 --- a/Scripts/Functions/Render/render_doBaseActions.sh +++ b/Scripts/Functions/Render/render_doBaseActions.sh @@ -30,7 +30,6 @@ function render_doBaseActions { local OUTPUT='' local TEMPLATE='' local PARENTDIR='' - local EXTENSION='' local TRANSLATION='' local EXTERNALFILE='' local EXTERNALFILES='' @@ -41,12 +40,6 @@ function render_doBaseActions { # Verify default directory where design models are stored in. cli_checkFiles "$(cli_getRepoTLDir)/Identity/Models/Themes/${FLAG_THEME_MODEL}" --directory - # Define the extension pattern for template files. This is the - # file extensions that centos-art will look for in order to build - # the list of files to process. The list of files to process - # contains the files that match this extension pattern. - EXTENSION='(svgz|svg|docbook)' - # Redefine parent directory for current workplace. PARENTDIR=$(basename "${ACTIONVAL}") @@ -79,10 +72,10 @@ function render_doBaseActions { # # Another issue to consider here, is the way of filtering. We # cannot expand the pattern specified by FLAG_FILTER with a `.*' - # here (e.g., "${FLAG_FILTER}.*\.${EXTENSION}") because that would - # suppress any possibility from the user to specifiy just one file - # name in locations where more than one file with the same name as - # prefix exists (e.g., `repository.docbook', + # here (e.g., "${FLAG_FILTER}.*\.${RENDER_EXTENSION}") because + # that would suppress any possibility from the user to specifiy + # just one file name in locations where more than one file with + # the same name as prefix exists (e.g., `repository.docbook', # `repository-preamble.docbook' and `repository-parts.docbook'). # Instead, pass filtering control to the user whom can use regular # expression markup in the `--filter' option to decide whether to @@ -91,11 +84,15 @@ function render_doBaseActions { # `repository-parts.docbook' but not `repository.docbook' (e.g., # through `--filter="repository-.*"'). for FILE in $(cli_getFilesList ${TEMPLATE} \ - --pattern="${FLAG_FILTER}\.${EXTENSION}" --type="f" \ + --pattern="${FLAG_FILTER}\.${RENDER_EXTENSION}" --type="f" \ | egrep -v '/[[:alpha:]]{2}_[[:alpha:]]{2}/');do FILES[((++${#FILES[*]}))]=$FILE done + # Initialize backend-specific functionalities. + cli_exportFunctions "${RENDER_BACKEND_DIR}/$(cli_getRepoName \ + ${RENDER_BACKEND} -d)" "${RENDER_BACKEND}" + # Start processing the base rendition list of FILES. Fun part # approching :-). while [[ $COUNT -lt ${#FILES[*]} ]];do @@ -172,7 +169,7 @@ function render_doBaseActions { # structure. FILE=$(echo ${FILE} \ | sed -r "s!.*${PARENTDIR}/!!" \ - | sed -r "s/\.${EXTENSION}$//") + | sed -r "s/\.${RENDER_EXTENSION}$//") # Define absolute path to final file (without extension). FILE=${OUTPUT}/$(basename "${FILE}") @@ -187,20 +184,6 @@ function render_doBaseActions { # Expand translation markers inside design model instance. cli_replaceTMarkers ${INSTANCE} - # Redefine name of rendition backend based on the file - # extension of template instance. - if [[ $INSTANCE =~ '\.(svgz|svg)$' ]];then - RENDER_BACKEND='svg' - elif [[ $INSTANCE =~ '\.docbook$' ]];then - RENDER_BACKEND='docbook' - else - cli_printMessage "`gettext "The template file you try to render is not supported yet."`" --as-error-line - fi - - # Initialize backend-specific functionalities. - cli_exportFunctions "${RENDER_BACKEND_DIR}/$(cli_getRepoName \ - ${RENDER_BACKEND} -d)" "${RENDER_BACKEND}" - # Perform backend base-rendition. ${RENDER_BACKEND} @@ -210,14 +193,6 @@ function render_doBaseActions { # Perform backend last-rendition. ${RENDER_BACKEND}_doLastActions - # Unset backend-specific functionalities from environment. - # This is required to prevent end up with more than one - # backend-specifc function initialization, in those cases when - # different template files are rendered in just one execution - # of `centos-art.sh' script. - cli_unsetFunctions "${RENDER_BACKEND_DIR}/$(cli_getRepoName \ - ${RENDER_BACKEND} -d)" "${RENDER_BACKEND}" - # Remove template instance. if [[ -f $INSTANCE ]];then rm $INSTANCE @@ -228,4 +203,8 @@ function render_doBaseActions { done + # Unset backend-specific functionalities. + cli_unsetFunctions "${RENDER_BACKEND_DIR}/$(cli_getRepoName \ + ${RENDER_BACKEND} -d)" "${RENDER_BACKEND}" + }