2019-01-28 22:23:15 +00:00
|
|
|
#!/usr/local/bin/python3
|
2017-08-02 10:08:57 +00:00
|
|
|
import datetime
|
|
|
|
|
|
|
|
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
|
2019-01-28 22:23:15 +00:00
|
|
|
tags: tag1, tag2..
|
2017-08-02 10:08:57 +00:00
|
|
|
'''
|
|
|
|
metadata_fmt = """---
|
|
|
|
layout: post
|
|
|
|
title: "{}"
|
|
|
|
date: {}
|
|
|
|
comments: true
|
2019-01-28 22:23:15 +00:00
|
|
|
tags: {}
|
2017-08-02 10:08:57 +00:00
|
|
|
---
|
|
|
|
"""
|
|
|
|
metadata_fmt = metadata_fmt.format(
|
|
|
|
blog_title,
|
|
|
|
title_date,
|
2019-01-29 19:29:28 +00:00
|
|
|
', '.join(tags.split())
|
2017-08-02 10:08:57 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
with open('blog/{}'.format(filename), 'w') as f:
|
|
|
|
f.write(metadata_fmt)
|
|
|
|
|
|
|
|
print("New entry {} is ready at {} for editing".format(
|
|
|
|
blog_title, filename,
|
|
|
|
))
|