Consolodate project directories into variables.
This commit is contained in:
parent
bfcd194a09
commit
7c1aec3497
54
isidore.sh
54
isidore.sh
@ -26,6 +26,11 @@ ISIDORE_AUTHOR_NAME=""
|
|||||||
PROG_NAME=$0
|
PROG_NAME=$0
|
||||||
PROJECT_NAME="Isidore"
|
PROJECT_NAME="Isidore"
|
||||||
|
|
||||||
|
SOURCE_DIR="site/"
|
||||||
|
TMP_DIR="/tmp/isidore-workdesk/"
|
||||||
|
OUTPUT_DIR="output/"
|
||||||
|
TEMPLATE_DIR="templates/"
|
||||||
|
|
||||||
##
|
##
|
||||||
# Create the configuration file. This function is called if it does not already
|
# Create the configuration file. This function is called if it does not already
|
||||||
# exist.
|
# exist.
|
||||||
@ -134,8 +139,8 @@ function new_project()
|
|||||||
read NEW_PROJECT_URL
|
read NEW_PROJECT_URL
|
||||||
fi
|
fi
|
||||||
mkdir $NEW_PROJECT_DIR
|
mkdir $NEW_PROJECT_DIR
|
||||||
mkdir -p $NEW_PROJECT_DIR/site/
|
mkdir -p $NEW_PROJECT_DIR/$SOURCE_DIR
|
||||||
mkdir -p $NEW_PROJECT_DIR/templates/
|
mkdir -p $NEW_PROJECT_DIR/$TEMPLATE_DIR
|
||||||
echo \
|
echo \
|
||||||
"<?php
|
"<?php
|
||||||
\$site_name = \"$NEW_PROJECT_NAME\";
|
\$site_name = \"$NEW_PROJECT_NAME\";
|
||||||
@ -155,9 +160,9 @@ function new_project()
|
|||||||
function clean_project()
|
function clean_project()
|
||||||
{
|
{
|
||||||
check_in_project
|
check_in_project
|
||||||
if [ -d "./output/" ]
|
if [ -d "$OUTPUT_DIR" ]
|
||||||
then
|
then
|
||||||
rm -r ./output/
|
rm -r $OUTPUT_DIR
|
||||||
fi
|
fi
|
||||||
echo "Project cleaned."
|
echo "Project cleaned."
|
||||||
}
|
}
|
||||||
@ -169,31 +174,32 @@ function build_project()
|
|||||||
{
|
{
|
||||||
check_in_project
|
check_in_project
|
||||||
|
|
||||||
mkdir -p ./output/
|
CFG_HEADER_FILE="$TMP_DIR/config-header.php"
|
||||||
WORKDESK="/tmp/isidore-workdesk"
|
|
||||||
CFG_HEADER_FILE="$WORKDESK/config-header.php"
|
mkdir -p $OUTPUT_DIR
|
||||||
mkdir -p $WORKDESK
|
mkdir -p $TMP_DIR
|
||||||
for i in $(find site/ -name '*.php' -not -name '*.cfg.php')
|
echo "<?php include(getcwd() . '/config.php'); ?>" > $CFG_HEADER_FILE
|
||||||
|
|
||||||
|
for i in $(find $SOURCE_DIR -type d)
|
||||||
do
|
do
|
||||||
echo "<?php include getcwd() . '/config.php'; ?>" > $CFG_HEADER_FILE
|
mkdir -p $OUTPUT_DIR/${i:${#SOURCE_DIR}}
|
||||||
mkdir -p $WORKDESK/${i%/*}
|
mkdir -p $TMP_DIR/$i
|
||||||
cat $CFG_HEADER_FILE $i > $WORKDESK/$i
|
|
||||||
# the 4 offset is to avoid including `site/`
|
|
||||||
: ${i:4}
|
|
||||||
OUT_DIR="./output/${_%/*}"
|
|
||||||
mkdir -p $OUT_DIR
|
|
||||||
: ${i: :-4}
|
|
||||||
OUT_FILE="$OUT_DIR/${_##*/}"
|
|
||||||
php $WORKDESK/$i > $OUT_FILE
|
|
||||||
done
|
done
|
||||||
|
|
||||||
for i in $(find site/ -type f -not -name '*.php')
|
for i in $(find $SOURCE_DIR -name '*.php' -not -name '*.cfg.php')
|
||||||
do
|
do
|
||||||
mkdir -p ./output/${i%/*}
|
cat $CFG_HEADER_FILE $i > $TMP_DIR/$i
|
||||||
cp $i ./output/$i
|
: ${i:${#SOURCE_DIR}}
|
||||||
|
OUT_FILE="$OUTPUT_DIR/${_: :-4}"
|
||||||
|
php $TMP_DIR/$i > $OUT_FILE
|
||||||
done
|
done
|
||||||
|
|
||||||
rm -r $WORKDESK
|
for i in $(find $SOURCE_DIR -type f -not -name '*.php')
|
||||||
|
do
|
||||||
|
cp $i $OUTPUT_DIR/${i:${#SOURCE_DIR}}
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -r $TMP_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
set_config_vars
|
set_config_vars
|
||||||
@ -228,7 +234,7 @@ case $1 in
|
|||||||
build)
|
build)
|
||||||
build_project;;
|
build_project;;
|
||||||
serve|server)
|
serve|server)
|
||||||
php -S localhost:8080 -t ./output/;;
|
php -S localhost:8080 -t $OUTPUT_DIR/;;
|
||||||
clean)
|
clean)
|
||||||
clean_project;;
|
clean_project;;
|
||||||
help)
|
help)
|
||||||
|
Loading…
Reference in New Issue
Block a user