Blame Scripts/Bash/Functions/cli_getThemeName.sh

4c79b5
#!/bin/bash
4c79b5
#
4c79b5
# cli_getThemeName.sh -- This function manipulates the current
4c79b5
# absolute path to extract the theme name from it. If there is no
4c79b5
# theme in the path, this function returns an empty string.
4c79b5
#
63bc52
# Theme names are stored in directories immediatly under
63bc52
# Themes/Motifs/ directory and and can be named using letters and
63bc52
# numbers. When rendering themes under branches/ directory structure,
63bc52
# theme names are also built using the branch numeration the theme is
63bc52
# being rendered for.
63bc52
#
63bc52
# Branch enumeration start at number one and increment one unit each
63bc52
# time a new branch is created from the same trunk development line.
63bc52
# If a branch is created from another brach then a new directory is
63bc52
# created inside the source branch, using the same enumeration schema.
63bc52
# So, we may end up with paths like
63bc52
# branches/.../Themes/Motifs/Flame/1,
63bc52
# branches/.../Themes/Motifs/Flame/1/1,
63bc52
# branches/.../Themes/Motifs/Flame/1/2,
63bc52
# branches/.../Themes/Motifs/Flame/2,
63bc52
# branches/.../Themes/Motifs/Flame/2/1, and so on.  In all previous
63bc52
# examples the theme name holds the branch enumeration schema too.
63bc52
#
7cd8e9
# Copyright (C) 2009, 2010 Alain Reguera Delgado
4c79b5
# 
4c79b5
# This program is free software; you can redistribute it and/or
4c79b5
# modify it under the terms of the GNU General Public License as
4c79b5
# published by the Free Software Foundation; either version 2 of the
4c79b5
# 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
4c79b5
function cli_getThemeName {
4c79b5
4c79b5
    local THEMENAME=''
4c79b5
63bc52
    # Define theme name from action value.
c9f2b8
    if [[ $ACTIONVAL =~ '^.+/Themes/Motifs/([A-Za-z0-9-]+)/.+$' ]];then
63bc52
        THEMENAME=$(echo $ACTIONVAL | sed -r \
63bc52
            -e "s!^.+/Themes/Motifs/([A-Za-z0-9-]+(/${RELEASE_FORMAT})*)/.+!\1!") 
4c79b5
    fi
4c79b5
63bc52
    # Print theme name to standard output.
4c79b5
    echo $THEMENAME
63bc52
4c79b5
}