commit ebb68bae109beabb4155271f1ff7fdbdeac51eb8
parent 93557fc66d29a4844af6665ed0eb7ea4fb36d665
Author: Christos Margiolis <christos@margiolis.net>
Date: Wed, 14 Oct 2020 17:37:08 +0300
pending blogindex dating update implementation
Diffstat:
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
@@ -62,6 +62,7 @@ Options:
-v View draft post in browser
-t Delete draft post
-r Revise published post
+ -c Change title
-o View published post in browser
-d Delete published post
-l List all published posts
diff --git a/autoblog b/autoblog
@@ -50,6 +50,9 @@ publish()
printf "\t\t\t\t<li>%s – <a href=\"%s\">%s</a></li>\n" "$(date '+%Y %b %d')" "$blogdir/$blogpost.html" "$title" | expand -t4 > $draftdir/$blogpost-htmlentry
printf "<item>\n\t<title>%s</title>\n\t<guid>%s</guid>\n\t<pubDate>%s</pubDate>\n\t<description>\n\t\t%s\n\t</description>\n</item>\n" "$title" "$website/$blogdir/$blogpost.html" "$(date '+%a, %d %b %Y')" "$(cat $draftdir/$blogpost.xml)" | expand -t4 > $draftdir/$blogpost-rssentry
+ #dateid=$(date '+%b %Y' | sed 's/\ //' | tr '[:upper:]' '[:lower:]')
+ #[ -z "$(grep "$dateid" $blogindex)" ] && update_blogindex
+
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 && echo "RSS... done"
@@ -76,6 +79,15 @@ view()
$BROWSER $draftdir/$blogpost-final-view.html
}
+# TEST
+update_blogindex()
+{
+ #dateid=$(date '+%b %Y' | sed 's/\ //' | tr '[:upper:]' '[:lower:]')
+ datename=$(date '+%B %Y')
+ monthheader=$(echo -e "<h2 id=\"$dateid\">$datename<\/h2>\n<ul>\n\t<\!--BLOG $datename-->\n<\/ul>" | sed 's/^/\t\t\t/' | expand -t4)
+ sed "/<\!--BLOG-->/a $monthheader" $blogindex
+}
+
remove_contents()
{
ls $1 | grep -w $blogpost | sed "s/^/$1\//" | xargs rm
@@ -100,8 +112,9 @@ case $1 in
-v*) listposts $draftdir && view ;;
-t*) listposts $draftdir && delete $draftdir ;;
-r*) listposts $blogdir && $EDITOR $blogdir/$blogpost.html ;;
+ -c*) listposts $blogdir && exit ;;
-o*) listposts $blogdir && $BROWSER $blogdir/$blogpost.html ;;
-d*) listposts $blogdir && delete $blogdir ;;
-l*) listposts $blogdir ;;
- *) printf "Usage: autoblog [OPTION]\n\nOptions:\n -n\t\tNew post\n -p\t\tPublish draft post\n -e\t\tEdit draft post\n -v\t\tView draft post in browser\n -t\t\tDelete draft post\n -r\t\tRevise published post\n -o\t\tView published post in browser\n -d\t\tDelete published post\n -l\t\tList all published posts\n" ;;
+ *) printf "Usage: autoblog [OPTION]\n\nOptions:\n -n\t\tNew post\n -p\t\tPublish draft post\n -e\t\tEdit draft post\n -v\t\tView draft post in browser\n -t\t\tDelete draft post\n -r\t\tRevise published post\n -c\t\tChange title\n -o\t\tView published post in browser\n -d\t\tDelete published post\n -l\t\tList all published posts\n" ;;
esac
diff --git a/autoblog.1 b/autoblog.1
@@ -9,6 +9,7 @@ autoblog \- automatic blog and RSS system
.RB [ \-v \ view\ draft ]
.RB [ \-t \ delete\ draft ]
.RB [ \-r \ revise\ published ]
+.RB [ \-c \ change\ title]
.RB [ \-o \ view\ published ]
.RB [ \-d \ delete\ published ]
.RB [ \-l \ list\ all\ published ]
@@ -36,6 +37,9 @@ Delete one of the posts stored in the .drafts directory.
.BR \-r
Revise a published post stored in the blog directory.
.TP
+.BR \-c
+Change a published post's title.
+.TP
.BR \-o
View a published post stored in the blog directory on your default browser.
.TP