initial commit of a *whole bunch* of old Egressive shell scripts, used to make many people redundant.
This commit is contained in:
commit
43e0f5b59e
329 changed files with 31937 additions and 0 deletions
139
egdrupalhelpers/egsubtheme
Executable file
139
egdrupalhelpers/egsubtheme
Executable file
|
@ -0,0 +1,139 @@
|
|||
#!/bin/bash
|
||||
# this script copies a Zen-based Drupal subtheme into a new, named subtheme
|
||||
# the subtheme can be either a real or a linked directory in the site's themes directory
|
||||
|
||||
# default values
|
||||
DEFAULT_LAYOUT='f'
|
||||
DEFAULT_BASE='egressive_blue'
|
||||
# The working directory
|
||||
DEFAULT_DIR=`pwd`
|
||||
|
||||
usage() {
|
||||
cat <<EOT
|
||||
|
||||
Usage: $0 [OPTIONS] sub_theme_name
|
||||
|
||||
Create a sub theme with a given name from a designated Zen-derived base theme.
|
||||
|
||||
This script should be run in your themes directory, and your base theme
|
||||
|
||||
OPTIONS
|
||||
-b - Specify the base theme in your themes directory on which to base the subtheme (default: $DEFAULT_BASE)
|
||||
-l - Specify desired layout, either 'f' for fixed or 'l' for liquid (or 'fluid') layout. (default: $DEFAULT_LAYOUT)
|
||||
|
||||
EXAMPLE
|
||||
|
||||
The following will create a sub theme called "noodle" based on a theme called "snazzy", using a fluid layout.
|
||||
|
||||
$0 -b snazzy -l f noodle
|
||||
|
||||
EOT
|
||||
}
|
||||
|
||||
while getopts "l" OPT ; do
|
||||
case "${OPT}" in
|
||||
b) BASE=$OPTARG ;;
|
||||
l) LAYOUT=$OPTARG ;;
|
||||
d) DIR=$OPTARG ;;
|
||||
h) usage ; exit 0 ;;
|
||||
*) usage ; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
# grab the unflagged argument from the commandline
|
||||
if [ $# -lt 1 ] ; then
|
||||
echo "You must specify a sub theme name"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# assign them in the appropriate order
|
||||
NAME=$1
|
||||
|
||||
# determine whether the base theme exists and is valid
|
||||
|
||||
# determine the CSS file to use for fixed or fluid layout
|
||||
if [ -z $LAYOUT ]; then
|
||||
echo "no layout specified using default ($DEFAULT_LAYOUT)"
|
||||
LAYOUT=$DEFAULT_LAYOUT
|
||||
fi
|
||||
|
||||
if [ $LAYOUT = "f" ]; then
|
||||
echo "using fixed layout"
|
||||
CSS="layout-fixed.css"
|
||||
elif [ $LAYOUT = "l" ]; then
|
||||
echo "using fluid layout"
|
||||
CSS="layout-liquid.css"
|
||||
else
|
||||
echo "$LAYOUT is an invalid layout type."
|
||||
exit
|
||||
fi
|
||||
|
||||
# determine the base theme to copy
|
||||
if [ -z $BASE ]; then
|
||||
echo "no base theme specified using default ($DEFAULT_BASE)"
|
||||
BASE=$DEFAULT_BASE
|
||||
fi
|
||||
|
||||
DIR=$DEFAULT_DIR
|
||||
|
||||
# check if theme directory already exists, and if so, warn user
|
||||
if [ -d $DIR/$NAME ] ; then
|
||||
echo "The $NAME directory already exists - please remove or move it if you'd like to create it again."
|
||||
exit
|
||||
fi
|
||||
|
||||
# work out if we're looking at a linked dir or not - supply the real dir as target
|
||||
if [ -L $DIR/$BASE ] ; then
|
||||
# the "L" means, if the base directory is a symbolic link, dereference the link and create a
|
||||
# copy of the *linked* directory here.
|
||||
TARGET=`readlink $DIR/$BASE`
|
||||
echo "using link target $TARGET instead of $DIR/$BASE which is a symbolic link"
|
||||
else
|
||||
TARGET=$DIR/$BASE
|
||||
fi
|
||||
|
||||
|
||||
# check that the target (sub)theme exists
|
||||
if [ -d $TARGET ] ; then
|
||||
echo "copying $BASE theme to $NAME"
|
||||
# is it an SVN managed directory?
|
||||
if [ -d $TARGET/.svn ] ; then
|
||||
echo "$TARGET is managed by Subversion, exporting to create unmanaged subtheme $NAME"
|
||||
svn export $TARGET $NAME
|
||||
else
|
||||
cp -Lr $TARGET $NAME
|
||||
fi
|
||||
else
|
||||
echo "$TARGET doesn't exist..."
|
||||
exit
|
||||
fi
|
||||
|
||||
#
|
||||
# Change the theme name (the line 'name = ...') to the new subtheme name
|
||||
#
|
||||
if [ -f $NAME/$BASE.info ] ; then
|
||||
INFO=$NAME/$BASE.info
|
||||
elif [ -f $NAME/$BASE.info.txt ] ; then
|
||||
INFO=$NAME/$BASE.info.txt
|
||||
else
|
||||
echo "there's no original info file for the $BASE theme."
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "using $INFO as the info file"
|
||||
sed 's/'$BASE'/'$NAME'/g' $INFO | sed 's/^\(name *= *\).*/\1'"$NAME"'/g' | sed 's/^\(description *= *\).*/\1'"Zen subtheme ($NAME is derived from $BASE)"'/g' > $NAME/$NAME.info
|
||||
rm $INFO
|
||||
|
||||
#cp $BASE/$CSS $NAME/layout.css
|
||||
#cp $BASE/print.css $NAME/print.css
|
||||
#cp $BASE/html-elements.css $NAME/html-elements.css
|
||||
cp $BASE/$BASE.css $NAME/$NAME.css
|
||||
sed 's/$BASE/'$NAME'/g' $BASE/template.php > $NAME/template.php
|
||||
sed 's/$BASE/'$NAME'/g' $BASE/theme-settings.php > $NAME/theme-settings.php
|
||||
|
||||
echo "Done"
|
||||
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue