sbrs

Simple blog and RSS system
git clone git://git.christosmarg.xyz/sbrs.git
Log | Files | Refs | README | LICENSE

commit 13813f40095a14fb1251c04d2c923e2da599943a
parent 031733532b928891d108dcee672c1ee3b775cac1
Author: Christos Margiolis <christos@margiolis.net>
Date:   Sat, 29 Aug 2020 00:25:47 +0300

added index example and fixed blogindex BLOG position

Diffstat:
Mautoblog | 14+++++++-------
Mblogindex.html | 2+-
Aindex.html | 15+++++++++++++++
3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/autoblog b/autoblog @@ -8,11 +8,11 @@ blogindex="blogindex.html" index="index.html" rssfile="rss.xml" template="template.html" -[ -z $EDITOR ] && EDITOR="vim" +[ -z $EDITOR ] && EDITOR="nano" [ ! -d $blogdir ] && - read -erp "Blog directory doesn't exist. Initialize it here (y/n)? " initdir && - [ "$initdir" = "y" ] && mkdir -pv $blogdir + read -erp "Blog directory doesn't exist. Initialize it here (y/n)? " initblogdir && + [ "$initblogdir" = "y" ] && mkdir -pv $blogdir listposts() { @@ -42,7 +42,7 @@ publish() sed -i "/<\!--BLOG $(date '+%B %Y')-->/r $draftdir/$blogpost-htmlentry" $blogindex && echo "Blogindex... done." sed -i "/<\!--BLOG-->/r $draftdir/$blogpost-htmlentry" $index && echo "Index... done" - sed -i "/<\!--BLOG-->/r $draftdir/$blogpost-rssentry" $rssfile + sed -i "/<\!--BLOG-->/r $draftdir/$blogpost-rssentry" $rssfile && echo "RSS... done" remove_last_index_entry && echo "Removing last entry from index file... done" remove_contents $draftdir && echo "Cleaning up .drafts... done" echo "Published $blogpost." @@ -50,7 +50,7 @@ publish() delete() { - [ $(echo "$blogpost" | wc -l) -gt 1 ] && echo "Invalid choice" && exit + [ $(($(echo "$blogpost" | wc -l))) -gt 1 ] && echo "Invalid choice" && exit [ "$1" = "$blogdir" ] && sed -i "/$blogpost/d" $index $blogindex && sed -ni "/<item>/{ :loop; N; s/<\\/item>/&/; T loop; s/$blogpost/&/; T keep; d }; :keep; p" $rssfile @@ -72,8 +72,8 @@ remove_contents() remove_last_index_entry() { - indexentries=$(sed "1,/<\!--BLOG-->/d" $index | grep "<li>") - [ $(($(echo "$indexentries" | wc -l))) -gt 7 ] && + indexentries=$(sed "1,/<\!--BLOG-->/d" $index | grep "<li>") && + [ $(($(echo "$indexentries" | wc -l))) -gt 7 ] && lastentry=$(echo "$indexentries" | tail -2 | head -1) && sed -i "s|$lastentry||;" $index } diff --git a/blogindex.html b/blogindex.html @@ -7,9 +7,9 @@ </head> <body> - <!--BLOG [Month Year]--> <h2>Month Year</h2> <ul> + <!--BLOG [Month Year]--> </ul> </body> </html> diff --git a/index.html b/index.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="UTF-8"> + <link rel="stylesheet" href="styles.css"/> + <title>Website Index</title> + </head> + + <body> + <h2>Recent blog posts</h2> + <ul> + <!--BLOG--> + </ul> + </body> +</html>