From 7c1aec3497e87a6dd046372f0f1b1c18bcae86a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20A=2E=20Ortega=20Froysa?= Date: Tue, 8 Nov 2022 15:52:12 +0100 Subject: [PATCH] Consolodate project directories into variables. --- isidore.sh | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/isidore.sh b/isidore.sh index a0b42a3..46fb3a1 100755 --- a/isidore.sh +++ b/isidore.sh @@ -26,6 +26,11 @@ ISIDORE_AUTHOR_NAME="" PROG_NAME=$0 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 # exist. @@ -134,8 +139,8 @@ function new_project() read NEW_PROJECT_URL fi mkdir $NEW_PROJECT_DIR - mkdir -p $NEW_PROJECT_DIR/site/ - mkdir -p $NEW_PROJECT_DIR/templates/ + mkdir -p $NEW_PROJECT_DIR/$SOURCE_DIR + mkdir -p $NEW_PROJECT_DIR/$TEMPLATE_DIR echo \ "" > $CFG_HEADER_FILE + + for i in $(find $SOURCE_DIR -type d) do - echo "" > $CFG_HEADER_FILE - mkdir -p $WORKDESK/${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 + mkdir -p $OUTPUT_DIR/${i:${#SOURCE_DIR}} + mkdir -p $TMP_DIR/$i done - for i in $(find site/ -type f -not -name '*.php') + for i in $(find $SOURCE_DIR -name '*.php' -not -name '*.cfg.php') do - mkdir -p ./output/${i%/*} - cp $i ./output/$i + cat $CFG_HEADER_FILE $i > $TMP_DIR/$i + : ${i:${#SOURCE_DIR}} + OUT_FILE="$OUTPUT_DIR/${_: :-4}" + php $TMP_DIR/$i > $OUT_FILE 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 @@ -228,7 +234,7 @@ case $1 in build) build_project;; serve|server) - php -S localhost:8080 -t ./output/;; + php -S localhost:8080 -t $OUTPUT_DIR/;; clean) clean_project;; help)