Blame Scripts/Functions/Render/render_getDirOutput.sh

4c79b5
#!/bin/bash
4c79b5
#
ab1d67
# render_getDirOutput.sh -- This function defines the final
5fc0b7
# absolute path the centos-art.sh script uses to store identity
5fc0b7
# contents produced at rendition time.
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
ab1d67
function render_getDirOutput {
4c79b5
72b5da
    # Define base output directory using design model path as
15662d
    # reference.  
5fc0b7
    OUTPUT=$(dirname $FILE | sed -r \
294842
        -e "s!/Models/${FLAG_THEME_MODEL}!/Motifs/$(cli_getPathComponent "$ACTIONVAL" "--theme")!" \
af01e9
        -e "s!/Models!/Images!")
15662d
15662d
    # By default rendered identity content is stored immediatly under
15662d
    # identity entry structure,  but if `Img/' directory exists use it
15662d
    # instead.
15662d
    if [[ -d "${OUTPUT}/Img" ]];then
15662d
        OUTPUT=${OUTPUT}/Img
15662d
    fi
f59354
5fc0b7
    # Redefine base output directory to introduce specific information
5fc0b7
    # like release number, architecture, etc.
49237e
    OUTPUT=${OUTPUT}/${FLAG_RELEASEVER}/${FLAG_BASEARCH}
5fc0b7
5fc0b7
    # Define whether to use or not locale-specific directory to store
5fc0b7
    # content, using current locale information as reference. As
5fc0b7
    # convenction, when we produce content in English language, we do
5fc0b7
    # not add a laguage-specific directory to organize content.
5fc0b7
    # However, when we produce language-specific content in a language
5fc0b7
    # different from English we do use language-specific directory to
5fc0b7
    # organize content.
5fc0b7
    if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then
5fc0b7
        OUTPUT=${OUTPUT}/$(cli_getCurrentLocale)
f59354
    fi
f59354
5fc0b7
    # Remove two or more consecutive slashes as well as the last
5fc0b7
    # remaining slash in the path.
5fc0b7
    OUTPUT=$(echo $OUTPUT | sed -r 's!/{2,}!/!g' | sed -r 's!/$!!')
f59354
f59354
    # Create final output directory, if it doesn't exist yet.
f59354
    if [[ ! -d ${OUTPUT} ]];then
f59354
        mkdir -p ${OUTPUT}
4c79b5
    fi
4c79b5
4c79b5
}