From 029a99216d6a7d7653efd8398a34adcd1ee54672 Mon Sep 17 00:00:00 2001 From: Simon Petit Date: Mon, 28 Oct 2024 22:06:49 +0100 Subject: [PATCH] improving installation + adding variable to execute awk script --- .gitignore | 2 +- Makefile | 5 ++--- bob | 15 +++++++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index e32f34a..203d664 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ css bash posts *.conf -index.html \ No newline at end of file +./index.html \ No newline at end of file diff --git a/Makefile b/Makefile index 4e749a2..3bfde08 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,13 @@ install: @echo "Installing bob" cp bob /usr/local/bin - cp bob2 /usr/local/bin - cp -r lib/template /usr/local/lib/bob/template + mkdir -p /usr/local/lib/bob/template + cp lib/template/* /usr/local/lib/bob/template cp lib/*.awk /usr/local/lib/bob uninstall: @echo "Uninstalling bob" rm /usr/local/bin/bob - rm /usr/local/bin/bob2 rm -rf /usr/local/lib/bob .PHONY: test # Declare 'test' as a phony target diff --git a/bob b/bob index 710d31e..a2ecb2a 100755 --- a/bob +++ b/bob @@ -1,5 +1,11 @@ #!/usr/bin/env bash +if [ -z "${BOB_LIB}" ]; then + BOB_LIB=/usr/local/lib/bob +else + BOB_LIB=./lib +fi + usage() { echo @@ -66,15 +72,15 @@ update_index() print "" }') - template="./lib/template/index.html" + template="${BOB_LIB}/template/index.html" awk -v content="$posts" '{gsub(/{{articles}}/, content); print}' "$template" > "./index.html" } publish() { - post=$(awk -f lib/markdown.awk ./drafts/$1.md) - template="./lib/template/post.html" + post=$(awk -f ${BOB_LIB}/markdown.awk ./drafts/$1.md) + template="${BOB_LIB}/template/post.html" awk -v content="$post" '{gsub(/{{article}}/, content); print}' "$template" > "./posts/$1.html" mv ./drafts/$1.md ./drafts/published/$1.md @@ -92,11 +98,12 @@ unpublish() unpublish_all() { rm ./posts/* + mv ./drafts/published/* ./drafts/ } deploy() { - scp + echo "TODO" } if [[ $# -eq 0 ]]; then