Merge pull request #33 from Nerian/automate_post_creation

Automate post creation
This commit is contained in:
Michael Rose 2013-08-21 20:06:10 -07:00
commit 6a5d7eaedc
3 changed files with 58 additions and 18 deletions

View file

@ -4,3 +4,5 @@ gem 'jekyll'
gem 'jekyll-minibundle' gem 'jekyll-minibundle'
gem 'coderay' gem 'coderay'
gem 'rake' gem 'rake'
gem 'thor'
gem 'activesupport'

View file

@ -263,6 +263,16 @@ To make things easier I use LESS to build So Simple Theme's stylesheets. If you
--- ---
## Creating a new Post
You can create a new post like this:
```bash
$ thor post:new 'My cool post'
create _posts/2013-08-21-my-cool-post
```
---
## Questions? ## Questions?
Having a problem getting something to work or want to know why I setup something in a certain way? Ping me on Twitter [@mmistakes](http://twitter.com/mmistakes) or [file a GitHub Issue](https://github.com/mmistakes/so-simple-theme/issues/new). Having a problem getting something to work or want to know why I setup something in a certain way? Ping me on Twitter [@mmistakes](http://twitter.com/mmistakes) or [file a GitHub Issue](https://github.com/mmistakes/so-simple-theme/issues/new).

28
post.thor Normal file
View file

@ -0,0 +1,28 @@
require 'active_support/all'
class Post < Thor
include Thor::Actions
desc "new", "Creates a new post"
argument :title
def new
date = Time.now.strftime("%Y-%m-%d")
create_file "_posts/#{(date + '-' + title).parameterize}.md", <<-eos
---
layout: post
title: #{title}
description: A description
modified: #{date}
category: articles
tags: []
image:
credit:
creditlink:
feature:
comments: true
---
eos
end
end