improving installation + adding variable to execute awk script

This commit is contained in:
Simon Petit 2024-10-28 22:06:49 +01:00
parent 5234e54a81
commit 029a99216d
3 changed files with 14 additions and 8 deletions

2
.gitignore vendored
View File

@ -4,4 +4,4 @@ css
bash
posts
*.conf
index.html
./index.html

View File

@ -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

15
bob
View File

@ -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 "</ul>"
}')
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