preping v0.1.0

This commit is contained in:
Simon Petit 2024-10-27 18:27:06 +01:00
parent 191c3a78e5
commit 88ec76dcee
2 changed files with 29 additions and 8 deletions

31
bob2
View File

@ -15,9 +15,10 @@ usage()
your blog" your blog"
echo echo
echo "bob commands :" echo "bob commands :"
echo " help display this help" echo " help display this help"
echo " init initiate a blog" echo " init initiate a blog"
echo " publish publish the blog" echo " publish <post> publish the post"
echo " unpublish <post> unpublish the post"
} }
@ -51,7 +52,7 @@ init()
update_index() update_index()
{ {
ls -t ./posts | awk ' posts=$(ls -t ./posts | awk '
BEGIN { BEGIN {
print "<ul>" print "<ul>"
} }
@ -63,7 +64,11 @@ update_index()
} }
END { END {
print "</ul>" print "</ul>"
}' }')
template="./lib/template/index.html"
awk -v content="$posts" '{gsub(/{{articles}}/, content); print}' "$template" > "./index.html"
} }
publish() publish()
@ -72,12 +77,26 @@ publish()
template="./lib/template/post.html" template="./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
update_index
} }
unpublish() unpublish()
{ {
rm ./posts/$1.html rm ./posts/$1.html
mv ./drafts/published/$1.md ./drafts/$1.md mv ./drafts/published/$1.md ./drafts/$1.md
update_index
}
unpublish_all()
{
rm ./posts/*
}
deploy()
{
scp
} }
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
@ -100,6 +119,8 @@ elif [[ "$1" == "unpublish" ]]; then
else else
unpublish $2 unpublish $2
fi fi
elif [[ "$1" == "deploy" ]]; then
deploy
elif [[ "$1" == "help" ]]; then elif [[ "$1" == "help" ]]; then
usage usage
fi fi

View File

@ -6,11 +6,11 @@
<title>simpet</title> <title>simpet</title>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<link href="https://fonts.googleapis.com/css?family=Cutive+Mono|IBM+Plex+Mono&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Cutive+Mono|IBM+Plex+Mono&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="../css/indexstyle.css"> <link rel="stylesheet" type="text/css" href="../css/poststyle.css">
</head> </head>
<body> <body>
<h1 class='title'>simpet</h1> <h1 class='title'><a href="../index.html">simpet</a></h1>
<article> <article>
{{article}} {{article}}
</article> </article>