From fedb059fdbe89343a943d8456b175ea8878d2140 Mon Sep 17 00:00:00 2001 From: sceox Date: Mon, 14 Sep 2020 10:16:48 -0700 Subject: [PATCH] use markdown(1) and cat(1) to build the html * add an empty footer * add a minimal html header * indent the nav * modify the build process (publish.sh): * use a tmp directory * use discount markdown(1) rather than discount mkd2html(1) * generate html page title from the file name * indent html body * use cat(1) to combine the pieces * remove trailing newlines in publish.sh * git ignore tmp/ directory --- .gitignore | 1 + foot.html | 2 ++ head.html | 5 +++++ nav.html | 12 ++++++------ publish.sh | 20 +++++++++++++------- tail.html | 2 ++ 6 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 .gitignore create mode 100644 foot.html create mode 100644 head.html create mode 100644 tail.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9a5aec --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tmp diff --git a/foot.html b/foot.html new file mode 100644 index 0000000..921ba2a --- /dev/null +++ b/foot.html @@ -0,0 +1,2 @@ + diff --git a/head.html b/head.html new file mode 100644 index 0000000..d8de143 --- /dev/null +++ b/head.html @@ -0,0 +1,5 @@ + + + + + diff --git a/nav.html b/nav.html index 4908df8..f656851 100644 --- a/nav.html +++ b/nav.html @@ -1,6 +1,6 @@ - + diff --git a/publish.sh b/publish.sh index 870255c..6b87434 100755 --- a/publish.sh +++ b/publish.sh @@ -3,15 +3,21 @@ PUB_DIR=${1:-/home/html/planet/static} FILES=md/*.md +test -d tmp || mkdir tmp + for f in $FILES do filename=$(basename -- $f .md) echo "publishing md/$filename.md to $PUB_DIR/$filename.html" - mkd2html -css style.css $f - mv md/*.html $PUB_DIR - - # TODO insert nav before tag - # sed '//e cat nav.html' html/$filename.html + markdown -o tmp/$filename.html $f + sed -i 's/^/ /' tmp/$filename.html + cp head.html tmp/ + # set the title + title="$(echo $filename | awk '{for(i=1;i<=NF;i++){ $i=toupper(substr($i,1,1)) substr($i,2) }}1')" + echo " $title • Anarchy Planet" >> tmp/head.html + echo " " >> tmp/head.html + echo " " >> tmp/head.html + # compile the elements in order + cat tmp/head.html nav.html tmp/$filename.html foot.html tail.html \ + > $PUB_DIR/$filename.html done - - diff --git a/tail.html b/tail.html new file mode 100644 index 0000000..b605728 --- /dev/null +++ b/tail.html @@ -0,0 +1,2 @@ + +