diff --git a/blog/2017-08-02-hello-world.markdown b/blog/2017-08-02-hello-world.markdown new file mode 100644 index 0000000..0d33b02 --- /dev/null +++ b/blog/2017-08-02-hello-world.markdown @@ -0,0 +1,10 @@ +--- +layout: post +title: "hello world" +date: 2017-08-02 +comments: true +categories: + - script +--- + +well, lets see how you compule diff --git a/new_post.py b/new_post.py new file mode 100755 index 0000000..e61f8fa --- /dev/null +++ b/new_post.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +import datetime +import yaml + +blog_title = input('title for the entry: ') +title_date = input('date for the entry (format:yyyy-mm-dd|defaults to today): ') + +if not title_date: + title_date = datetime.datetime.strftime(datetime.datetime.now(), + '%Y-%m-%d') + +tags = input('tags (space seperated): ') + +filename = "{}-{}.markdown".format( + title_date, + '-'.join(blog_title.lower().split())) + +''' +layout: post +title: "go: `:=` operator causes accidental shadowing" +date: 2016-01-14 21:13 +comments: true +categories: + - go +''' +metadata_fmt = """--- +layout: post +title: "{}" +date: {} +comments: true +categories: +{} +--- +""" +catblock = " - {}" +cats = map(catblock.format, tags.split()) + + +metadata_fmt = metadata_fmt.format( + blog_title, + title_date, + '\n'.join(cats) +) + +with open('blog/{}'.format(filename), 'w') as f: + f.write(metadata_fmt) + +print("New entry {} is ready at {} for editing".format( + blog_title, filename, +))