Automate post creation

This commit is contained in:
Nerian 2013-08-21 17:43:08 +02:00
parent 0bbc5e4884
commit 2eacb24dff
3 changed files with 58 additions and 18 deletions

View file

@ -3,4 +3,6 @@ source 'https://rubygems.org'
gem 'jekyll' gem 'jekyll'
gem 'jekyll-minibundle' gem 'jekyll-minibundle'
gem 'coderay' gem 'coderay'
gem 'rake' gem 'rake'
gem 'thor'
gem 'activesupport'

View file

@ -5,8 +5,8 @@ Looking for a simple, responsive, theme for your Jekyll powered blog? Well look
## So Simple Theme is all about: ## So Simple Theme is all about:
* Responsive templates. Looking good on mobile, tablet, and desktop. * Responsive templates. Looking good on mobile, tablet, and desktop.
* Gracefully degrading in older browsers. Compatible with Internet Explorer 8+ and all modern browsers. * Gracefully degrading in older browsers. Compatible with Internet Explorer 8+ and all modern browsers.
* Minimal embellishments and subtle animations. * Minimal embellishments and subtle animations.
* Readable typography to make your words shine. * Readable typography to make your words shine.
* Support for large images to call out your favorite posts. * Support for large images to call out your favorite posts.
* Simple and clear permalink structure. * Simple and clear permalink structure.
@ -54,20 +54,20 @@ owner:
avatar: your-photo.jpg avatar: your-photo.jpg
email: your@email.com email: your@email.com
# Social networking links used in footer. Update and remove as you like. # Social networking links used in footer. Update and remove as you like.
twitter: twitter:
facebook: facebook:
github: github:
linkedin: linkedin:
instagram: instagram:
tumblr: tumblr:
# For Google Authorship https://plus.google.com/authorship # For Google Authorship https://plus.google.com/authorship
google_plus: "http://plus.google.com/123123123123132123" google_plus: "http://plus.google.com/123123123123132123"
# Analytics and webmaster tools stuff goes here # Analytics and webmaster tools stuff goes here
google_analytics: google_analytics:
google_verify: google_verify:
# https://ssl.bing.com/webmaster/configure/verify/ownership Option 2 content= goes here # https://ssl.bing.com/webmaster/configure/verify/ownership Option 2 content= goes here
bing_verify: bing_verify:
# Links to include in top navigation # Links to include in top navigation
# For external links add external: true # For external links add external: true
@ -110,7 +110,7 @@ so-simple-theme/
| ├── js | ├── js
| | ├── main.js //jQuery plugins and settings | | ├── main.js //jQuery plugins and settings
| | └── vendor //all 3rd party scripts | | └── vendor //all 3rd party scripts
| └── less | └── less
├── images //images for posts and pages ├── images //images for posts and pages
├── _config.yml //Site options ├── _config.yml //Site options
├── about.md //about page ├── about.md //about page
@ -160,7 +160,7 @@ links:
url: /other-page url: /other-page
- title: External Link - title: External Link
url: http://mademistakes.com url: http://mademistakes.com
external: true external: true
``` ```
#### Other Stuff #### Other Stuff
@ -173,13 +173,13 @@ For the most part you can leave these as is since the author/owner details are p
### Adding Posts and Pages ### Adding Posts and Pages
There are two main content layouts: `post.html` (for posts) and `page.html` (for pages). Both have support for large **feature images** that span the full-width of the screen, and both are meant for text heavy blog posts (or articles). There are two main content layouts: `post.html` (for posts) and `page.html` (for pages). Both have support for large **feature images** that span the full-width of the screen, and both are meant for text heavy blog posts (or articles).
#### Feature Images #### Feature Images
A good rule of thumb is to keep feature images nice and wide so you don't push the body text too far down. An image cropped around around 1024 x 256 pixels will keep file size down with an acceptable resolution for most devices. If you want to serve these images responsively I'd suggest looking at [Picturefill](https://github.com/scottjehl/picturefill) or [Adaptive Images](http://adaptive-images.com/). A good rule of thumb is to keep feature images nice and wide so you don't push the body text too far down. An image cropped around around 1024 x 256 pixels will keep file size down with an acceptable resolution for most devices. If you want to serve these images responsively I'd suggest looking at [Picturefill](https://github.com/scottjehl/picturefill) or [Adaptive Images](http://adaptive-images.com/).
The two layouts make the assumption that the feature images live in the *images* folder. To add a feature image to a post or page just include the filename in the front matter like so. The two layouts make the assumption that the feature images live in the *images* folder. To add a feature image to a post or page just include the filename in the front matter like so.
``` yaml ``` yaml
image: image:
@ -252,8 +252,8 @@ To make things easier I use LESS to build So Simple Theme's stylesheets. If you
// -------------------------------------------------- // --------------------------------------------------
@body-color : #ebebeb; @body-color : #ebebeb;
@text-color : #333; @text-color : #333;
@base-color : #343434; @base-color : #343434;
@comp-color : spin(@base-color, 180); @comp-color : spin(@base-color, 180);
@border-color : @base-color; @border-color : @base-color;
@white : #fff; @white : #fff;
@black : #000; @black : #000;
@ -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