improving installation + adding variable to execute awk script
This commit is contained in:
parent
5234e54a81
commit
029a99216d
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,4 +4,4 @@ css
|
||||
bash
|
||||
posts
|
||||
*.conf
|
||||
index.html
|
||||
./index.html
|
5
Makefile
5
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
|
||||
|
15
bob
15
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 "</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
|
||||
|
Loading…
Reference in New Issue
Block a user