Add script for creating draft blog posts

This commit is contained in:
str4d
2016-07-02 03:58:52 +00:00
parent 278ae3db1e
commit c925b7454e

50
create-blog-post.sh Executable file
View File

@ -0,0 +1,50 @@
#!/bin/sh
BLOG_DIR="i2p2www/blog"
if [ $# -lt 3 ]
then
echo "Usage: ./create-blog-post.sh name-in-url \"Title of blog post\" author [category]"
exit
fi
name=$1
title=$2
author=$3
category=$4
date=`TZ=UTC date +%Y-%m-%d`
datedir=`TZ=UTC date +%Y/%m/%d`
titleline=`printf '%*s' "$(expr length "$title")" | tr ' ' =`
post="$BLOG_DIR/$datedir/$name.draft.rst"
mkdir -p "$BLOG_DIR/$datedir"
cat >"$post" <<EOF
{% trans -%}
$titleline
$title
$titleline
{%- endtrans %}
.. meta::
:author: $author
:date: $date
EOF
if [ -n "$category" ]
then
cat >>"$post" <<EOF
:category: $category
EOF
fi
cat >>"$post" <<EOF
:excerpt: {% trans %}{% endtrans %}
{% trans -%}
{%- endtrans %}
EOF
echo "Draft blog post created: $post"
echo "See i2p2www/blog/README for more information."