diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_getConfig.sh b/Scripts/Bash/Cli/Functions/Identity/identity_getConfig.sh index fe459a6..cf7f393 100755 --- a/Scripts/Bash/Cli/Functions/Identity/identity_getConfig.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_getConfig.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# identity_getConfig.sh -- This function checks/validates variables -# passed from artwork-specific pre-rendition configuration files. +# identity_getConfig.sh -- This function retrives values set in +# pre-rendition configuration files. # # Copyright (C) 2009-2011 Alain Reguera Delgado # @@ -26,8 +26,7 @@ function identity_getConfig { - local POSTCOUNT=0 - local LASTCOUNT=0 + local COUNT=0 # Re-define action variables in separated array variables. Once # verification is done, we remove the BASE, POST, LAST parts from @@ -35,19 +34,20 @@ function identity_getConfig { # call. for ACTION in "${ACTIONS[@]}"; do - # Define post-rendition actions. if [[ $ACTION =~ '^POST:' ]];then - ACTION=$(identity_getConfigOption "$ACTION" '2-') - POSTACTIONS[$POSTCOUNT]="$ACTION" - POSTCOUNT=$(($POSTCOUNT + 1)) - - # Define last-rendition actions. + # Define post-rendition action. + POSTACTIONS[$COUNT]=$(identity_getConfigOption "$ACTION" '2-') elif [[ $ACTION =~ '^LAST:' ]];then - ACTION=$(identity_getConfigOption "$ACTION" '2-') - LASTACTIONS[$LASTCOUNT]="$ACTION" - LASTCOUNT=$(($LASTCOUNT + 1)) + # Define last-rendition action. + LASTACTIONS[$COUNT]=$(identity_getConfigOption "$ACTION" '2-') + else + cli_printMessage "`gettext "The base-rendition action you specified is not supported yet."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' fi + # Increment counter. + COUNT=$(($COUNT + 1)) + done # Sanitate theme model value using repository directory name diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderBase.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderBase.sh index 9f88931..63074a4 100755 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderBase.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderBase.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# identity_renderBase.sh -- This function initiates base rendition -# using pre-rendition configuration files. +# identity_renderBase.sh -- This function performs base-rendition +# action for all files. # # Copyright (C) 2009-2011 Alain Reguera Delgado # @@ -26,18 +26,24 @@ function identity_renderBase { + local -a FILES local FILE='' - local FILES='' local OUTPUT='' - local EXPORTID='' local TEMPLATE='' - local COMMONDIR='' local PARENTDIR='' + local EXTENSION='' local TRANSLATION='' local EXTERNALFILE='' local EXTERNALFILES='' - local COMMONDIRCOUNT=0 - local -a COMMONDIRS + local THIS_FILE_DIR='' + local NEXT_FILE_DIR='' + local COUNT=0 + + # 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}") @@ -45,31 +51,42 @@ function identity_renderBase { # Define base location of template files. identity_getDirTemplate - # Define list of files to process. - FILES=$(cli_getFilesList "${TEMPLATE}" "${FLAG_FILTER}.*\.(svgz|svg)") + # Define list of files to process as array variable. This make + # posible to realize verifications like: is the current base + # directory equal to the next one in the list of files to process? + # This is used to know when centos-art.sh is leaving a directory + # structure and entering into another. This information is + # required in order for centos-art.sh to know when to apply + # last-rendition actions. + for FILE in $(cli_getFilesList "${TEMPLATE}" "${FLAG_FILTER}.*${EXTENSION}");do + FILES[$COUNT]=$FILE + COUNT=$(($COUNT + 1)) + done # Set action preamble. - cli_printActionPreamble "$FILES" - - # Define common absolute paths in order to know when centos-art.sh - # is leaving a directory structure and entering into another. This - # information is required in order for centos-art.sh to know when - # to apply last-rendition actions. - for COMMONDIR in $(dirname "$FILES" | sort | uniq);do - COMMONDIRS[$COMMONDIRCOUNT]=$(dirname "$COMMONDIR") - COMMONDIRCOUNT=$(($COMMONDIRCOUNT + 1)) - done + cli_printActionPreamble "${FILES[@]}" # Reset common directory counter. - COMMONDIRCOUNT=0 - - # Define export id used inside design templates. This value - # defines the design area we want to export. - EXPORTID='CENTOSARTWORK' + COUNT=0 # Start processing the base rendition list of FILES. Fun part # approching :-). - for FILE in $FILES; do + while [[ $COUNT -lt ${#FILES[*]} ]];do + + # Define base file. + FILE=${FILES[$COUNT]} + + # Define the base directory path for the current file being + # process. + THIS_FILE_DIR=$(dirname ${FILES[$COUNT]}) + + # Define the base directory path for the next file that will + # be process. + if [[ $(($COUNT + 1)) -lt ${#FILES[*]} ]];then + NEXT_FILE_DIR=$(dirname ${FILES[$(($COUNT + 1))]}) + else + NEXT_FILE_DIR='' + fi # Print separator line. cli_printMessage '-' 'AsSeparatorLine' @@ -128,7 +145,7 @@ function identity_renderBase { # structure. FILE=$(echo ${FILE} \ | sed -r "s!.*${PARENTDIR}/!!" \ - | sed -r "s/\.(svgz|svg)$//") + | sed -r "s/${EXTENSION}$//") # Define absolute path to final file (without extension). FILE=${OUTPUT}/$(basename "${FILE}") @@ -136,6 +153,8 @@ function identity_renderBase { # Define instance name from design model. INSTANCE=$(cli_getTemporalFile ${TEMPLATE}) + # Verify translation file existence and create template + # instance accordingly. if [[ -f ${TRANSLATION} ]];then # Create translated instance from design model. @@ -147,80 +166,55 @@ function identity_renderBase { fi else - # Create non-translated instance form design model. /bin/cat ${TEMPLATE} > ${INSTANCE} - fi - # Apply replacement of translation markers to design model - # translated instance. + # Apply translation markers replacements to template instance. cli_replaceTMarkers ${INSTANCE} - # Check export id inside design templates. - grep "id=\"$EXPORTID\"" $INSTANCE > /dev/null - if [[ $? -gt 0 ]];then - cli_printMessage "`eval_gettext "There is no export id (\\\$EXPORTID) inside \\\$TEMPLATE."`" "AsErrorLine" - cli_printMessage '-' 'AsSeparatorLine' - continue - fi + # Verify the extension of template instance and render content + # accordingly. + if [[ $INSTANCE =~ '\.(svgz|svg)$' ]];then + + # Perform base-rendition action for svg files. + identity_renderSvg + + # Perform post-rendition action for svg files. + identity_renderSvgPostActions + + # Perform last-rendition action for svg files. + identity_renderSvgLastActions + + #elif [[ $INSTANCE =~ '\.docbook$' ]];then + + # Perform base-rendition action for docbook files. + #identity_renderDocbook + + # Perform post-rendition action for docbook files. + #identity_renderDocbookPostActions - # Check existence of external files. In order for design - # templates to point different artistic motifs, design - # templates make use of external files that point to specific - # artistic motif background images. If such external files - # doesn't exist, print a message and stop script execution. - # We cannot continue without background information. - identity_checkAbsolutePaths "$INSTANCE" - - # Render template instance and modify the inkscape output to - # reduce the amount of characters used in description column - # at final output. - cli_printMessage "$(inkscape $INSTANCE \ - --export-id=$EXPORTID --export-png=${FILE}.png | sed -r \ - -e "s!Area !`gettext "Area"`: !" \ - -e "s!Background RRGGBBAA:!`gettext "Background"`: RRGGBBAA!" \ - -e "s!Bitmap saved as:!`gettext "Saved as"`:!")" \ - 'AsRegularLine' + # Perform base-rendition action for docbook files. + #identity_renderDocbookLastActions + + else + cli_printMessage "`gettext "The template extension you try to render is not supported yet."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi # Remove template instance. - if [[ -a $INSTANCE ]];then + if [[ -f $INSTANCE ]];then rm $INSTANCE fi - # Execute post-rendition actions. + # Perform post-rendition actions for all files. identity_renderPostActions - # Verify position of file being produced in the list of files - # been currently processed. As convenction, last-rendition - # actions are applied after all images inside the same - # directory structure have being produced. Notice that, in - # order to apply last-rendition actions correctly, - # centos-art.sh needs to "predict" what the last file in the - # same directory structure would be. There is no magic here, - # so we need to previously define which are the common - # directory structures centos-art.sh could produce content for - # inside an array variable. Later, using the index of that - # array variable we could check the next item in the array - # against the file being currently produced. If they match, we - # haven't reached the end of the same directory structure, but - # if they don't match, we do have reach the end of the same - # directory structure and it is time for last-rendition - # actions to be evaluated before go producing the next - # directory structure in the list of files to process. - if [[ $(dirname "$TEMPLATE") != ${COMMONDIRS[$(($COMMONDIRCOUNT + 1))]} ]];then - - # At this point centos-art.sh should be producing the last - # file from the same unique directory structure, so, - # before producing images for the next directory structure - # lets execute last-rendition actions for the current - # directory structure. - identity_renderLastActions - - fi + # Perform last-rendition actions for all files. + identity_renderLastActions - # Increment common directory counter. - COMMONDIRCOUNT=$(($COMMONDIRCOUNT + 1)) + # Increment file counter. + COUNT=$(($COUNT + 1)) done diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderDm.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderDm.sh index bc7780e..5fe2525 100755 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderDm.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderDm.sh @@ -56,6 +56,9 @@ function identity_renderDm { local RESOLUTION='' local RESOLUTIONS='' + # Print separator line. + cli_printMessage '-' 'AsSeparatorLine' + # Get display manager passed from render.conf.sh pre-rendition # configuration script. DM=$(identity_getConfigOption "${ACTION}" '2') @@ -185,7 +188,4 @@ function identity_renderDm { # Return to where we were initially. popd > /dev/null - # Output division rule. - cli_printMessage '-' 'AsSeparatorLine' - } diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderKsplash.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderKsplash.sh index f88f0e9..0c46040 100755 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderKsplash.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderKsplash.sh @@ -77,7 +77,4 @@ function identity_renderKsplash { # Apply common translation markers to Theme.rc file. cli_replaceTMarkers "${DST[4]}" - # Print separator line. - cli_printMessage '-' 'AsSeparatorLine' - } diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderLastActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderLastActions.sh index 0311b5d..bfc0038 100755 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderLastActions.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderLastActions.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# identity_renderLastActions.sh -- This function executes -# last-rendition actions. +# identity_renderLastActions.sh -- This function performs +# last-rendition actions for all files. # # Copyright (C) 2009-2011 Alain Reguera Delgado # @@ -28,23 +28,26 @@ function identity_renderLastActions { local ACTION='' - for ACTION in "${LASTACTIONS[@]}"; do + # Verify position of file being produced in the list of files been + # currently processed. + if [[ $THIS_FILE_DIR != $NEXT_FILE_DIR ]];then - case "${ACTION}" in + # At this point centos-art.sh should be producing the last + # file from the same unique directory structure, so, before + # producing images for the next directory structure lets + # execute last-rendition actions for the current directory + # structure. + for ACTION in "${LASTACTIONS[@]}"; do - renderKSplash ) - identity_renderKsplash - ;; + case "${ACTION}" in - renderDm:* ) - identity_renderDm - ;; + groupByType:* ) + identity_renderGroupByType + ;; + esac - groupByType:* ) - identity_renderGroupByType - ;; - esac + done - done + fi } diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh index 4cde273..62e912a 100755 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# identity_renderPostActions.sh -- This function executes -# post-rendition actions. +# identity_renderPostActions.sh -- This function performs +# post-rendition actions for all files. # # Copyright (C) 2009-2011 Alain Reguera Delgado # @@ -32,26 +32,10 @@ function identity_renderPostActions { case "${ACTION}" in - renderSyslinux* ) - identity_renderSyslinux - ;; - - renderGrub* ) - identity_renderGrub - ;; - - renderFormats:* ) - identity_renderFormats - ;; - groupByType:* ) identity_renderGroupByType ;; - renderBrands ) - identity_renderBrands - ;; - esac done diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderSvg.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderSvg.sh new file mode 100644 index 0000000..d13e9a8 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderSvg.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# identity_renderSvg.sh -- This function performs base-rendition +# action for SVG files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function identity_renderSvg { + + # Define export id used inside design templates. This value + # defines the design area we want to export. + local EXPORTID='CENTOSARTWORK' + + # Check export id inside design templates. + grep "id=\"$EXPORTID\"" $INSTANCE > /dev/null + if [[ $? -gt 0 ]];then + cli_printMessage "`eval_gettext "There is no export id (\\\$EXPORTID) inside \\\$TEMPLATE."`" "AsErrorLine" + cli_printMessage '-' 'AsSeparatorLine' + continue + fi + + # Check existence of external files. Inside design templates and + # their instances, external files are used to refere the + # background information required by the design template. If such + # background information is not available the image is produced + # without background information. This is something that need to + # be avoided. + identity_checkAbsolutePaths "$INSTANCE" + + # Render template instance using inkscape. Modify the inkscape + # output to reduce the amount of characters used in description + # column at final output. + cli_printMessage "$(inkscape $INSTANCE \ + --export-id=$EXPORTID --export-png=${FILE}.png | sed -r \ + -e "s!Area !`gettext "Area"`: !" \ + -e "s!Background RRGGBBAA:!`gettext "Background"`: RRGGBBAA!" \ + -e "s!Bitmap saved as:!`gettext "Saved as"`:!")" 'AsRegularLine' + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgLastActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgLastActions.sh new file mode 100644 index 0000000..caf9281 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgLastActions.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# +# identity_renderSvgLastActions.sh -- This function performs +# last-rendition actions for SVG files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function identity_renderSvgLastActions { + + local ACTION='' + + # Verify position of file being produced in the list of files been + # currently processed. + if [[ $THIS_FILE_DIR != $NEXT_FILE_DIR ]];then + + # At this point centos-art.sh should be producing the last + # file from the same unique directory structure, so, before + # producing images for the next directory structure lets + # execute last-rendition actions for the current directory + # structure. + for ACTION in "${LASTACTIONS[@]}"; do + + case "${ACTION}" in + + renderKSplash ) + identity_renderKsplash + ;; + + renderDm:* ) + identity_renderDm + ;; + + esac + + done + + fi + +} + diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgPostActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgPostActions.sh new file mode 100644 index 0000000..95a3eab --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderSvgPostActions.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# identity_renderSvgPostActions.sh -- This function performs +# post-rendition actions for SVG files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function identity_renderSvgPostActions { + + local ACTION='' + + for ACTION in "${POSTACTIONS[@]}"; do + + case "${ACTION}" in + + renderSyslinux* ) + identity_renderSyslinux + ;; + + renderGrub* ) + identity_renderGrub + ;; + + renderFormats:* ) + identity_renderFormats + ;; + + renderBrands ) + identity_renderBrands + ;; + + esac + + done + +}