Blame Scripts/Bash/Functions/Render/render_doIdentityImages.sh

4c79b5
#!/bin/bash
4c79b5
#
07c2fe
# render_doIdentityImages.sh -- This function renders image-based
07c2fe
# identity contents.
4c79b5
#
9f5f2e
# Copyright (C) 2009-2011 Alain Reguera Delgado
4c79b5
# 
7cd8e9
# This program is free software; you can redistribute it and/or
7cd8e9
# modify it under the terms of the GNU General Public License as
7cd8e9
# published by the Free Software Foundation; either version 2 of the
7cd8e9
# License, or (at your option) any later version.
4c79b5
# 
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4c79b5
# USA.
4c79b5
# 
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
4c79b5
function render_doIdentityImages {
4c79b5
4c79b5
    local EXPORTID=''
4c79b5
    local EXTERNALFILES=''
e4d34a
    local EXTERNALFILE=''
4c79b5
4c79b5
    # Export id used inside design templates. This value defines the
4c79b5
    # design area we want to export.
4c79b5
    EXPORTID='CENTOSARTWORK'
4c79b5
15b1d2
    # Start processing the base rendition list of FILES. Fun part
4c79b5
    # approching :-).
4c79b5
    for FILE in $FILES; do
4c79b5
4c79b5
        # Call shared variable re-definitions.
4c79b5
        render_getIdentityDefs
4c79b5
4c79b5
        # Check export id inside design templates.
4c79b5
        grep "id=\"$EXPORTID\"" $INSTANCE > /dev/null
4c79b5
        if [[ $? -gt 0 ]];then
2d50e8
            cli_printMessage "`eval_gettext "Can't found the export id (\\\$EXPORTID) inside \\\$TEMPLATE."`" "AsErrorLine"
15b1d2
            cli_printMessage '-' 'AsSeparatorLine'
4c79b5
            continue
4c79b5
        fi
4c79b5
4c79b5
        # Define final image width. If FILE name is a number, asume it
4c79b5
        # as the width value of the image being rendered. Otherwise
4c79b5
        # use design template default width value.
4c79b5
        WIDTH=$(basename $FILE)
4c79b5
        if [[ $WIDTH =~ '^[0-9]+$' ]];then
4c79b5
            WIDTH="--export-width=$WIDTH" 
4c79b5
        else
4c79b5
            WIDTH=''
4c79b5
        fi
e287e0
        
34fcce
        # Check existence of external files. In order for design
34fcce
        # templates to point different artistic motifs, design
34fcce
        # templates make use of external files that point to specific
34fcce
        # artistic motif background images. If such external files
34fcce
        # doesn't exist, print a message and stop script execution.
34fcce
        # We cannot continue wihtout the background information.
34fcce
        EXTERNALFILES="(xlink:href|sodipodi:absref)=\"$(cli_getRepoTLDir $TEMPLATE)"
34fcce
        EXTERNALFILES=$(egrep "${EXTERNALFILES}" "${INSTANCE}" \
4c79b5
            | sed -r 's!^[[:space:]]+!!' \
4c79b5
            | sed -r 's!^(xlink:href|sodipodi:absref)="!!' \
b76c02
            | sed -r 's!".*$!!' | sort | uniq)
e4d34a
        for EXTERNALFILE in $EXTERNALFILES;do
e4d34a
            cli_checkFiles $EXTERNALFILE
e4d34a
        done
4c79b5
4c79b5
        # Render template instance and modify the inkscape output to
4c79b5
        # reduce the amount of characters used in description column
4c79b5
        # at final output.
2d50e8
        cli_printMessage "$(inkscape $INSTANCE \
2d50e8
            --export-id=$EXPORTID $WIDTH --export-png=$FILE.png | sed -r \
2d50e8
            -e "s!Area !`gettext "Area"`: !" \
2d50e8
            -e "s!Background RRGGBBAA:!`gettext "Background"`: RRGGBBAA!" \
2d50e8
            -e "s!Bitmap saved as:!`gettext "Saved as"`:!")" \
2d50e8
            'AsRegularLine'
4c79b5
4c79b5
        # Remove template instance. 
4c79b5
        if [[ -a $INSTANCE ]];then
4c79b5
            rm $INSTANCE
4c79b5
        fi
4c79b5
15b1d2
        # Execute post-rendition actions.
f3bce7
        for ACTION in "${POSTACTIONS[@]}"; do
4c79b5
4c79b5
            case "$ACTION" in
4c79b5
46f314
                renderSyslinux* )
2d50e8
                    render_doIdentityImageSyslinux "$FILE" "$ACTION"
4c79b5
                    ;;
4c79b5
46f314
                renderGrub* )
2d50e8
                    render_doIdentityImageGrub "$FILE" "$ACTION"
4c79b5
                    ;;
4c79b5
4c79b5
                renderFormats:* )
2d50e8
                    render_doIdentityImageFormats "$FILE" "$ACTION"
4c79b5
                    ;;
4c79b5
4c79b5
                renderBrands:* )
4c79b5
                    render_doIdentityImageBrands "$FILE" "$ACTION"
4c79b5
                    ;;
4c79b5
ff3ea9
                groupByType:* )
ff3ea9
                    render_doIdentityGroupByType "$FILE" "$ACTION"
4c79b5
                    ;;
4c79b5
4c79b5
            esac
4c79b5
4c79b5
        done
4c79b5
15b1d2
        # Output separator line.
15b1d2
        cli_printMessage '-' 'AsSeparatorLine'
4c79b5
2d50e8
    done
f3bce7
2d50e8
    # Define and execute possible last-rendition actions for image
eb0e14
    # rendeirng base action.
f3bce7
    for ACTION in "${LASTACTIONS[@]}"; do
f3bce7
f3bce7
        case "$ACTION" in
f3bce7
640a79
            renderKSplash )
640a79
                render_doIdentityImageKsplash
f3bce7
                ;;
f3bce7
eb0e14
            renderDm:* )
eb0e14
                render_doIdentityImageDm "$ACTION"
ae8a10
                ;;
ae8a10
ff3ea9
            groupByType:* )
ff3ea9
                render_doIdentityGroupByType "$ACTION"
ff3ea9
                ;;
ff3ea9
f3bce7
        esac
f3bce7
f3bce7
    done
4c79b5
4c79b5
}