Last active
January 8, 2016 09:51
-
-
Save narenaryan/c35d4eafcc9eea6fe5fe to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import datetime | |
| import os | |
| __name__ = "Script for generating Markdown metadata for a new post for pelican" | |
| __author__ = "Naren Arya" | |
| __date__ = "08-01-2016" | |
| BASE_DIR = os.path.dirname(os.path.dirname(__file__)) | |
| title = input("Enter title for your brand new article: ") | |
| category = input("Enter category: ") | |
| tags = input("Enter tags with comma seperated: ") | |
| slug = input("Enter slug(blank for default): ") | |
| summary = input("Enter summary for your writeup: ") | |
| date = modified = datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S') | |
| file_name = '_'.join(title.split()) + '.md' | |
| if slug.strip() == '': | |
| slug = date | |
| template = """ | |
| Title : {title} | |
| Date: {date} | |
| Modified: {modified} | |
| Category: {category} | |
| Tags: {tags} | |
| Slug: {slug} | |
| Authors: Naren Arya | |
| Summary: {summary} | |
| <!--- | |
| Begin your post content here | |
| --> | |
| """ | |
| template = template.format( | |
| title=title, | |
| date=date, | |
| modified=modified, | |
| tags=tags, | |
| slug=slug, | |
| summary=summary, | |
| category=category | |
| ) | |
| with open(BASE_DIR + 'content/' + file_name, 'w') as f: | |
| f.write(template) | |
| print("File successfully created -> %s" % file_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment