monochromatic

monochromatic blog: http://blog.z3bra.org
git clone git://z3bra.org/monochromatic
Log | Files | Refs

commit 7f5983cd9ddf343e98d74249ee9ca8fbfdde0372
parent 72d3b9af102866db14adbd8f8a14d3d1729b18a3
Author: z3bra <willy@mailoo.org>
Date:   Mon,  3 Feb 2014 11:20:39 +0100

Improved the post.sh script

Diffstat:
tools/body.template | 4++--
tools/post.sh | 34+++++++++++++++++++++++++---------
tools/publi.sh | 2+-
3 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/tools/body.template b/tools/body.template @@ -1,10 +1,10 @@ <div id='wrapper'> <section> <h1> - <a href='#'></a> + <a href='#'>BLOG_TITLE</a> </h1> <h2> - &mdash; + &mdash; BLOG_DATE </h2> <article> <p> diff --git a/tools/post.sh b/tools/post.sh @@ -1,18 +1,34 @@ #!/bin/bash -[[ -z "$1" ]] && exit 1 -folder=$(date +%Y/%m) -file=${1// /-}.html -[[ ! -d ${folder} ]] && mkdir -p ${folder} +# Ask the user for a title +read -p "post title" title -POST="${folder}/${file}" +# use post title to name the file +file=`echo ${title}| sed "s/\s\+/-/g;s/./\l&/g;s/[,.!;\"']/g"` -cat tools/{head,body,foot}.template >> $POST +#date format for the post +date=`date +%d %B, %Y` -[[ ! -f ${folder}/${file} ]] && echo "cannot create ${POST}" && exit 1 +# The format of the path to the post, here: /yyyy/mm/ +folder=`date +%Y/%m` -echo "$POST created" +# create the path if it does not exists +test -d ${folder} || mkdir -p ${folder} -ln -fs ${POST} post.html +# build the whole path +post="${folder}/${file}" + +# use the templates to create the post skeleton +cat tools/{head,body,foot}.template >> ${post} + +# put the title and date in the post +sed "s/BLOG_TITLE/${title};s/BLOG_DATE/${date}" + +test -f ${folder}/${file} || echo "cannot create ${post}" && exit 1 + +echo "$post created" + +# create a symlink to the last post, to easily access it +ln -fs ${post} last_post.html diff --git a/tools/publi.sh b/tools/publi.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Re-generate the RSS feed tools/feeds.sh