diff --git a/system/bin/generate_html.sh b/system/bin/generate_html.sh
index 3063ccb..612b547 100755
--- a/system/bin/generate_html.sh
+++ b/system/bin/generate_html.sh
@@ -3,19 +3,23 @@
echo "Creating symbolic link /workspace to $(pwd)"
ln -s "$(pwd)" /workspace
-php-fpm -D
-service nginx start
-
-host=$(jq -r '.hostname' config.json)
+# Check if php-fpm is running
+if ! pgrep "php-fpm" > /dev/null; then
+ php-fpm -D
+fi
-if ! grep -qF "$host" "/etc/hosts"; then
- echo "$host" >> "/etc/hosts"
+# Check if nginx is running
+if ! pgrep "nginx" > /dev/null; then
+ service nginx start
fi
-echo 127.0.0.1 "$host" >> /etc/hosts
+hostname=$(jq -r '.hostname' config.json)
-rm -rf html
-mkdir -p html
+if ! grep -qF "$hostname" "/etc/hosts"; then
+ echo "$hostname" >> "/etc/hosts"
+fi
+
+echo 127.0.0.1 "$hostname" >> /etc/hosts
function curl_and_save() {
echo Hitting URL "$1"
@@ -34,33 +38,50 @@ function curl_and_save() {
fi
}
-curl_and_save "https://$host/" "html/index.html"
+curl_and_save "https://$hostname/" "html/index.html"
-# generate html from all md files at pages directory
+#region Building HTML files
+rm -rf html
+mkdir -p html
+
+# pages/*.md HTML BUilding
for file in pages/*.md; do
filename=$(basename "$file" .md)
- curl_and_save "https://$host/$filename" "html/$filename.html"
-done
-
-# generate html from all php files at home directory except index.php, page.php and post.php
-for file in *.php; do
- if [[ "$file" != "index.php" && "$file" != "page.php" && "$file" != "post.php" ]]; then
- filename=$(basename "$file" .php)
- curl_and_save "https://$host/$filename" "html/$filename.html"
- fi
+ curl_and_save "https://$hostname/$filename" "html/$filename.html"
done
-# generate html from all md files at posts directory
+# posts/*.md HTML Building
mkdir -p html/p
for file in posts/*.md; do
filename=$(basename "$file" .md)
slug=$(awk -F': ' '/^slug:|^[ \t]*"slug":/ {gsub(/["\r]/, "", $2); print $2}' $file)
- curl_and_save "https://$host/p/$slug" "html/p/$slug.html"
+ curl_and_save "https://$hostname/p/$slug" "html/p/$slug.html"
done
+# **/*.php Any php file HTML Building
+find . -name "*.php" ! -path "./system/*" | while read -r file; do
+ if [[ "$file" == "index.php" || "$file" == "page.php" || "$file" != "post.php" ]]; then
+ continue;
+ fi
+
+ without_extension="${file%.*}"
+ # Replace the .php extension with .txt
+ html_file="html/${file%.php}.html"
+
+ # Create the directory structure if it doesn't exist
+ mkdir -p "$(dirname "$html_file")"
+
+ filename=$(basename "$file" .php)
+ curl_and_save "https://$hostname/$without_extension" "$html_file"
+done
+
+#endregion
+
+# ./assets/* copying to ./html
cp -R assets html/assets
+# Build CSS
lessc html/assets/styles/style.less html/assets/styles/style.css
-
+# Remove .less as .css file is built
rm -f html/assets/styles/*.less
-
+# Robots.txt is good to have
cp robots.txt html/
diff --git a/system/workflow-image/Dockerfile b/system/workflow-image/Dockerfile
index 2b66f01..029751a 100644
--- a/system/workflow-image/Dockerfile
+++ b/system/workflow-image/Dockerfile
@@ -10,6 +10,7 @@ RUN apt-get update && apt-get install -y \
node-less \
git \
jq \
+ procps \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd pdo_mysql