Compare commits

..

No commits in common. "v0.1.0" and "master" have entirely different histories.

12 changed files with 28 additions and 142 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
output/

View File

@ -14,10 +14,9 @@ Synopsis: `isidore <command> [options]`
Commands:
- `new [-i] <dir>`: create a new project directory `<dir>`. Use `-i` for
interactive mode.
- `build [-v]`: build the website (default). Use `-v` for verbose.
- `serve`, `server`: run an HTTP server of the output on port 8080.
- `new <dir> <name>`: create a new project directory `<dir>` with project name
`<name>`.
- `build`: build the website (default).
- `clean`: cleans build files.
- `help`: show help information.
- `version`: show Isidore version number.
@ -48,7 +47,7 @@ please take a look at what needs to be done in the [roadmap](/ROADMAP.md), or
check if there are any to-do comments in the code:
```bash
grep "TODO" isidore.sh
grep -r "TODO" src/
```
## License & Copyright

View File

@ -1 +0,0 @@
0.1.0

View File

@ -1,5 +0,0 @@
<?php
$site_name = "New Project";
$site_author = "Nicolás A. Ortega Froysa";
$site_url = "http://example.com/";
?>

View File

@ -1,23 +0,0 @@
<?php
$title = "Blog";
include("templates/header.html.php");
?>
<p>
Welcome to my blog page! Here's a list of my current entries:
</p>
<ul>
<?php
foreach(glob("site/blog/*.cfg.php") as $i)
{
include($i);
$entry_file = substr($i, 4, -8) . '.html';
echo "<li><a href='$entry_file'>$blog_date - $blog_title</a></li>";
}
?>
</ul>
<?php
include("templates/footer.html.php");
?>

View File

@ -1,4 +0,0 @@
<?php
$blog_title = "My First Post";
$blog_date = "2022-11-07";
?>

View File

@ -1,9 +0,0 @@
<?php
include("site/blog/000-first.cfg.php");
$title = $blog_title;
include("templates/header.html.php");
?>
<p>My first blog post.</p>
<?php
include("templates/footer.html.php");
?>

View File

@ -1,10 +0,0 @@
<?php
$title = "Home";
include("templates/header.html.php");
?>
<p>
Hello, World! This is an example page.
</p>
<?php
include("templates/footer.html.php");
?>

View File

@ -1 +0,0 @@
A test file.

View File

@ -1,2 +0,0 @@
</body>
</html>

View File

@ -1,7 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title><?= $title ?> | <?= $site_name?></title>
</head>
<body>
<h1><?= $title ?></h1>

View File

@ -26,11 +26,6 @@ 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.
@ -95,8 +90,6 @@ function print_help()
Create a new Isidore project (use interactive mode with '-i')
build
Build the project rooted in the current directory
serve | server
Serve a local HTTP server of the output directory on port 8080
clean
Clean the built files
version
@ -139,8 +132,8 @@ function new_project()
read NEW_PROJECT_URL
fi
mkdir $NEW_PROJECT_DIR
mkdir -p $NEW_PROJECT_DIR/$SOURCE_DIR
mkdir -p $NEW_PROJECT_DIR/$TEMPLATE_DIR
mkdir -p $NEW_PROJECT_DIR/site/
mkdir -p $NEW_PROJECT_DIR/templates/
echo \
"<?php
\$site_name = \"$NEW_PROJECT_NAME\";
@ -160,69 +153,43 @@ function new_project()
function clean_project()
{
check_in_project
if [ -d "$OUTPUT_DIR" ]
if [ -d "./output/" ]
then
rm -r $OUTPUT_DIR
rm -r ./output/
fi
echo "Project cleaned."
}
##
# Build the project.
#
# Params:
# $1 - Verbose flag
##
function build_project()
{
check_in_project
CFG_HEADER_FILE="$TMP_DIR/config-header.php"
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)
mkdir -p ./output/
WORKDESK="/tmp/isidore-workdesk"
CFG_HEADER_FILE="$WORKDESK/config-header.php"
mkdir -p $WORKDESK
for i in $(find site/ -name '*.php')
do
mkdir -p $OUTPUT_DIR/${i:${#SOURCE_DIR}}
mkdir -p $TMP_DIR/$i
echo "<?php include getcwd() . '/config.php'; ?>" > $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
done
for i in $(find $SOURCE_DIR -name '*.php' -not -name '*.cfg.php')
do
cat $CFG_HEADER_FILE $i > $TMP_DIR/$i
: ${i:${#SOURCE_DIR}}
OUT_FILE="$OUTPUT_DIR/${_: :-4}"
if [ $1 == 1 ]
then
echo "Building $OUT_FILE ..."
fi
php $TMP_DIR/$i > $OUT_FILE
done
for i in $(find $SOURCE_DIR -type f -not -name '*.php')
do
OUT_FILE="$OUTPUT_DIR/${i:${#SOURCE_DIR}}"
if [ $1 == 1 ]
then
echo "Copying $OUT_FILE ..."
fi
cp $i $OUT_FILE
done
rm -r $TMP_DIR
rm -r $WORKDESK
}
set_config_vars
if [ $# -lt 1 ]
then
echo "No subcommand was specified. Use the 'help' subcommand."
print_usage
exit 1
fi
case $1 in
new)
if [ $# -lt 2 ]
@ -243,32 +210,15 @@ case $1 in
then
NEW_DIR="$i"
else
echo "Unknown argument for new '$i'. Use the 'help' subcommand."
echo "Unknown argument for new '$i'. Use the 'help' command."
print_usage
exit 1
fi;;
fi
esac
done
new_project $NEW_DIR $INTERACTIVE;;
build)
VERBOSE=0
if [ $# -gt 1 ]
then
for i in ${@:2}
do
case $i in
-v)
VERBOSE=1;;
*)
echo "Unknown argument for build '$i'. Use the 'help' subcommand."
print_usage
exit 1;;
esac
done
fi
build_project $VERBOSE;;
serve|server)
php -S localhost:8080 -t $OUTPUT_DIR/;;
build_project;;
clean)
clean_project;;
help)
@ -276,7 +226,7 @@ case $1 in
version)
echo "$PROJECT_NAME v$ISIDORE_VERSION";;
*)
echo "Unknown command $1. Use the 'help' subcommand."
echo "Unknown command $1. Use the 'help' command."
print_usage
exit 1;;
esac