Skip to content

Instantly share code, notes, and snippets.

@jkw
Created July 23, 2017 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkw/ca951c00c197f7c1e3fff26cfa4cd966 to your computer and use it in GitHub Desktop.
Save jkw/ca951c00c197f7c1e3fff26cfa4cd966 to your computer and use it in GitHub Desktop.
Create mockup .md files for blogposts using Pelican.
#!/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