|
|
878a2b |
#!/bin/bash
|
|
|
878a2b |
#
|
|
|
878a2b |
# render_doThemeActions.sh -- This function performs theme-specific
|
|
|
878a2b |
# rendition.
|
|
|
878a2b |
#
|
|
|
03486a |
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is free software; you can redistribute it and/or modify
|
|
|
878a2b |
# it under the terms of the GNU General Public License as published by
|
|
|
878a2b |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
878a2b |
# your option) any later version.
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is distributed in the hope that it will be useful, but
|
|
|
878a2b |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
878a2b |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
878a2b |
# General Public License for more details.
|
|
|
878a2b |
#
|
|
|
878a2b |
# You should have received a copy of the GNU General Public License
|
|
|
878a2b |
# along with this program; if not, write to the Free Software
|
|
|
878a2b |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
878a2b |
#
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
# $Id$
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
|
|
|
878a2b |
function render_doThemeActions {
|
|
|
878a2b |
|
|
|
878a2b |
local -a DIRS
|
|
|
878a2b |
local COUNT=0
|
|
|
41ae46 |
local NEXTDIR=''
|
|
|
878a2b |
local MOTIF_NAME=''
|
|
|
878a2b |
local MOTIF_DIR=''
|
|
|
878a2b |
|
|
|
878a2b |
# Define base directory of artistic motifs. This is the location
|
|
|
878a2b |
# where all artistic motifs are stored in.
|
|
|
819c26 |
local MOTIF_BASEDIR="${TCAR_WORKDIR}/Identity/Images/Themes"
|
|
|
878a2b |
|
|
|
878a2b |
# Define base directory of design models. This is the location
|
|
|
878a2b |
# where all design models are stored in.
|
|
|
819c26 |
local MODEL_BASEDIR="${TCAR_WORKDIR}/Identity/Models/Themes"
|
|
|
878a2b |
|
|
|
878a2b |
# Define directory structure of design models. Design models
|
|
|
878a2b |
# directory structures are used as reference to create artistic
|
|
|
878a2b |
# motifs directory structure. Use the `--pattern' option to be
|
|
|
878a2b |
# sure any modification to FLAG_FILTER won't affect the output
|
|
|
878a2b |
# result. We need to make matching everything here, no matter what
|
|
|
878a2b |
# the FLAG_FILTER value be.
|
|
|
878a2b |
local MODEL_DIR=''
|
|
|
878a2b |
local MODEL_DIRS="$(cli_getFilesList ${MODEL_BASEDIR}/${FLAG_THEME_MODEL} \
|
|
|
3b9515 |
--pattern='^/[^.svn][[:alnum:]_/-]+$' --type="d" \
|
|
|
41ae46 |
| sed -e "s!^.*/${FLAG_THEME_MODEL}!!" \
|
|
|
41ae46 |
-e '/^[[:space:]]*$/d' \
|
|
|
41ae46 |
-e 's!^/!!')"
|
|
|
878a2b |
|
|
|
878a2b |
# Define design model regular expression patterns from design
|
|
|
878a2b |
# models directory structure.
|
|
|
878a2b |
local MODEL_PATTERN=$(echo "$MODEL_DIRS" | tr "\n" '|' \
|
|
|
878a2b |
| sed -e 's!^|!!' -e 's!|$!!')
|
|
|
878a2b |
|
|
|
41ae46 |
# Define regular expression pattern that match the theme artistic
|
|
|
41ae46 |
# motif component inside the path strings.
|
|
|
41ae46 |
local MOTIF_PATTERN=$(cli_getPathComponent --motif-pattern)
|
|
|
41ae46 |
|
|
|
41ae46 |
# Define list of render-able directory structures inside the
|
|
|
878a2b |
# artistic motif. As reference, to build this list, use design
|
|
|
41ae46 |
# model directory structure. The more specific you be in the path
|
|
|
41ae46 |
# specification the more specific theme rendition will be. Thus,
|
|
|
41ae46 |
# we use the path provided as argument and the filter option as
|
|
|
41ae46 |
# reference to control the amount of directories to be considered
|
|
|
41ae46 |
# as render-able directory.
|
|
|
878a2b |
local MOTIF_RENDERABLE_DIR=''
|
|
|
878a2b |
local MOTIF_RENDERABLE_DIRS=$(cli_getFilesList ${MOTIF_BASEDIR} \
|
|
|
41ae46 |
--pattern="${TCAR_WORKDIR}/${MOTIF_PATTERN}/($MODEL_PATTERN)" --type="d" \
|
|
|
41ae46 |
| grep "${ACTIONVAL}")
|
|
|
878a2b |
|
|
|
41ae46 |
# Rebuild list of render-able directory structures using an array
|
|
|
878a2b |
# variable. This let us to predict what directory is one step
|
|
|
878a2b |
# forward or backward from the current directory structure.
|
|
|
878a2b |
for MOTIF_RENDERABLE_DIR in $MOTIF_RENDERABLE_DIRS;do
|
|
|
878a2b |
DIRS[((++${#DIRS[*]}))]=${MOTIF_RENDERABLE_DIR}
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
# Define total number of directories to process. This is required
|
|
|
878a2b |
# in order to correct the counting value and so, make it to match
|
|
|
878a2b |
# the zero based nature of bash array variables.
|
|
|
878a2b |
local DIRS_TOTAL=$((${#DIRS[*]} - 1))
|
|
|
878a2b |
|
|
|
878a2b |
while [[ $COUNT -le ${DIRS_TOTAL} ]];do
|
|
|
878a2b |
|
|
|
41ae46 |
# Redefine action value to refer the theme-specific render-able
|
|
|
878a2b |
# directory.
|
|
|
878a2b |
ACTIONVAL=${DIRS[$COUNT]}
|
|
|
878a2b |
|
|
|
878a2b |
# Refine artistic motif name using the current action value.
|
|
|
878a2b |
MOTIF_NAME=$(cli_getPathComponent $ACTIONVAL --motif)
|
|
|
878a2b |
|
|
|
878a2b |
# Verify artistic motif name. The name of the artistic motif
|
|
|
878a2b |
# must be present in order for theme rendition to happen.
|
|
|
878a2b |
# Theme rendition takes place inside artistic motifs and the
|
|
|
878a2b |
# artistic motif name is an indispensable part of it. Take
|
|
|
878a2b |
# care of not using design models directory structure as name
|
|
|
878a2b |
# for artistic motifs. They, sometimes, match the pattern used
|
|
|
878a2b |
# to verify artistic motifs names but must not be confused.
|
|
|
41ae46 |
if [[ $MOTIF_NAME == '' ]] || [[ $MOTIF_NAME =~ "^($MODEL_PATTERN)" ]];then
|
|
|
878a2b |
COUNT=$(($COUNT + 1))
|
|
|
878a2b |
continue
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
# Refine artistic motif directory. This is the top directory
|
|
|
878a2b |
# where all visual manifestations of an artistic motif are
|
|
|
878a2b |
# stored in (e.g., Backgrounds, Brushes, Concept, Distro,
|
|
|
878a2b |
# etc.).
|
|
|
878a2b |
MOTIF_DIR="${MOTIF_BASEDIR}/${MOTIF_NAME}"
|
|
|
878a2b |
|
|
|
878a2b |
# Define what is the next directory in the list, so we could
|
|
|
878a2b |
# verify whether to render or not the current theme-specific
|
|
|
41ae46 |
# render-able directory.
|
|
|
878a2b |
if [[ $COUNT -lt ${DIRS_TOTAL} ]];then
|
|
|
41ae46 |
NEXTDIR=$(dirname ${DIRS[(($COUNT + 1))]})
|
|
|
878a2b |
else
|
|
|
41ae46 |
NEXTDIR=''
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
# Verify whether to render or not the current theme's
|
|
|
41ae46 |
# render-able directory. This verification is needed in order
|
|
|
41ae46 |
# to avoid unnecessary rendition loops. For example, don't
|
|
|
878a2b |
# render `path/to/dir/A' when `path/to/dir/A/B' does exist,
|
|
|
878a2b |
# that configuration would produce `/path/to/dir/A/B twice.
|
|
|
41ae46 |
if [[ $ACTIONVAL =~ '[[:digit:]]$' ]] || [[ $ACTIONVAL == $NEXTDIR ]];then
|
|
|
878a2b |
COUNT=$(($COUNT + 1))
|
|
|
878a2b |
continue
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
41ae46 |
# Execute direct rendition on theme specific render-able
|
|
|
878a2b |
# directory as specified by action value.
|
|
|
878a2b |
render_doBaseActions
|
|
|
878a2b |
|
|
|
878a2b |
# Increment counter to match the correct count value.
|
|
|
878a2b |
COUNT=$(($COUNT + 1))
|
|
|
878a2b |
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
}
|