Compare commits

...

4 Commits

Author SHA1 Message Date
Jus de Patate_ 16aa6dae2d support multi dir
you can now have multiple directories in pages/ and they will all end up
in builds/
2021-07-28 17:37:22 +02:00
Jus de Patate_ 7a28c1125a remove useless output 2021-07-28 17:30:45 +02:00
Jus de Patate_ a7a556a99f correcting small problems 2021-07-28 17:29:57 +02:00
Jus de Patate_ db31085fd2 gitignore update 2021-07-28 17:16:52 +02:00
2 changed files with 14 additions and 9 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ builds/*
src/*
pages/*
parts/*
static/*

22
mkhtml
View File

@ -15,16 +15,15 @@ if [[ -d "$(pwd)/pages" && -d "$(pwd)/parts" && -d "$(pwd)/builds" ]]; then
# Check if mandatory folders exist, make variables if yes, create them if not.
fi
if [ ! -w "$BUILDSDIR" ]; then
echo "mkhtml (executed by $(whoami)) can't write in $BUILDSDIR"
echo "Ask your system admin to change permissions or move this whole folder"
exit 1
fi
if [[ ! -d "$(pwd)/pages" || ! -d "$(pwd)/parts" || ! -d "$(pwd)/builds" ]]; then
mkdir {pages,parts,builds} 2>/dev/null
echo "pages, parts and builds folders were created by mkhtml in $(pwd)"
echo "now populate them"
exit 1
fi
if [ ! -w "$BUILDSDIR" ]; then
echo "mkhtml (executed by $(whoami)) can't write in $BUILDSDIR"
echo "Ask your system admin to change permissions or move this whole folder"
exit 1
fi
@ -50,8 +49,11 @@ fi
echo ""
echo "Building files..."
cd $PAGESDIR
find -type d -links 2 -exec mkdir -p "$BUILDSDIR/{}" \;
# https://stackoverflow.com/a/54563899
cd $PAGESDIR && find . -type f -print0 | while IFS= read -r -d $'\0' file; do
find . -type f -print0 | while IFS= read -r -d $'\0' file; do
filename=$(echo $file | sed 's/.\///')
newloc="$BUILDSDIR/$filename"
touch $newloc 2>/dev/null
@ -60,7 +62,7 @@ cd $PAGESDIR && find . -type f -print0 | while IFS= read -r -d $'\0' file; do
cat "$PARTSDIR/header.html" >> "$newloc"
cat "$PAGESDIR/$filename" >> "$newloc"
cat "$PARTSDIR/footer.html" >> "$newloc"
# build file using PARTS and PAGE
# build files using PARTS and PAGE
done
if [ -n "$SRCDIR" ]; then
@ -74,6 +76,8 @@ if [ -n "$STATDIR" ]; then
cp -r $STATDIR/* $BUILDSDIR
fi
cd - > /dev/null
echo ""
echo "Looks like all files were built"
echo ""