Blob Blame History Raw
#!/bin/bash
#
# render_getDirTemplate.sh -- This function defines the way renderable
# directories are processed inside the repository.  Inside the
# repository, renderable directories are processed either through
# direct or theme-specific rendition.
#
# Direct rendition takes one XML file from design model
# (`Identity/Models') directory structure and produces one file
# in `Identity/Images' directory strucutre. In this
# configuration, the organization used to stored the design model is
# taken as reference to build the path required to store the image
# related to it under `Identity/Images' directory structure.
#
# Theme-specific rendition takes one design model from
# `Identity/Models/Themes' directory structure to produce one or
# more images in `Identity/Images/Themes/$THEME/$VERSION/$MODEL'
# directory structure. In this configuration we have many different
# artistic motifs that use one unique design model directory structure
# as reference to produce images. 
#
# Since theme design models are unified to be reused by more
# than one artistic motif, it is not possible to render artistic
# motifs in a lineal manner (i.e., as we do with direct rendition)
# because we need to establish the relation between the artistic motif
# renderable directory structure and the design model first and that
# relation happens when renderable directory structures inside
# artistic motifs are processed individually.
#
# In the first rendition category, we use a design model directory
# structure as reference to produce images one by one. In the second
# rendition category, we can't use the same procedure because one
# design model directory structure is used to produce several
# renderable directory structures, not just one.
#
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# ----------------------------------------------------------------------
# $Id$
# ----------------------------------------------------------------------

function render_getDirTemplate {

    # Initialize design models location used as reference to process
    # renderable directory structures.
    TEMPLATE=$ACTIONVAL

    # Define absolute path to input files using absolute path from
    # output files.
    if [[ -d ${TEMPLATE}/Tpl ]];then
        TEMPLATE=${TEMPLATE}/Tpl
    else
        TEMPLATE=$(echo "$TEMPLATE" | sed -r \
            -e "s!/Themes/$(cli_getPathComponent $ACTIONVAL --motif)!/Themes/${FLAG_THEME_MODEL}!" \
            -e "s!/(Manuals|Images)!/Models!")
    fi

    # Verify absolute path to input file. This verification is
    # specially needed in those situations when the artistic motif
    # directory structure has an organization different to that in
    # design models directory structure. Since the path to design
    # models is built from artistic motif directory structure, if
    # artistic motifs directory structure is different from design
    # model directory structure, as result we'll have a path to a
    # design model that may not exist and that would make
    # centos-art.sh script to fail. So, verify the absolute path to
    # the input file and stop script execution if it doesn't exist.
    cli_checkFiles -e $TEMPLATE

}