From 2948421fa226ad6a4bdb86529f664c10d10c3168 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Mar 07 2011 16:13:03 +0000 Subject: Update `identity' functionality: - Remove pre-rendition configuration script parsing from identity_render. Command-line options will be used instead, to control post-rendition and last-rendition actions. - Move identity_renderBase to identity_render and remove identity_renderBase. - Rename THEMEMODEL variable to FLAG_THEME_MODEL. Put its initial definition in identity.sh. --- diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Brands/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Brands/render.conf.sh index d9bb979..9dad3a9 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Brands/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Brands/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. ACTIONS[0]='LAST:renderBrands' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Fonts/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Fonts/render.conf.sh index 8f03a3a..b927151 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Fonts/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Fonts/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. ACTIONS[0]='POST:renderFormats: jpg pdf' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Models/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Models/render.conf.sh index 5c40a17..f56cc8f 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Models/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Models/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. ACTIONS[0]='POST:renderFormats: pdf jpg' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Backgrounds/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Backgrounds/render.conf.sh index 0f659be..4046ad6 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Backgrounds/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Backgrounds/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. ACTIONS[0]='POST:renderFormats: jpg' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Concept/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Concept/render.conf.sh index 632c8f9..45669e1 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Concept/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Concept/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. ACTIONS[0]='POST:renderFormats: jpg pdf' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Anaconda/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Anaconda/render.conf.sh index 417c8b1..a93fe9c 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Anaconda/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Anaconda/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. #ACTIONS[0]='' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Firstboot/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Firstboot/render.conf.sh index b5fe32a..a1724c9 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Firstboot/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Firstboot/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. #ACTIONS[0]='' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Gdm/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Gdm/render.conf.sh index 6d7d094..f280e46 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Gdm/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Gdm/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. ACTIONS[0]="LAST:renderDm:Gdm:800x600 1024x768 1280x1024 1360x768 \ diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Grub/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Grub/render.conf.sh index 59e1a10..4572333 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Grub/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Grub/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. ACTIONS[0]='POST:renderGrub:' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Gsplash/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Gsplash/render.conf.sh index ed9d313..1cec9de 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Gsplash/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Gsplash/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. #ACTIONS[0]='' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Kdm/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Kdm/render.conf.sh index d241e51..5971419 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Kdm/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Kdm/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. ACTIONS[0]="LAST:renderDm:Kdm:800x600 1024x768 1280x1024 1360x768 \ diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Ksplash/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Ksplash/render.conf.sh index a0aa21a..24fe8b4 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Ksplash/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Ksplash/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. ACTIONS[0]='LAST:renderKSplash' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Rhgb/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Rhgb/render.conf.sh index 60a4a49..3125fb2 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Rhgb/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Rhgb/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. #ACTIONS[0]='' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Syslinux/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Syslinux/render.conf.sh index f91cc69..955eb57 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Syslinux/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Distro/5/Syslinux/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. ACTIONS[0]='POST:renderSyslinux:' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Promo/Releases/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Promo/Releases/render.conf.sh index f4b6862..de304c3 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Promo/Releases/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Promo/Releases/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. #ACTIONS[0]='' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Promo/Stationery/Media/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Promo/Stationery/Media/render.conf.sh index ef6ec48..f64ad09 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Promo/Stationery/Media/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Promo/Stationery/Media/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. #ACTIONS[0]='' diff --git a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Promo/Stationery/Posters/render.conf.sh b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Promo/Stationery/Posters/render.conf.sh index c63754b..d9c610a 100755 --- a/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Promo/Stationery/Posters/render.conf.sh +++ b/Scripts/Bash/Cli/Functions/Identity/Config/Identity/Themes/Promo/Stationery/Posters/render.conf.sh @@ -27,7 +27,7 @@ function identity_loadConfig { # Deifne theme model. - #THEMEMODEL='Default' + #FLAG_THEME_MODEL='Default' # Define rendition actions. ACTIONS[0]='POST:renderFormats: pdf jpg' diff --git a/Scripts/Bash/Cli/Functions/Identity/identity.sh b/Scripts/Bash/Cli/Functions/Identity/identity.sh index e66e31c..fdeeb1b 100644 --- a/Scripts/Bash/Cli/Functions/Identity/identity.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity.sh @@ -1,8 +1,7 @@ #!/bin/bash # -# render.sh -- This function provides rendition features to -# centos-art.sh script. Here we initialize rendition variables and -# call identity_getActions functions. +# identity.sh -- This function initializes rendition variables and +# actions to centos-art.sh script. # # Copyright (C) 2009-2011 Alain Reguera Delgado # @@ -41,6 +40,10 @@ function identity { # for. By default no architecture type is used. local FLAG_ARCHITECTURE='' + # Define theme model flag. The theme model flag (--theme-model) + # specifies the theme model used when no one is specified. + local FLAG_THEME_MODEL='Default' + # Define rendition actions. identity_getActions diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_getConfig.sh b/Scripts/Bash/Cli/Functions/Identity/identity_getConfig.sh index cf7f393..dea6e48 100755 --- a/Scripts/Bash/Cli/Functions/Identity/identity_getConfig.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_getConfig.sh @@ -52,9 +52,9 @@ function identity_getConfig { # Sanitate theme model value using repository directory name # convenction. - THEMEMODEL=$(cli_getRepoName "$THEMEMODEL" 'd') + FLAG_THEME_MODEL=$(cli_getRepoName "$THEMEMODEL" 'd') # Check theme model directory. - cli_checkFiles "$(cli_getRepoTLDir)/Identity/Themes/Models/${THEMEMODEL}" 'd' + cli_checkFiles "$(cli_getRepoTLDir)/Identity/Themes/Models/${FLAG_THEME_MODEL}" 'd' } diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_getDirOutput.sh b/Scripts/Bash/Cli/Functions/Identity/identity_getDirOutput.sh index e28cbd4..2149416 100644 --- a/Scripts/Bash/Cli/Functions/Identity/identity_getDirOutput.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_getDirOutput.sh @@ -32,7 +32,7 @@ function identity_getDirOutput { # immediatly under identity entry structure, but if `Img/' # directory exists use it instead. OUTPUT=$(dirname $FILE | sed -r \ - -e "s!/Models/${THEMEMODEL}!/Motifs/$(cli_getPathComponent "$ACTIONVAL" "--theme")!" \ + -e "s!/Models/${FLAG_THEME_MODEL}!/Motifs/$(cli_getPathComponent "$ACTIONVAL" "--theme")!" \ -e "s!/Tpl!/Img!") # Redefine base output directory to introduce specific information diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_getDirTemplate.sh b/Scripts/Bash/Cli/Functions/Identity/identity_getDirTemplate.sh index e6c1ef5..fa63110 100644 --- a/Scripts/Bash/Cli/Functions/Identity/identity_getDirTemplate.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_getDirTemplate.sh @@ -49,12 +49,12 @@ function identity_getDirTemplate { TEMPLATE=$TEMPLATE/Tpl else # Redefine design model location based on theme model - # (THEMEMODEL) variable value. The theme model variable is + # (FLAG_THEME_MODEL) variable value. The theme model variable is # 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. TEMPLATE=$(echo "$TEMPLATE" \ - | sed "s!Motifs/$(cli_getPathComponent "$TEMPLATE" '--theme')!Models/$THEMEMODEL!") + | sed "s!Motifs/$(cli_getPathComponent "$TEMPLATE" '--theme')!Models/$FLAG_THEME_MODEL!") fi } diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_render.sh b/Scripts/Bash/Cli/Functions/Identity/identity_render.sh index bcf7966..4acb8a5 100755 --- a/Scripts/Bash/Cli/Functions/Identity/identity_render.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_render.sh @@ -1,10 +1,7 @@ #!/bin/bash # -# identity_render.sh -- This function initiates rendition -# configuration functions and executes them to perform the rendition -# action specified in the `ACTIONS' array variable. Function -# initialization and execution is based on the absolute path -# convenction defined by ARTCONF variable. +# identity_render.sh -- This function performs base-rendition action +# for all files. # # Copyright (C) 2009-2011 Alain Reguera Delgado # @@ -29,87 +26,195 @@ function identity_render { + local -a FILES local FILE='' + local OUTPUT='' + local TEMPLATE='' + local PARENTDIR='' + local EXTENSION='' + local TRANSLATION='' + local EXTERNALFILE='' + local EXTERNALFILES='' + 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}") + + # Define base location of template files. + identity_getDirTemplate + + # 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[*]}" '' '' - # Initialize artwork identification. - local ARTCOMP='' + # Reset common directory counter. + COUNT=0 - # Define default theme model. - local THEMEMODEL='Default' + # Start processing the base rendition list of FILES. Fun part + # approching :-). + while [[ $COUNT -lt ${#FILES[*]} ]];do - # Build list of files to process. - local FILES=$(cli_getFilesList "$ARTCONF" ".*/?render\.conf\.sh") + # Define base file. + FILE=${FILES[$COUNT]} - # Set action preamble. - cli_printActionPreamble "$FILES" '' '' + # Define the base directory path for the current file being + # process. + THIS_FILE_DIR=$(dirname ${FILES[$COUNT]}) - # Process list of files. - for FILE in $FILES;do + # 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' - # Output action message. - cli_printMessage $FILE 'AsConfigurationLine' - - # Define artwork-specific action arrays. We need to do this - # here because ACTIONS variable is unset after - # identity_renders execution. Otherwise, undesired - # concatenations may occur. - local -a ACTIONS - local -a POSTACTIONS - local -a LASTACTIONS - - # Initialize artwork-specific pre-rendition configuration - # (function) scripts. - . $FILE - - # Execute artwork-specific pre-rendition configuration - # (function) scripts to re-define artwork-specific ACTIONS. - identity_loadConfig - - # Check variables passed from artwork-specific pre-rendition - # configuration scripts and make required transformations. - identity_getConfig - - # Redefine action value (ACTIONVAL) based on pre-rendition - # configuration script path value. Otherwise, massive - # rendition may fail. Functions like renderImage need to know - # the exact artwork path (that is, where images will be - # stored). - ACTIONVAL=$(dirname $(echo $FILE | sed -r \ - -e 's!/Scripts/Bash/Cli/Functions/Identity/Config/(Identity)!/\1!' \ - -e "s!/Themes!/Themes/Motifs/$(cli_getPathComponent '--theme')!" )) - - # Redefine artwork identification using redefined action - # value. - ARTCOMP=$(echo $ACTIONVAL | cut -d/ -f6-) - - # Remove motif name from artwork identification in order to - # reuse motif artwork identification. There is not need to - # create one artwork identification for each motif directory - # structure if we can reuse just one. - ARTCOMP=$(echo $ARTCOMP \ - | sed -r "s!Themes/Motifs/$(cli_getPathComponent '--theme')/!Themes/!") - - # Initiate base rendition using pre-rendition configuration - # files. - identity_renderBase - - # Unset artwork-specific actions so they can be redefined by - # artwork-specific pre-rendition configuration scripts. This - # is required in massive rendition. For example, if you say - # centos-art.sh to render the whole Distro directory it first - # renders Prompt entry, which defines the renderSyslinux - # post-rendition action, and later Progress entry which does - # not defines post-rendition actions. If we do not unset the - # ACTIONS variable, post-rendition actions defined in Prompt - # entry remain for Progress entry and that is not desired. We - # want ACTIONS to do what we exactly tell it to do inside each - # artwork-specific pre-rendition configuration script. - unset ACTIONS - unset POSTACTIONS - unset LASTACTIONS + # Define final location of translation file. + TRANSLATION=$(dirname $FILE \ + | sed -r 's!/trunk/(Identity/)!/trunk/Locales/\1!')/$(cli_getCurrentLocale).po + + # Print final location of translation file. + if [[ ! -f "$TRANSLATION" ]];then + cli_printMessage "`gettext "None"`" "AsTranslationLine" + else + cli_printMessage "$TRANSLATION" 'AsTranslationLine' + fi + + # Define final location of template file. + TEMPLATE=${FILE} + + # Print final location of template file. + if [[ ! -f "$TEMPLATE" ]];then + cli_printMessage "`gettext "None"`" "AsDesignLine" + else + cli_printMessage "$TEMPLATE" 'AsDesignLine' + fi + + # Define final location of output directory. + identity_getDirOutput + + # Get relative path to file. The path string (stored in FILE) + # has two parts: 1. the variable path and 2. the common path. + # The variable path is before the common point in the path + # string. The common path is after the common point in the + # path string. The common point is the name of the parent + # directory (stored in PARENTDIR). + # + # trunk/Locales/Identity/.../Firstboot/3/splash-small.svg + # -------------------------^| the |^------------^ + # variable path | common | common path + # -------------------------v| point | v------------v + # trunk/Identity/Themes/M.../Firstboot/Img/3/splash-small.png + # + # What we do here is remove the varibale path, the common + # point, and the file extension parts in the string holding + # the path retrived from design models directory structure. + # Then we use the common path as relative path to store the + # the final image file. + # + # The file extension is removed from the common path because + # it is set when we create the final image file. This + # configuration let us use different extensions for the same + # file name. + # + # When we render using renderImage function, the structure of + # files under the output directory will be the same used after + # the common point in the related design model directory + # structure. + FILE=$(echo ${FILE} \ + | sed -r "s!.*${PARENTDIR}/!!" \ + | sed -r "s/${EXTENSION}$//") + + # Define absolute path to final file (without extension). + FILE=${OUTPUT}/$(basename "${FILE}") + + # 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. + /usr/bin/xml2po -p ${TRANSLATION} ${TEMPLATE} > ${INSTANCE} + + # Remove .xml2po.mo temporal file. + if [[ -f ${PWD}/.xml2po.mo ]];then + rm ${PWD}/.xml2po.mo + fi + + else + # Create non-translated instance form design model. + /bin/cp ${TEMPLATE} ${INSTANCE} + fi + + # Apply translation markers replacements to template instance. + cli_replaceTMarkers ${INSTANCE} + + # 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 + + # 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 [[ -f $INSTANCE ]];then + rm $INSTANCE + fi + + # Perform post-rendition actions for all files. + identity_renderPostActions + + # Perform last-rendition actions for all files. + identity_renderLastActions + + # Increment file counter. + COUNT=$(($COUNT + 1)) done diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderBase.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderBase.sh deleted file mode 100755 index 5dfe729..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderBase.sh +++ /dev/null @@ -1,221 +0,0 @@ -#!/bin/bash -# -# identity_renderBase.sh -- This function performs base-rendition -# action for all 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_renderBase { - - local -a FILES - local FILE='' - local OUTPUT='' - local TEMPLATE='' - local PARENTDIR='' - local EXTENSION='' - local TRANSLATION='' - local EXTERNALFILE='' - local EXTERNALFILES='' - 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}") - - # Define base location of template files. - identity_getDirTemplate - - # 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[*]}" '' '' - - # Reset common directory counter. - COUNT=0 - - # Start processing the base rendition list of FILES. Fun part - # approching :-). - 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' - - # Define final location of translation file. - TRANSLATION=$(dirname $FILE \ - | sed -r 's!/trunk/(Identity/)!/trunk/Locales/\1!')/$(cli_getCurrentLocale).po - - # Print final location of translation file. - if [[ ! -f "$TRANSLATION" ]];then - cli_printMessage "`gettext "None"`" "AsTranslationLine" - else - cli_printMessage "$TRANSLATION" 'AsTranslationLine' - fi - - # Define final location of template file. - TEMPLATE=${FILE} - - # Print final location of template file. - if [[ ! -f "$TEMPLATE" ]];then - cli_printMessage "`gettext "None"`" "AsDesignLine" - else - cli_printMessage "$TEMPLATE" 'AsDesignLine' - fi - - # Define final location of output directory. - identity_getDirOutput - - # Get relative path to file. The path string (stored in FILE) - # has two parts: 1. the variable path and 2. the common path. - # The variable path is before the common point in the path - # string. The common path is after the common point in the - # path string. The common point is the name of the parent - # directory (stored in PARENTDIR). - # - # trunk/Locales/Identity/.../Firstboot/3/splash-small.svg - # -------------------------^| the |^------------^ - # variable path | common | common path - # -------------------------v| point | v------------v - # trunk/Identity/Themes/M.../Firstboot/Img/3/splash-small.png - # - # What we do here is remove the varibale path, the common - # point, and the file extension parts in the string holding - # the path retrived from design models directory structure. - # Then we use the common path as relative path to store the - # the final image file. - # - # The file extension is removed from the common path because - # it is set when we create the final image file. This - # configuration let us use different extensions for the same - # file name. - # - # When we render using renderImage function, the structure of - # files under the output directory will be the same used after - # the common point in the related design model directory - # structure. - FILE=$(echo ${FILE} \ - | sed -r "s!.*${PARENTDIR}/!!" \ - | sed -r "s/${EXTENSION}$//") - - # Define absolute path to final file (without extension). - FILE=${OUTPUT}/$(basename "${FILE}") - - # 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. - /usr/bin/xml2po -p ${TRANSLATION} ${TEMPLATE} > ${INSTANCE} - - # Remove .xml2po.mo temporal file. - if [[ -f ${PWD}/.xml2po.mo ]];then - rm ${PWD}/.xml2po.mo - fi - - else - # Create non-translated instance form design model. - /bin/cp ${TEMPLATE} ${INSTANCE} - fi - - # Apply translation markers replacements to template instance. - cli_replaceTMarkers ${INSTANCE} - - # 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 - - # 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 [[ -f $INSTANCE ]];then - rm $INSTANCE - fi - - # Perform post-rendition actions for all files. - identity_renderPostActions - - # Perform last-rendition actions for all files. - identity_renderLastActions - - # Increment file counter. - COUNT=$(($COUNT + 1)) - - done - -}