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
|
bash
|
||||||
posts
|
posts
|
||||||
*.conf
|
*.conf
|
||||||
index.html
|
./index.html
|
5
Makefile
5
Makefile
@ -1,14 +1,13 @@
|
|||||||
install:
|
install:
|
||||||
@echo "Installing bob"
|
@echo "Installing bob"
|
||||||
cp bob /usr/local/bin
|
cp bob /usr/local/bin
|
||||||
cp bob2 /usr/local/bin
|
mkdir -p /usr/local/lib/bob/template
|
||||||
cp -r lib/template /usr/local/lib/bob/template
|
cp lib/template/* /usr/local/lib/bob/template
|
||||||
cp lib/*.awk /usr/local/lib/bob
|
cp lib/*.awk /usr/local/lib/bob
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
@echo "Uninstalling bob"
|
@echo "Uninstalling bob"
|
||||||
rm /usr/local/bin/bob
|
rm /usr/local/bin/bob
|
||||||
rm /usr/local/bin/bob2
|
|
||||||
rm -rf /usr/local/lib/bob
|
rm -rf /usr/local/lib/bob
|
||||||
|
|
||||||
.PHONY: test # Declare 'test' as a phony target
|
.PHONY: test # Declare 'test' as a phony target
|
||||||
|
15
bob
15
bob
@ -1,5 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ -z "${BOB_LIB}" ]; then
|
||||||
|
BOB_LIB=/usr/local/lib/bob
|
||||||
|
else
|
||||||
|
BOB_LIB=./lib
|
||||||
|
fi
|
||||||
|
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
@ -66,15 +72,15 @@ update_index()
|
|||||||
print "</ul>"
|
print "</ul>"
|
||||||
}')
|
}')
|
||||||
|
|
||||||
template="./lib/template/index.html"
|
template="${BOB_LIB}/template/index.html"
|
||||||
awk -v content="$posts" '{gsub(/{{articles}}/, content); print}' "$template" > "./index.html"
|
awk -v content="$posts" '{gsub(/{{articles}}/, content); print}' "$template" > "./index.html"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
publish()
|
publish()
|
||||||
{
|
{
|
||||||
post=$(awk -f lib/markdown.awk ./drafts/$1.md)
|
post=$(awk -f ${BOB_LIB}/markdown.awk ./drafts/$1.md)
|
||||||
template="./lib/template/post.html"
|
template="${BOB_LIB}/template/post.html"
|
||||||
awk -v content="$post" '{gsub(/{{article}}/, content); print}' "$template" > "./posts/$1.html"
|
awk -v content="$post" '{gsub(/{{article}}/, content); print}' "$template" > "./posts/$1.html"
|
||||||
mv ./drafts/$1.md ./drafts/published/$1.md
|
mv ./drafts/$1.md ./drafts/published/$1.md
|
||||||
|
|
||||||
@ -92,11 +98,12 @@ unpublish()
|
|||||||
unpublish_all()
|
unpublish_all()
|
||||||
{
|
{
|
||||||
rm ./posts/*
|
rm ./posts/*
|
||||||
|
mv ./drafts/published/* ./drafts/
|
||||||
}
|
}
|
||||||
|
|
||||||
deploy()
|
deploy()
|
||||||
{
|
{
|
||||||
scp
|
echo "TODO"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user