Created
July 23, 2017 22:00
-
-
Save jkw/ca951c00c197f7c1e3fff26cfa4cd966 to your computer and use it in GitHub Desktop.
Create mockup .md files for blogposts using Pelican.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Create a Markdown-file with current time and date etc. | |
""" | |
import datetime | |
import os | |
def createpost(): | |
today = datetime.datetime.now() | |
fixdate = today.strftime('%d%m%y') | |
filename = fixdate.strip(' ') + '.md' | |
os.mknod(filename) | |
print('[**] Created file:', filename) | |
with open(filename, 'w') as f: | |
post_title = input('[**] Title of the page? ') | |
f.write('Title: ' + post_title + '\n') | |
f.write('Date: ' + today.strftime('%Y-%m-%d %H:%M:%S') + '\n') | |
f.write('Modified: ' + today.strftime('%Y-%m-%d %H:%M:%S') + '\n') | |
f.write('Category: ' + input('[**] Category? ') + '\n') | |
f.write('Tags: ' + input('[**] Tags? ') + '\n') | |
f.write('Slug: ' + input('[**] Slug? ') + '\n') | |
f.write('Authors: ' + input('[**] Authors? ') + '\n') | |
f.write('Summary: ' + input('[**] Summary? ') + '\n\n') | |
f.write('#' + post_title + '\n\n') | |
print('[**] Post created and updated.') | |
createpost() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment