From 88ec76dcee6f67f68a810cc90120a9b211ce95b2 Mon Sep 17 00:00:00 2001 From: Simon Petit Date: Sun, 27 Oct 2024 18:27:06 +0100 Subject: [PATCH] preping v0.1.0 --- bob2 | 33 +++++++++++++++++++++++++++------ lib/template/post.html | 4 ++-- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/bob2 b/bob2 index 982ad3c..710d31e 100755 --- a/bob2 +++ b/bob2 @@ -15,9 +15,10 @@ usage() your blog" echo echo "bob commands :" - echo " help display this help" - echo " init initiate a blog" - echo " publish publish the blog" + echo " help display this help" + echo " init initiate a blog" + echo " publish publish the post" + echo " unpublish unpublish the post" } @@ -51,7 +52,7 @@ init() update_index() { - ls -t ./posts | awk ' + posts=$(ls -t ./posts | awk ' BEGIN { print "
    " } @@ -63,7 +64,11 @@ update_index() } END { print "
" - }' + }') + + template="./lib/template/index.html" + awk -v content="$posts" '{gsub(/{{articles}}/, content); print}' "$template" > "./index.html" + } publish() @@ -72,12 +77,26 @@ publish() template="./lib/template/post.html" awk -v content="$post" '{gsub(/{{article}}/, content); print}' "$template" > "./posts/$1.html" mv ./drafts/$1.md ./drafts/published/$1.md + + update_index } unpublish() { rm ./posts/$1.html mv ./drafts/published/$1.md ./drafts/$1.md + + update_index +} + +unpublish_all() +{ + rm ./posts/* +} + +deploy() +{ + scp } if [[ $# -eq 0 ]]; then @@ -91,7 +110,7 @@ elif [[ "$1" == "init" ]]; then elif [[ "$1" == "publish" ]]; then if [[ $# -eq 1 ]]; then echo "Usage : bob publish " - else + else publish $2 fi elif [[ "$1" == "unpublish" ]]; then @@ -100,6 +119,8 @@ elif [[ "$1" == "unpublish" ]]; then else unpublish $2 fi +elif [[ "$1" == "deploy" ]]; then + deploy elif [[ "$1" == "help" ]]; then usage fi diff --git a/lib/template/post.html b/lib/template/post.html index e3627a0..3dbcd77 100644 --- a/lib/template/post.html +++ b/lib/template/post.html @@ -6,11 +6,11 @@ simpet - + -

simpet

+

simpet

{{article}}