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

4c79b5
#!/bin/bash
4c79b5
#
4c79b5
# render_doIdentityImages.sh -- This function provides image
4c79b5
# rendering feature to centos-art.sh script.
4c79b5
#
4c79b5
# Copyright (C) 2009-2010 Alain Reguera Delgado
4c79b5
# 
4c79b5
# This program is free software; you can redistribute it and/or modify
4c79b5
# it under the terms of the GNU General Public License as published by
4c79b5
# the Free Software Foundation; either version 2 of the License, or
4c79b5
# (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
# ----------------------------------------------------------------------
4c79b5
# $Id: render_doIdentityImages.sh 96 2010-09-19 06:39:32Z al $
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
4c79b5
    # Start processing the base rendering 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
4c79b5
            cli_printMessage "`eval_gettext "The export id (\\\$EXPORTID) was not found inside \\\$TEMPLATE."`" "AsErrorLine"
4c79b5
            echo '----------------------------------------------------------------------'
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
4c79b5
4c79b5
        # Check =THEME= translation marker existence inside design
4c79b5
        # template instance and replace it with the name of the theme
4c79b5
        # being rendered.
4c79b5
        grep "=THEME=" $INSTANCE > /dev/null
4c79b5
        if [[ $? -eq 0 ]];then
4c79b5
            sed -i -e "s!=THEME=!$(cli_getThemeName)!g" $INSTANCE
4c79b5
        fi
4c79b5
4c79b5
        # Check external files existence. External files are used when
4c79b5
        # reusing background images inside design templates. In these
4c79b5
        # cases external files point to images which contain the
4c79b5
        # appropriate background image used by design template to
4c79b5
        # propagate theme's artistic motif.
4c79b5
        EXTERNALFILES=$(egrep '(xlink:href|sodipodi:absref)="/home/centos/artwork/' $INSTANCE \
4c79b5
            | sed -r 's!^[[:space:]]+!!' \
4c79b5
            | sed -r 's!^(xlink:href|sodipodi:absref)="!!' \
4c79b5
            | sed -r 's!".*$!!' | 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.
4c79b5
        inkscape $INSTANCE \
4c79b5
            --export-id=$EXPORTID $WIDTH \
4c79b5
            --export-png=$FILE.png \
4c79b5
                | sed -r -e "s!Area !`gettext "Area"`: !" \
4c79b5
                -e "s!Background RRGGBBAA:!`gettext "Background"`: RRGGBBAA!" \
841480
                -e "s!Bitmap saved as:.+/(trunk|branches|tags)/!`gettext "Saved as"`: \1/!"
4c79b5
4c79b5
        # Remove template instance. 
4c79b5
        if [[ -a $INSTANCE ]];then
4c79b5
            rm $INSTANCE
4c79b5
        fi
4c79b5
4c79b5
        # Execute post-rendering actions.
f3bce7
        for ACTION in "${POSTACTIONS[@]}"; do
4c79b5
4c79b5
            case "$ACTION" in
4c79b5
4c79b5
                renderSyslinux )
4c79b5
                    render_doIdentityImageSyslinux $FILE
4c79b5
                    ;;
4c79b5
4c79b5
                renderGrub )
4c79b5
                    render_doIdentityImageGrub $FILE
4c79b5
                    ;;
4c79b5
4c79b5
                renderFormats:* )
4c79b5
                    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
4c79b5
        echo '----------------------------------------------------------------------'
4c79b5
5fb18a
    done \
e92b23
        | awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
f3bce7
f3bce7
    # Execute post-rendering actions.
f3bce7
    for ACTION in "${LASTACTIONS[@]}"; do
f3bce7
f3bce7
        case "$ACTION" in
f3bce7
640a79
            renderKSplash )
640a79
                render_doIdentityImageKsplash
f3bce7
                ;;
f3bce7
ae8a10
            renderGdmTgz:* )
ae8a10
                render_doIdentityImageGdm "$ACTION"
ae8a10
                ;;
ae8a10
ff3ea9
            groupByType:* )
ff3ea9
                render_doIdentityGroupByType "$ACTION"
ff3ea9
                ;;
ff3ea9
f3bce7
f3bce7
        esac
f3bce7
f3bce7
    done
4c79b5
4c79b5
}