Remove need for tmp directory.

This commit is contained in:
Nicolás A. Ortega Froysa 2022-11-10 17:07:03 +01:00
parent 281a31f5f7
commit a799374399

View File

@ -27,9 +27,9 @@ PROG_NAME=$0
PROJECT_NAME="Isidore" PROJECT_NAME="Isidore"
SOURCE_DIR="site/" SOURCE_DIR="site/"
TMP_DIR="/tmp/isidore-workdesk/"
OUTPUT_DIR="output/" OUTPUT_DIR="output/"
TEMPLATE_DIR="templates/" TEMPLATE_DIR="templates/"
PROJECT_CONFIG_FILE="config.php"
## ##
# 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
@ -110,7 +110,7 @@ function print_help()
## ##
function check_in_project() function check_in_project()
{ {
if ! [ -f "./config.php" ] || ! [ -f "./.isidore-version" ] if ! [ -f "$PROJECT_CONFIG_FILE" ] || ! [ -f "./.isidore-version" ]
then then
echo "ERROR: You are not currently in the root of an Isidore project." echo "ERROR: You are not currently in the root of an Isidore project."
exit 1 exit 1
@ -146,12 +146,12 @@ function new_project()
\$site_name = \"$NEW_PROJECT_NAME\"; \$site_name = \"$NEW_PROJECT_NAME\";
\$site_author = \"$ISIDORE_AUTHOR_NAME\"; \$site_author = \"$ISIDORE_AUTHOR_NAME\";
\$site_url = \"$NEW_PROJECT_URL\"; \$site_url = \"$NEW_PROJECT_URL\";
?>" >> $NEW_PROJECT_DIR/config.php ?>" >> $NEW_PROJECT_DIR/$PROJECT_CONFIG_FILE
echo "$ISIDORE_VERSION" > $NEW_PROJECT_DIR/.isidore-version echo "$ISIDORE_VERSION" > $NEW_PROJECT_DIR/.isidore-version
echo "New project created." echo "New project created."
[ $2 == 0 ] && [ $2 == 0 ] &&
echo "Consider taking a look at the $NEW_PROJECT_DIR/config.php file." echo "Consider taking a look at the $NEW_PROJECT_DIR/$PROJECT_CONFIG_FILE file."
} }
## ##
@ -177,28 +177,22 @@ function build_project()
{ {
check_in_project check_in_project
local CFG_HEADER_FILE="$TMP_DIR/config-header.php"
mkdir -p $OUTPUT_DIR mkdir -p $OUTPUT_DIR
mkdir -p $TMP_DIR
echo "<?php include(getcwd() . '/config.php'); ?>" > $CFG_HEADER_FILE
for i in $(find $SOURCE_DIR -type d) for i in $(find $SOURCE_DIR -type d)
do do
mkdir -p $OUTPUT_DIR/${i:${#SOURCE_DIR}} mkdir -p $OUTPUT_DIR/${i:${#SOURCE_DIR}}
mkdir -p $TMP_DIR/$i
done done
for i in $(find $SOURCE_DIR -name '*.php' -not -name '*.cfg.php') for i in $(find $SOURCE_DIR -name '*.php' -not -name '*.cfg.php')
do do
cat $CFG_HEADER_FILE $i > $TMP_DIR/$i
: ${i:${#SOURCE_DIR}} : ${i:${#SOURCE_DIR}}
local OUT_FILE="$OUTPUT_DIR/${_: :-4}" local OUT_FILE="$OUTPUT_DIR/${_: :-4}"
if [ $1 == 1 ] if [ $1 == 1 ]
then then
echo "Building $OUT_FILE ..." echo "Building $OUT_FILE ..."
fi fi
php $TMP_DIR/$i > $OUT_FILE cat $PROJECT_CONFIG_FILE $i | php > $OUT_FILE
done done
for i in $(find $SOURCE_DIR -type f -not -name '*.php') for i in $(find $SOURCE_DIR -type f -not -name '*.php')
@ -210,8 +204,6 @@ function build_project()
fi fi
cp $i $OUT_FILE cp $i $OUT_FILE
done done
rm -r $TMP_DIR
} }
set_config_vars set_config_vars