diff --git a/mkhtml b/mkhtml index 1191f4b..2681eaa 100755 --- a/mkhtml +++ b/mkhtml @@ -8,10 +8,10 @@ echo " |_| |_| |_|_|\_\_| |_|\__|_| |_| |_|_|" # http://patorjk.com/software/taag/ echo "" -if [[ -d "$(pwd)/pages/" && -d "$(pwd)/parts/" && -d "$(pwd)/builds/" ]]; then - PAGESDIR="$(pwd)/pages/" - PARTSDIR="$(pwd)/parts/" - BUILDSDIR="$(pwd)/builds/" +if [[ -d "$(pwd)/pages" && -d "$(pwd)/parts" && -d "$(pwd)/builds" ]]; then + PAGESDIR="$(pwd)/pages" + PARTSDIR="$(pwd)/parts" + BUILDSDIR="$(pwd)/builds" # Check if mandatory folders exist, make variables if yes, create them if not. fi @@ -21,7 +21,7 @@ if [ ! -w "$BUILDSDIR" ]; then exit 1 fi -if [[ ! -d "$(pwd)/pages/" || ! -d "$(pwd)/parts/" || ! -d "$(pwd)/builds/" ]]; then +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" @@ -29,10 +29,14 @@ if [[ ! -d "$(pwd)/pages/" || ! -d "$(pwd)/parts/" || ! -d "$(pwd)/builds/" ]]; fi -if [ -d "$(pwd)/src/" ]; then - SRCDIR="$(pwd)/src/" +if [ -d "$(pwd)/src" ]; then + SRCDIR="$(pwd)/src" fi # Check if there is a src/ folder +if [ -d "$(pwd)/static" ]; then + STATDIR="$(pwd)/static" +fi +# Check if there is a static/ foder echo "PAGESDIR: $PAGESDIR" echo "PARTSDIR: $PARTSDIR" @@ -40,34 +44,38 @@ echo "BUILDSDIR: $BUILDSDIR" if [ -n "$SRCDIR" ]; then echo "SRCDIR: $SRCDIR" fi - +if [ -n "$STATDIR" ]; then + echo "STATDIR: $STATDIR" +fi echo "" echo "Building files..." # https://stackoverflow.com/a/54563899 cd $PAGESDIR && find . -type f -print0 | while IFS= read -r -d $'\0' file; do filename=$(echo $file | sed 's/.\///') - newloc="$BUILDSDIR$filename" + newloc="$BUILDSDIR/$filename" touch $newloc 2>/dev/null echo "Building $file" echo "" > "$newloc" cat "$PARTSDIR/footer.html" >> "$newloc" - cat "$PAGESDIR$filename" >> "$newloc" + cat "$PAGESDIR/$filename" >> "$newloc" cat "$PARTSDIR/header.html" >> "$newloc" # build file using PARTS and PAGE done if [ -n "$SRCDIR" ]; then echo "Copying SRCDIR to BUILDSDIR" - cp -r "$SRCDIR" "$BUILDSDIR" + mkdir "$BUILDSDIR/src" 2>/dev/null + cp -r $SRCDIR/* $BUILDSDIR/src +fi + +if [ -n "$STATDIR" ]; then + echo "Copying STATDIR to BUILDSDIR" + cp -r $STATDIR/* $BUILDSDIR fi echo "" echo "Looks like all files were built" echo "" -if [ -z "$SRCDIR" ]; then - echo "Pro Tip: add a SRCDIR (create a src/ dir in $(pwd) for CSS/JS)" -fi - echo "Please report any error to https://tildegit.org/jusdepatate/mkhtml"