Skip to content

Commit

Permalink
Add: New post creation helper
Browse files Browse the repository at this point in the history
  • Loading branch information
divarvel committed Oct 21, 2012
1 parent 98dcd42 commit d549bee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ build: hakyll
hakyll: hakyll.hs
ghc --make hakyll.hs

new:
@./new_post.sh

publish: build
#ToDo
24 changes: 24 additions & 0 deletions new_post.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

date_pattern=`date "+%Y-%m-%d"`-

read -r -p "Post name > "
title=${REPLY}
clean_title=`echo $title | tr "[:upper:]" "[:lower:]"]` #Lower Case
clean_title=`echo $clean_title | iconv -f utf-8 -t ascii//translit` #Remove accents
clean_title=`echo $clean_title | tr -dc "[a-z ]"` #Keep spaces and letters
clean_title=`echo $clean_title | tr " " "-"` #Replace spaces by dashes

filename=$date_pattern$clean_title.md
author=`git config --get user.name`

cat > "posts/"$filename <<EOF
---
title: $title
author: $author
tags:
---
EOF

$EDITOR "posts/"$filename

0 comments on commit d549bee

Please sign in to comment.