Blame Automation/Modules/Render/Svg/svg_doPostActions.sh

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