From 9b4d7db5b5e62e3e9993de9b7355c734badc93e4 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Feb 03 2011 14:37:03 +0000 Subject: Update `render' functionality. --- diff --git a/Scripts/Bash/Functions/Render/render_doCopy.sh b/Scripts/Bash/Functions/Render/render_doCopy.sh index a2fe6c2..957e92e 100755 --- a/Scripts/Bash/Functions/Render/render_doCopy.sh +++ b/Scripts/Bash/Functions/Render/render_doCopy.sh @@ -1,12 +1,12 @@ #!/bin/bash # # render_doCopy.sh -- This function duplicates rendition stuff. -# Rendition stuff is formed by design models, design images, -# pre-rendition configuration scripts and translations files. This -# way, when we say to duplicate rendition stuff we are saying to -# duplicate these four directory structures (i.e., design models, -# design images, pre-rendition configuration scripts, and related -# translations files). +# Rendition stuff is formed by design models, design images and +# pre-rendition configuration scripts (which includes translations +# files). This way, when we say to duplicate rendition stuff we are +# saying to duplicate these four directory structures (i.e., design +# models, design images, pre-rendition configuration scripts, and +# related translations files). # # Copyright (C) 2009-2011 Alain Reguera Delgado # diff --git a/Scripts/Bash/Functions/Render/render_doIdentity.sh b/Scripts/Bash/Functions/Render/render_doIdentity.sh index ef8edb7..923c68a 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentity.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentity.sh @@ -29,12 +29,11 @@ function render_doIdentity { - # Check parent directory. Identity rendition takes place under - # trunk/Identity directory structure only. Be sure action value - # referes an identity directory structure before perform identity - # rendition. - if [[ ! $ACTIONVAL =~ "^$(cli_getRepoTLDir $ACTIONVAL)/Identity/.+$" ]];then - cli_printMessage "`eval_gettext "Can't do identity rendition at \\\`\\\$ACTIONVAL'."`" 'AsErrorLine' + # Define rendition parent directories. This is, where we can run + # the `render' functionality to produce files from translation + # files and/or design models. + if [[ ! $ACTIONVAL =~ "^$(cli_getRepoTLDir $ACTIONVAL)/(Identity|Manuals)/.+$" ]];then + cli_printMessage "`eval_gettext "Can't render files under \\\`\\\$ACTIONVAL'."`" 'AsErrorLine' cli_printMessage "$(caller)" "AsToKnowMoreLine" fi @@ -97,7 +96,7 @@ function render_doIdentity { # the exact artwork path (that is, where images will be # stored). ACTIONVAL=$(dirname $(echo $FILE | sed -r \ - -e 's!Scripts/Bash/Functions/Render/Config/Identity/!Identity/!' \ + -e 's!Scripts/Bash/Functions/Render/Config/(Identity|Manuals)/!\1/!' \ -e "s!Themes/!Themes/Motifs/$(cli_getPathComponent '--theme')/!")) # Redefine artwork identification. @@ -107,9 +106,8 @@ function render_doIdentity { # reuse motif artwork identification. There is not need to # create one artwork identification for each motif directory # structure if we can reuse just one. - if [[ $ARTCOMP =~ "Themes/Motifs/$(cli_getPathComponent '--theme')/" ]];then - ARTCOMP=$(echo $ARTCOMP | sed -r "s!Themes/Motifs/$(cli_getPathComponent '--theme')/!Themes/!") - fi + ARTCOMP=$(echo $ARTCOMP \ + | sed -r "s!Themes/Motifs/$(cli_getPathComponent '--theme')/!Themes/!") # Start rendition as defined in artwork-specific pre-rendition # configuration file. diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImageBrands.sh b/Scripts/Bash/Functions/Render/render_doIdentityImageBrands.sh index 8a05a96..7a10f6e 100644 --- a/Scripts/Bash/Functions/Render/render_doIdentityImageBrands.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImageBrands.sh @@ -41,14 +41,10 @@ function render_doIdentityImageBrands { # Create logo copy in 2 colors. cli_printMessage "${FILE}.xbm (`gettext "2 colors grayscale"`)" "AsSavedAsLine" - convert -colorspace gray -colors 2 \ - ${FILE}.png \ - ${FILE}.xbm + convert -colorspace gray -colors 2 ${FILE}.png ${FILE}.xbm # Create logo copy in emboss effect. cli_printMessage "${FILE}-emboss.png" "AsSavedAsLine" - convert -emboss 1 \ - ${FILE}.png \ - ${FILE}-emboss.png + convert -emboss 1 ${FILE} ${FILE}-emboss.png } diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImageGrub.sh b/Scripts/Bash/Functions/Render/render_doIdentityImageGrub.sh index 3e04518..c3bc356 100644 --- a/Scripts/Bash/Functions/Render/render_doIdentityImageGrub.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImageGrub.sh @@ -26,7 +26,7 @@ function render_doIdentityImageGrub { - local FILE=$1 + local FILE="$1" local ACTION="$2" local OPTIONS='' @@ -86,26 +86,20 @@ function render_doIdentityImageGrub { # Create Netpbm superformat (PNM). PNM file is created from the # PNG image rendered previously. PNM is a common point for image # manipulation using Netpbm tools. - cli_printMessage "$FILE.pnm" "AsSavedAsLine" + cli_printMessage "${FILE}.pnm" "AsSavedAsLine" pngtopnm -verbose \ - < $FILE.png \ - 2>$FILE.log \ - > $FILE.pnm + < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm # Reduce colors as specified in ppm palette of colors. cli_printMessage "${FILE}${PREFIX}.ppm" "AsSavedAsLine" pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ - < $FILE.pnm \ - 2>>$FILE.log \ - > ${FILE}${PREFIX}.ppm + < ${FILE}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.ppm # Create the 14 colors xpm.gz file. cli_printMessage "${FILE}${PREFIX}.xpm.gz" "AsSavedAsLine" ppmtoxpm \ - < ${FILE}${PREFIX}.ppm \ - 2>>$FILE.log \ - > $FILE.xpm \ - && gzip --force $FILE.xpm \ - && mv $FILE.xpm.gz ${FILE}${PREFIX}.xpm.gz + < ${FILE}${PREFIX}.ppm 2>>${FILE}.log > ${FILE}.xpm \ + && gzip --force ${FILE}.xpm \ + && mv ${FILE}.xpm.gz ${FILE}${PREFIX}.xpm.gz } diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImageSyslinux.sh b/Scripts/Bash/Functions/Render/render_doIdentityImageSyslinux.sh index d71002b..fdd0830 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentityImageSyslinux.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImageSyslinux.sh @@ -26,7 +26,7 @@ function render_doIdentityImageSyslinux { - local FILE=$1 + local FILE="$1" local ACTION="$2" local OPTIONS='' @@ -93,18 +93,16 @@ function render_doIdentityImageSyslinux { # Create Netpbm superformat (PNM). PNM file is created from the # PNG image rendered previously. PNM is a common point for image # manipulation using Netpbm tools. - cli_printMessage "$FILE.pnm" "AsSavedAsLine" - pngtopnm -verbose \ - < $FILE.png \ - 2>$FILE.log > $FILE.pnm + cli_printMessage "${FILE}.pnm" "AsSavedAsLine" + pngtopnm -verbose \ + < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm # Reduce colors. Here we use the Netpbm color $PALETTE_PPM to # enforce the color position in the image index and the # Floyd-Steinberg dithering in order to improve color reduction. - cli_printMessage "$FILE${PREFIX}.pnm" "AsSavedAsLine" + cli_printMessage "${FILE}${PREFIX}.pnm" "AsSavedAsLine" pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ - < $FILE.pnm \ - 2>>$FILE.log > $FILE${PREFIX}.pnm + < ${FILE}.pnm 2>> ${FILE}.log > ${FILE}${PREFIX}.pnm # Create LSS16 image. As specified in isolinux documentation the # background color should be indexed on position 0 and forground @@ -116,26 +114,21 @@ function render_doIdentityImageSyslinux { # with the color information as described in isolinux # documentation (i.e #RRGGBB=0 #RRGGBB=1 ... [all values in the # same line]). - cli_printMessage "$FILE${PREFIX}.lss" "AsSavedAsLine" + cli_printMessage "${FILE}${PREFIX}.lss" "AsSavedAsLine" PALETTE_HEX=$(cat $PALETTE_HEX | tr "\n" ' ' | tr -s ' ') ppmtolss16 $PALETTE_HEX \ - < $FILE${PREFIX}.pnm \ - 2>>$FILE.log \ - > $FILE${PREFIX}.lss + < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.lss # Create the PPM image indexed to 16 colors. Also the colormap - # used in the LSS16 image is saved on $FILE.log; this is useful to + # used in the LSS16 image is saved on ${FILE}.log; this is useful to # verify the correct order of colors in the image index. - cli_printMessage "$FILE${PREFIX}.ppm" "AsSavedAsLine" - lss16toppm -map < $FILE${PREFIX}.lss \ - 2>>$FILE.log \ - > $FILE${PREFIX}.ppm + cli_printMessage "${FILE}${PREFIX}.ppm" "AsSavedAsLine" + lss16toppm -map \ + < ${FILE}${PREFIX}.lss 2>>${FILE}.log > ${FILE}${PREFIX}.ppm # Create the 16 colors PNG image. - cli_printMessage "$FILE${PREFIX}.png" "AsSavedAsLine" + cli_printMessage "${FILE}${PREFIX}.png" "AsSavedAsLine" pnmtopng -verbose -palette=$PALETTE_PPM \ - < $FILE${PREFIX}.pnm \ - 2>>$FILE.log \ - > $FILE${PREFIX}.png + < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.png } diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImages.sh b/Scripts/Bash/Functions/Render/render_doIdentityImages.sh index 95b704b..12bf9c4 100644 --- a/Scripts/Bash/Functions/Render/render_doIdentityImages.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImages.sh @@ -37,7 +37,7 @@ function render_doIdentityImages { # Start processing the base rendition list of FILES. Fun part # approching :-). - for FILE in $FILES; do + for FILE in ${FILES}; do # Call shared variable re-definitions. render_getIdentityDefs @@ -45,7 +45,7 @@ function render_doIdentityImages { # Check export id inside design templates. grep "id=\"$EXPORTID\"" $INSTANCE > /dev/null if [[ $? -gt 0 ]];then - cli_printMessage "`eval_gettext "Can't found the export id (\\\$EXPORTID) inside \\\$TEMPLATE."`" "AsErrorLine" + cli_printMessage "`eval_gettext "There is no export id (\\\$EXPORTID) inside \\\$TEMPLATE."`" "AsErrorLine" cli_printMessage '-' 'AsSeparatorLine' continue fi @@ -53,7 +53,7 @@ function render_doIdentityImages { # Define final image width. If FILE name is a number, asume it # as the width value of the image being rendered. Otherwise # use design template default width value. - WIDTH=$(basename $FILE) + WIDTH=$(basename ${FILE}) if [[ $WIDTH =~ '^[0-9]+$' ]];then WIDTH="--export-width=$WIDTH" else @@ -79,7 +79,7 @@ function render_doIdentityImages { # reduce the amount of characters used in description column # at final output. cli_printMessage "$(inkscape $INSTANCE \ - --export-id=$EXPORTID $WIDTH --export-png=$FILE.png | sed -r \ + --export-id=$EXPORTID $WIDTH --export-png=${FILE} | sed -r \ -e "s!Area !`gettext "Area"`: !" \ -e "s!Background RRGGBBAA:!`gettext "Background"`: RRGGBBAA!" \ -e "s!Bitmap saved as:!`gettext "Saved as"`:!")" \ @@ -90,29 +90,33 @@ function render_doIdentityImages { rm $INSTANCE fi + # Stript extension from file. This is required in order to + # assign different extensions to the same name of file. + FILE=$(echo ${FILE} | sed -r "s/\.${EXTENSION}$//") + # Execute post-rendition actions. for ACTION in "${POSTACTIONS[@]}"; do case "$ACTION" in renderSyslinux* ) - render_doIdentityImageSyslinux "$FILE" "$ACTION" + render_doIdentityImageSyslinux "${FILE}" "$ACTION" ;; renderGrub* ) - render_doIdentityImageGrub "$FILE" "$ACTION" + render_doIdentityImageGrub "${FILE}" "$ACTION" ;; renderFormats:* ) - render_doIdentityImageFormats "$FILE" "$ACTION" + render_doIdentityImageFormats "${FILE}" "$ACTION" ;; renderBrands:* ) - render_doIdentityImageBrands "$FILE" "$ACTION" + render_doIdentityImageBrands "${FILE}" "$ACTION" ;; groupByType:* ) - render_doIdentityGroupByType "$FILE" "$ACTION" + render_doIdentityGroupByType "${FILE}" "$ACTION" ;; esac diff --git a/Scripts/Bash/Functions/Render/render_doIdentityTMarkersCommons.sh b/Scripts/Bash/Functions/Render/render_doIdentityTMarkersCommons.sh index 85a724b..d6fdcdb 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentityTMarkersCommons.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityTMarkersCommons.sh @@ -31,6 +31,8 @@ function render_doIdentityTMarkersCommons { local -a SRC local -a DST local COUNT=0 + local COUNTSRC=0 + local COUNTDST=0 local LOCATION='' # Define source location on which sed replacements take place. By @@ -55,38 +57,73 @@ function render_doIdentityTMarkersCommons { SRC[0]='=COPYRIGHT=' SRC[1]='=DESCRIPTION=' SRC[2]='=LICENSE=' - SRC[3]='=THEME=' - SRC[4]='=THEMENAME=' - SRC[5]='=THEMERELEASE=' - SRC[6]='=RELEASE=' - SRC[7]='=MAJOR_RELEASE=' - SRC[8]='=MINOR_RELEASE=' - SRC[9]='=URL=' - SRC[10]='=URLLOCALE=' + SRC[3]='=LICENSE_URL=' + SRC[4]='=THEME=' + SRC[5]='=THEMENAME=' + SRC[6]='=THEMERELEASE=' + SRC[7]='=RELEASE=' + SRC[8]='=MAJOR_RELEASE=' + SRC[9]='=MINOR_RELEASE=' + SRC[10]='=URL=' SRC[11]='=ARCH=' + SRC[12]='=URL_WIKI=' + SRC[13]='=URL_LISTS=' + SRC[14]='=URL_FORUMS=' + SRC[15]='=URL_MIRRORS=' + SRC[16]='=URL_DOCS=' # Define replacements for translation markers. DST[0]="$(cli_getCopyrightInfo '--copyright')" DST[1]="$(cli_getCopyrightInfo '--description')" DST[2]="$(cli_getCopyrightInfo '--license')" - DST[3]="$(cli_getPathComponent "$FILE" '--theme')" - DST[4]="$(cli_getPathComponent "$FILE" '--theme-name')" - DST[5]="$(cli_getPathComponent "$FILE" '--theme-release')" - DST[6]="$(cli_getPathComponent "$FILE" '--release')" - DST[7]="$(cli_getPathComponent "$FILE" '--release-major')" - DST[8]="$(cli_getPathComponent "$FILE" '--release-minor')" - DST[9]="http://www.centos.org" - # Define url locale information. We don't want to show locale - # information inside url for English language. English is the - # default locale and no locale level is used for it. However, if - # we are rendering a language different from English, the locale - # information should be present in the url. - if [[ $(cli_getCurrentLocale) == 'en' ]];then - DST[10]='' - else - DST[10]="$(cli_getCurrentLocale)/" - fi + DST[3]="$(cli_getCopyrightInfo '--license-url')" + DST[4]="$(cli_getPathComponent "$FILE" '--theme')" + DST[5]="$(cli_getPathComponent "$FILE" '--theme-name')" + DST[6]="$(cli_getPathComponent "$FILE" '--theme-release')" + DST[7]="$(cli_getPathComponent "$FILE" '--release')" + DST[8]="$(cli_getPathComponent "$FILE" '--release-major')" + DST[9]="$(cli_getPathComponent "$FILE" '--release-minor')" + DST[10]="http://$(cli_getCurrentLocale).centos.org/" DST[11]="$(cli_getPathComponent "$FILE" '--architecture')" + DST[12]="=URL=wiki/" + DST[13]="=URL=lists/" + DST[14]="=URL=forums/" + DST[15]="=URL=mirrors/" + DST[16]="=URL=docs/" + + # Do replacement of nested translation markers. + while [[ $COUNTDST -lt ${#DST[@]} ]];do + + # Verify existence of translation markers. If there is no + # translation marker on replacement, continue with the next + # one in the list. + if [[ ! ${DST[$COUNTDST]} =~ '=[A-Z_]+=' ]];then + # Increment destination counter. + COUNTDST=$(($COUNTDST + 1)) + # The current replacement value doesn't have translation + # marker inside, so skip it and evaluate the next + # replacement value in the list. + continue + fi + + while [[ $COUNTSRC -lt ${#SRC[*]} ]];do + + # Update replacements. + DST[$COUNTDST]=$(echo ${DST[$COUNTDST]} \ + | sed -r "s!${SRC[$COUNTSRC]}!${DST[$COUNTSRC]}!g") + + # Increment source counter. + COUNTSRC=$(($COUNTSRC + 1)) + + done + + # Reset source counter + COUNTSRC=0 + + # Increment destination counter. + COUNTDST=$(($COUNTDST + 1)) + + done # Apply replacements for translation markers. while [[ ${COUNT} -lt ${#SRC[*]} ]];do diff --git a/Scripts/Bash/Functions/Render/render_doIdentityTexts.sh b/Scripts/Bash/Functions/Render/render_doIdentityTexts.sh index 0c3168c..58c7ab9 100644 --- a/Scripts/Bash/Functions/Render/render_doIdentityTexts.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityTexts.sh @@ -35,7 +35,7 @@ function render_doIdentityTexts { # Render text file. cli_printMessage "$FILE" 'AsSavedAsLine' - cat $INSTANCE > $FILE + cat $INSTANCE > ${FILE} # Remove template instance. if [[ -a $INSTANCE ]];then diff --git a/Scripts/Bash/Functions/Render/render_getActions.sh b/Scripts/Bash/Functions/Render/render_getActions.sh index 0f4f8ef..463f595 100644 --- a/Scripts/Bash/Functions/Render/render_getActions.sh +++ b/Scripts/Bash/Functions/Render/render_getActions.sh @@ -120,7 +120,7 @@ function render_getActions { # scripts. The render.conf.sh scripts define how each artwork is # rendered. local ARTCONF=$(echo "$ACTIONVAL" \ - | sed -r -e 's!/(Identity|Translations)!/Scripts/Bash/Functions/Render/Config/\1!' \ + | sed -r -e 's!/(Identity|Manuals)!/Scripts/Bash/Functions/Render/Config/\1!' \ -e "s!Motifs/$(cli_getPathComponent '--theme')/?!!") # Execute action name. diff --git a/Scripts/Bash/Functions/Render/render_getFilesList.sh b/Scripts/Bash/Functions/Render/render_getFilesList.sh index 84233e4..1a88f3c 100644 --- a/Scripts/Bash/Functions/Render/render_getFilesList.sh +++ b/Scripts/Bash/Functions/Render/render_getFilesList.sh @@ -33,36 +33,32 @@ function render_getFilesList { # Define source location to look files for. In order to define # source location we evaluate both matching list and translation # path information, and based on them, we set which is the source - # location and extension used as reference to build list of file - # names (without extension) to process for. + # location we use to build the list of file names (without + # extension) we want to process. if [[ "${MATCHINGLIST}" != "" ]] \ && [[ "${TRANSLATIONPATH}" == "" ]];then # Use design template as source location. LOCATION="$SVG" - EXTENSION='svg' elif [[ "${MATCHINGLIST}" == "" ]] \ && [[ "${TRANSLATIONPATH}" == "" ]];then # Use design template as source location. LOCATION="$SVG" - EXTENSION='svg' elif [[ "${MATCHINGLIST}" == "" ]] \ && [[ "${TRANSLATIONPATH}" != "" ]];then # Use translations as source location. LOCATION="${TRANSLATIONPATH}" - EXTENSION='png\.sh' elif [[ "${MATCHINGLIST}" != "" ]] \ && [[ "${TRANSLATIONPATH}" != "" ]];then # Use translations as source location. LOCATION="${TRANSLATIONPATH}" - EXTENSION='png\.sh' - + fi # Make regular expression (FLAG_FILTER) variable local (to avoid diff --git a/Scripts/Bash/Functions/Render/render_getIdentityBase.sh b/Scripts/Bash/Functions/Render/render_getIdentityBase.sh index 017577b..63217a0 100755 --- a/Scripts/Bash/Functions/Render/render_getIdentityBase.sh +++ b/Scripts/Bash/Functions/Render/render_getIdentityBase.sh @@ -36,6 +36,10 @@ function render_getIdentityBase { local EXTENSION='' local -a COMMONDIRS + # Define extension pattern of rendition-related files (e.g., + # translation files and design models). + EXTENSION='(svg|txt|html|htm|png)(\.sh)?' + # Redefine absolute path to artwork's related translation entry. render_getIdentityDirTranslation diff --git a/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh b/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh index fe1bfc2..6488051 100644 --- a/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh +++ b/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh @@ -29,8 +29,8 @@ function render_getIdentityDefs { # Define the translation file absolute path. Only if we have a # .png.sh extension at file's end we can consider that file as a # translation file. Otherwise there is not translation file. - if [[ $FILE =~ '\.png\.sh$' ]];then - TRANSLATION=$FILE + if [[ ${FILE} =~ "\.${EXTENSION}$" ]];then + TRANSLATION=${FILE} else TRANSLATION=`gettext "None"` fi @@ -39,7 +39,7 @@ function render_getIdentityDefs { # because we already built the file list using existent files. # But what happen if any of the files already loaded are removed # after being loaded? well, just skip it. - if [[ "$TRANSLATION" == 'None' ]];then + if [[ "$TRANSLATION" == `gettext "None"` ]];then cli_printMessage "`gettext "None"`" "AsTranslationLine" else cli_checkFiles "$TRANSLATION" 'fh' @@ -57,7 +57,7 @@ function render_getIdentityDefs { # images based on design templates. This avoids the creation # of an extra `Tpl' directory under Img. We want to save # primary PNG file structure directly under Img/ not Img/Tpl/. - FILE=$(echo $FILE | sed -r "s!^${SVG}/!!") + FILE=$(echo ${FILE} | sed -r "s!^${SVG}/!!") # In this case just one primary image is rendered. # Template points to the value passed in the template @@ -71,12 +71,12 @@ function render_getIdentityDefs { # images based on design templates. This avoids the creation # of an extra `Tpl' directory under Img. We want to save # primary PNG file structure directly under Img/ not Img/Tpl/. - FILE=$(echo $FILE | sed -r "s!^${SVG}/!!") + FILE=$(echo ${FILE} | sed -r "s!^${SVG}/!!") # In this case one primary image is rendered for each # design template. Template absolute path points to a # design template (see LOCATION's definition). - TEMPLATE=$FILE + TEMPLATE=${FILE} elif [[ "${MATCHINGLIST}" == "" ]] \ && [[ "${TRANSLATIONPATH}" != "" ]];then @@ -87,12 +87,12 @@ function render_getIdentityDefs { # matching. Template and translation files use the same path # and name relative to their PARENTDIR. Translations use # .png.sh extension and templates .svg extension. - TEMPLATE=$(echo $FILE | sed -r "s!.*/${PARENTDIR}/(.*)!\1!" \ - | sed -r 's!\.png\.sh$!.svg!') + TEMPLATE=$(echo ${FILE} | sed -r "s!.*/${PARENTDIR}/(.*)!\1!" \ + | sed -r "s/\.${EXTENSION}$/.svg/") elif [[ "${MATCHINGLIST}" != "" ]] \ && [[ "${TRANSLATIONPATH}" != "" ]];then - + # Create a template and translation matching list. With this # configuration we can optimize the rendition process for # artworks like Anaconda progress slides and installation @@ -142,7 +142,8 @@ function render_getIdentityDefs { # bond/path/green/translation1.png.sh \ # bond/path/green/translation2.png.sh # - BOND=$(echo $TRANSLATION | sed -r "s/^.*\/$PARENTDIR\/(.+)\/.*\.png\.sh$/\1/") + BOND=$(echo $TRANSLATION \ + | sed -r "s/^.*\/$PARENTDIR\/(.+)\/.*\.${EXTENSION}$/\1/") # If there is no template at this point, start reducing the # bond path and try to use the result as template. This is @@ -206,12 +207,12 @@ function render_getIdentityDefs { # Remove `.png.sh' extension from BOND. This is required # in order to build the BOND design template correctly. - BOND=$(echo $BOND | sed -r 's!\.png\.sh$!!') + BOND=$(echo $BOND | sed -r "s/\.${EXTENSION}$//") # Reduce template designs found to match BOND design # template. Take into account design templates extensions. TEMPLATE=$(echo "$TEMPLATE" \ - | egrep "${BOND}(\.svg|\.html|\.htm)?$") + | egrep "${BOND}(\.${EXTENSION})?$") fi @@ -228,7 +229,7 @@ function render_getIdentityDefs { # prevent an empty template from being used. It is a missing # assignment definition in the pre-rendition script surely. if [[ "$TEMPLATE" == '' ]];then - cli_printMessage "`eval_gettext "There is no design template defined for \\\`\\\$FILE'."`" 'AsErrorLine' + cli_printMessage "`eval_gettext "There is no design template defined for \\\`\\\${FILE}'."`" 'AsErrorLine' cli_printMessage "$(caller)" "AsToKnowMoreLine" fi @@ -240,7 +241,7 @@ function render_getIdentityDefs { # possible to match many release-specific translations to the same # design template. There is no need to duplicate the release # structure inside design template structure. - TEMPLATE=$(echo $TEMPLATE | sed -r "s!^${RELEASE_FORMAT}/!!") + TEMPLATE=$(echo $TEMPLATE | sed -r "s!^$(cli_getPathComponent '--release-pattern')/!!") # Remove any language from design template's path. Language # code directories are used under Translation structure only. @@ -261,7 +262,7 @@ function render_getIdentityDefs { fi fi - + # Redefine design template using absolute path. if [[ -f $SVG/$(basename $TEMPLATE) ]];then # Generally, template files are stored one level inside @@ -277,7 +278,7 @@ function render_getIdentityDefs { TEMPLATE=$(find $SVG -regextype posix-egrep -regex \ ".*/${TEMPLATE}" | sort | head -n 1) fi - + # Check existence of TEMPLATE file. If design template doesn't # exist we cannot render it; in such case, stop working for it and # try the next one in the list. @@ -302,18 +303,21 @@ function render_getIdentityDefs { # retrived from translations structure. Then we use the common # path as relative path to the image file. # - # The .png.sh file extension is removed from the common path. - # Instead we assign the appropriate file extension when defining - # file name. + # The `.sh' file extension is removed from the common path. + # Instead we use the previous extension, defined in the + # translation files, as file extension. For example, if the + # translation file is file.png.sh, the final file would be + # file.png. Likewise, if the translation file is file.txt.sh, the + # final file would be file.txt. # # When we render using renderImage function, the structure of # files under Img/ directory will be the same of that used after # the common point in its related Translations or Template # directory depending in which one was taken as reference when # LOCATION variable was defined. - FILE=$(echo $FILE \ + FILE=$(echo ${FILE} \ | sed -r "s!.*${PARENTDIR}/!!" \ - | sed -r 's!\.(png\.sh|svg|html|htm)$!!') + | sed -r "s/\.sh$//") # Re-define directory absolute path of final output directory. As # convenction, when we produce content in English language, we do @@ -321,9 +325,9 @@ function render_getIdentityDefs { # we produce content in a language different from English we do # use language-specific directory to organize content. if [[ $(cli_getCurrentLocale) =~ '^en' ]];then - DIRNAME=$IMG/$(dirname $FILE) + DIRNAME=$IMG/$(dirname ${FILE}) else - DIRNAME=$IMG/$(dirname $FILE)/$(cli_getCurrentLocale) + DIRNAME=$IMG/$(dirname ${FILE})/$(cli_getCurrentLocale) fi # Check existence of output image directory. @@ -332,7 +336,7 @@ function render_getIdentityDefs { fi # Define absolute path to file. - FILE=$(echo $DIRNAME/$(basename $FILE) | sed -r 's!/\./!/!') + FILE=$(echo $DIRNAME/$(basename ${FILE}) | sed -r 's!/\./!/!') # Define instance name. INSTANCE=$(cli_getTemporalFile $TEMPLATE) diff --git a/Scripts/Bash/Functions/Render/render_getIdentityDirTemplate.sh b/Scripts/Bash/Functions/Render/render_getIdentityDirTemplate.sh index 230d39e..e54d337 100644 --- a/Scripts/Bash/Functions/Render/render_getIdentityDirTemplate.sh +++ b/Scripts/Bash/Functions/Render/render_getIdentityDirTemplate.sh @@ -53,7 +53,7 @@ function render_getIdentityDirTemplate { # defined in the associated pre-rendition configuration script # and can be used to set which design model to use among a # list of different design models that we can choose from. - SVG=$(echo "$SVG" | sed "s!Motifs/$(cli_getPathComponent '--theme')!Models/$THEMEMODEL!") + SVG=$(echo "$SVG" | sed "s!Motifs/$(cli_getPathComponent "$SVG" '--theme')!Models/$THEMEMODEL!") fi } diff --git a/Scripts/Bash/Functions/Render/render_getIdentityDirTranslation.sh b/Scripts/Bash/Functions/Render/render_getIdentityDirTranslation.sh index e589a50..32442a1 100644 --- a/Scripts/Bash/Functions/Render/render_getIdentityDirTranslation.sh +++ b/Scripts/Bash/Functions/Render/render_getIdentityDirTranslation.sh @@ -30,7 +30,8 @@ function render_getIdentityDirTranslation { TRANSLATIONPATH=${FUNCDIR}/${FUNCDIRNAM}/Config/$ARTCOMP - if [[ "$(find $TRANSLATIONPATH -name '*.png.sh')" == '' ]];then + if [[ "$(find $TRANSLATIONPATH -regextype posix-egrep \ + -regex ".+\.${EXTENSION}$")" == '' ]];then TRANSLATIONPATH='' fi