wip
This commit is contained in:
parent
9257373163
commit
191c3a78e5
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,4 +5,3 @@ bash
|
|||||||
posts
|
posts
|
||||||
*.conf
|
*.conf
|
||||||
index.html
|
index.html
|
||||||
README.html
|
|
||||||
|
5
Makefile
5
Makefile
@ -2,13 +2,14 @@ install:
|
|||||||
@echo "Installing bob"
|
@echo "Installing bob"
|
||||||
cp bob /usr/local/bin
|
cp bob /usr/local/bin
|
||||||
cp bob2 /usr/local/bin
|
cp bob2 /usr/local/bin
|
||||||
cp -r lib /usr/local/lib/bob
|
cp -r lib/template /usr/local/lib/bob/template
|
||||||
|
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 /usr/local/bin/bob2
|
||||||
rm -r /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
|
||||||
|
|
||||||
|
61
bob2
61
bob2
@ -16,7 +16,7 @@ usage()
|
|||||||
echo
|
echo
|
||||||
echo "bob commands :"
|
echo "bob commands :"
|
||||||
echo " help display this help"
|
echo " help display this help"
|
||||||
echo " init initiate the blog"
|
echo " init initiate a blog"
|
||||||
echo " publish publish the blog"
|
echo " publish publish the blog"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,31 +25,60 @@ init()
|
|||||||
{
|
{
|
||||||
echo Name of the author of the blog :
|
echo Name of the author of the blog :
|
||||||
read author
|
read author
|
||||||
echo "author:$author" > .blog.conf
|
echo "author=$author" > .blog.conf
|
||||||
echo Name of the blog :
|
echo Name of the blog :
|
||||||
read blog
|
read blog
|
||||||
echo "blog:$blog" >> .blog.conf
|
echo "blog=$blog" >> .blog.conf
|
||||||
echo "Language of the blog : (en)"
|
echo "Language of the blog : [en]"
|
||||||
read lang
|
read lang
|
||||||
if [ -z $lang ]; then
|
if [ -z $lang ]; then
|
||||||
lang=en
|
lang=en
|
||||||
fi
|
fi
|
||||||
echo "lang:$lang" >> .blog.conf
|
echo "lang=$lang" >> .blog.conf
|
||||||
echo "Activate dark mode : (y/N)"
|
echo "Activate dark mode : (y/N)"
|
||||||
read dark
|
read dark
|
||||||
if [ -z $dark ]; then
|
if [ -z $dark ]; then
|
||||||
dark=n
|
dark=n
|
||||||
fi
|
fi
|
||||||
echo "dark:$dark" >> .blog.conf
|
echo "dark=$dark" >> .blog.conf
|
||||||
mkdir drafts
|
mkdir drafts
|
||||||
mkdir bases
|
# mkdir templates
|
||||||
mkdir posts
|
mkdir posts
|
||||||
mkdir css
|
# mkdir css
|
||||||
_init_css
|
# _init_css
|
||||||
_index "$blog" "$lang" "$dark"
|
# _index "$blog" "$lang" "$dark"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_index()
|
||||||
|
{
|
||||||
|
ls -t ./posts | awk '
|
||||||
|
BEGIN {
|
||||||
|
print "<ul>"
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ref=$0
|
||||||
|
gsub(".html","",ref)
|
||||||
|
gsub(/[_-]/, " ", ref)
|
||||||
|
print "<li><a href=\"./posts/" $0 "\">" ref "</a></li>"
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
print "</ul>"
|
||||||
|
}'
|
||||||
|
}
|
||||||
|
|
||||||
|
publish()
|
||||||
|
{
|
||||||
|
post=$(awk -f lib/markdown.awk ./drafts/$1.md)
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
unpublish()
|
||||||
|
{
|
||||||
|
rm ./posts/$1.html
|
||||||
|
mv ./drafts/published/$1.md ./drafts/$1.md
|
||||||
|
}
|
||||||
|
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
usage
|
usage
|
||||||
@ -60,7 +89,17 @@ elif [[ "$1" == "usage" ]]; then
|
|||||||
elif [[ "$1" == "init" ]]; then
|
elif [[ "$1" == "init" ]]; then
|
||||||
init
|
init
|
||||||
elif [[ "$1" == "publish" ]]; then
|
elif [[ "$1" == "publish" ]]; then
|
||||||
publish
|
if [[ $# -eq 1 ]]; then
|
||||||
|
echo "Usage : bob publish <draft_name>"
|
||||||
|
else
|
||||||
|
publish $2
|
||||||
|
fi
|
||||||
|
elif [[ "$1" == "unpublish" ]]; then
|
||||||
|
if [[ $# -eq 1 ]]; then
|
||||||
|
echo "Usage : bob unpublish <post_name>"
|
||||||
|
else
|
||||||
|
unpublish $2
|
||||||
|
fi
|
||||||
elif [[ "$1" == "help" ]]; then
|
elif [[ "$1" == "help" ]]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr" dir="ltr">
|
<html lang="fr" dir="ltr">
|
||||||
<head>
|
|
||||||
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<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/indexstyle.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
|
||||||
|
<body>
|
||||||
<h1 class='title'>simpet</h1>
|
<h1 class='title'>simpet</h1>
|
||||||
<article>
|
<article>
|
||||||
{{article}}
|
{{article}}
|
||||||
</article>
|
</article>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
0
test/bob/test_init.sh
Normal file
0
test/bob/test_init.sh
Normal file
24
test/test.sh
24
test/test.sh
@ -8,4 +8,26 @@ NC='\033[0m' # No Color (reset)
|
|||||||
|
|
||||||
echo -e "${YELLOW}Testing markown parser :${NC}\n"
|
echo -e "${YELLOW}Testing markown parser :${NC}\n"
|
||||||
|
|
||||||
./parser/test_md_parser.sh ../lib/markdown.awk awk
|
./test/parser/test_md_parser.sh ./lib/markdown.awk awk
|
||||||
|
|
||||||
|
echo -e "${YELLOW}Testing bob init :${NC}\n"
|
||||||
|
|
||||||
|
author="author"
|
||||||
|
blog="blog"
|
||||||
|
lang="fr"
|
||||||
|
dark="y"
|
||||||
|
|
||||||
|
./bob2 init << EOF
|
||||||
|
$author
|
||||||
|
$blog
|
||||||
|
$lang
|
||||||
|
$dark
|
||||||
|
EOF
|
||||||
|
|
||||||
|
conf_author=$(grep "^author=" .blog.conf | cut -d '=' -f 2)
|
||||||
|
conf_blog=$(grep "^blog=" .blog.conf | cut -d '=' -f 2)
|
||||||
|
conf_lang=$(grep "^lang=" .blog.conf | cut -d '=' -f 2)
|
||||||
|
conf_dark=$(grep "^dark=" .blog.conf | cut -d '=' -f 2)
|
||||||
|
|
||||||
|
rm -r posts
|
||||||
|
rm -r drafts
|
Loading…
Reference in New Issue
Block a user