Blame Scripts/Functions/Render/Svg/svg_doPostActions.sh

8af4d8
#!/bin/bash
8af4d8
#
5eb9ec
# svg_doPostActions.sh -- This function performs post-rendition
5eb9ec
# actions for SVG files.
8af4d8
#
2fe9b7
# Copyright (C) 2009, 2010, 2011 The CentOS Project
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# WITHOUT ANY WARRANTY; without even the implied warranty of
8af4d8
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
8af4d8
# General Public License for more details.
8af4d8
#
8af4d8
# You should have received a copy of the GNU General Public License
8af4d8
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7ac5a5
#
8af4d8
# ----------------------------------------------------------------------
8af4d8
# $Id$
8af4d8
# ----------------------------------------------------------------------
8af4d8
5eb9ec
function svg_doPostActions {
8af4d8
8af4d8
    local ACTION=''
ccc633
ccc633
    # Redefine SVG post-rendition actions as local to avoid undesired
ccc633
    # concatenation when massive rendition is performed.
05d9ae
    local -a POSTACTIONS
05d9ae
ccc633
    # Define default comment written to base-rendition output.
c0cf6b
    local COMMENT="`gettext "Created in CentOS Artwork Repository"` ($(cli_printUrl '--projects-artwork'))"
ccc633
ccc633
    # Define SVG post-rendition actions. Since these actions are
ccc633
    # applied to base-rendition output and base-rendition output is
ccc633
    # used as reference to perform directory-specific rendition, these
ccc633
    # action must be defined before directory-specific rendition.
ccc633
    # Otherwise it wouldn't be possible to propagate changes impossed
ccc633
    # by these actions to new files produced as result of
ccc633
    # directory-specific rendition.
5eb9ec
    POSTACTIONS[((++${#POSTACTIONS[*]}))]="doPostCommand:png:mogrify -comment '$COMMENT'"
5eb9ec
    [[ $FLAG_POSTRENDITION != '' ]] && POSTACTIONS[((++${#POSTACTIONS[*]}))]="doPostCommand:png:${FLAG_POSTRENDITION}"
fc1ac6
fc1ac6
    # Define SVG directory-specific rendition. Directory-specfic
fc1ac6
    # rendition provides a predictable way of producing content inside
fc1ac6
    # the repository.
ccc633
    if [[ $FLAG_DONT_DIRSPECIFIC == 'false' ]];then
e16737
8eccbf
        if [[ $TEMPLATE =~ 'trunk/Identity/(Models|Images)/Themes/.+\.svg$' ]];then
e16737
e16737
            POSTACTIONS[((++${#POSTACTIONS[*]}))]="convertPngToBranded"
e16737
e16737
            if [[ $TEMPLATE =~ "Backgrounds/.+\.svg$" ]];then
e16737
                POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg'
e16737
                POSTACTIONS[((++${#POSTACTIONS[*]}))]='groupBy:png jpg'
e16737
e16737
            elif [[ $TEMPLATE =~ "Concept/.+\.svg$" ]];then
e16737
                POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf'
e16737
                POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToThumbnail:250'
e16737
e16737
            elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Syslinux/.+\.svg$" ]];then
e16737
                POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToSyslinux:'
e16737
                POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToSyslinux:-floyd'
e16737
e16737
            elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Grub/.+\.svg$" ]];then
e16737
                POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToGrub:'
e16737
                POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToGrub:-floyd'
e16737
e16737
            elif [[ $TEMPLATE =~ "Posters/.+\.svg$" ]];then
e16737
                POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf'
e16737
            fi
e16737
f191e9
        elif [[ $TEMPLATE =~ "trunk/Identity/Models/Brands/.+\.svg$" ]];then
5eb9ec
            POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToBrands'
e16737
e9d9fb
        elif [[ $TEMPLATE =~ "trunk/Identity/Models/Icons/.+\.svg$" ]];then
e9d9fb
            POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToIcons'
e16737
8f1f12
        elif [[ $TEMPLATE =~ "trunk/Identity/Models/Manuals.+\.svg$" ]];then
8f1f12
            POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf'
e16737
ccc633
        fi
e16737
05d9ae
    fi
dc167f
fc1ac6
    # Execute SVG post-rendition actions.
8af4d8
    for ACTION in "${POSTACTIONS[@]}"; do
8c13b6
        svg_$(echo "$ACTION" | cut -d: -f1)
8af4d8
    done
8af4d8
8af4d8
}