From 82b4e402fe44dfac8d9e0369d507d0281df44046 Mon Sep 17 00:00:00 2001 From: Stephen Cochrane Date: Tue, 10 Nov 2020 10:24:09 +0200 Subject: [PATCH] Added dev build mode --- Makefile | 5 +++++ build.sh | 52 ++++++++++++++++++++++++++++++++--------------- raw/template.html | 6 +++++- 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 753a29d..39fb54f 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,8 @@ EXE=bin/GenBlog all: comp blog build +demo: comp blog buildd + comp: install $(CC) $(FLAGS) src/GenBlog.c -o $(EXE) @@ -24,6 +26,9 @@ clean: build: ./build.sh +buildd: + ./build.sh -d + blog: comp @# Reset all blogs to start build. @# Setup boilerplate html files for blog files diff --git a/build.sh b/build.sh index 63517a1..3ad6f01 100755 --- a/build.sh +++ b/build.sh @@ -14,22 +14,42 @@ conv () { sed -E "s|(\\!/)([^ \)]*)|!\/\2|g" | sed -E '/%%BODY%%/r /dev/stdin' raw/template.html | - sed -E '/%%BODY%%/d' + sed -E '/%%BODY%%/d' | + sed 's/%%HEADER%%/'"$header"'/g' } -mkdir -p site -for file in raw/*.txt -do - case $file in - *index.txt) - path=index.html - ;; - *) - path=${file/raw/site} - path=${path/txt/html} - ;; - esac +main () { + while getopts "d" opt + do + case $opt in + d) + dev="

Please note, this is the development page, things may be broken\.<\/h4>
Details<\/summary>This version of my website is hosted inside a docker container and pulls from origin\/dev every 10 seconds, hence it is possible for the site to be unstable, this is only for demo purposes\.<\/details>" + ;; + *) + exit 2 + ;; + esac + done - echo "Building $file" - conv < "$file" > $path -done + mkdir -p site + for file in raw/*.txt + do + case $file in + *index.txt) + path=index.html + header="

Skiqqy<\/h1>~ Pronounced skippy" + ;; + *) + header="

$(echo $file | cut -d "/" -f 2 | cut -d "." -f 1)<\/h1>" + path=${file/raw/site} + path=${path/txt/html} + ;; + esac + [[ -n $dev ]] && header="$header$dev" + + echo "Building $file" + conv < "$file" > $path + done +} + +main "$@" diff --git a/raw/template.html b/raw/template.html index fa55e1f..40fdbef 100644 --- a/raw/template.html +++ b/raw/template.html @@ -40,8 +40,12 @@ text-align: center; font-size: 30px; } + + .dev { + color: orange + } -

Skiqqy

~ Pronounced skippy
+
%%HEADER%%