From 2eacb24dff8e0c2a64ddcb905f1d56c353c7bbbf Mon Sep 17 00:00:00 2001 From: Nerian Date: Wed, 21 Aug 2013 17:43:08 +0200 Subject: [PATCH] Automate post creation --- Gemfile | 4 +++- README.md | 44 +++++++++++++++++++++++++++----------------- post.thor | 28 ++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 18 deletions(-) create mode 100644 post.thor diff --git a/Gemfile b/Gemfile index 8b0d7a2..549ccc3 100644 --- a/Gemfile +++ b/Gemfile @@ -3,4 +3,6 @@ source 'https://rubygems.org' gem 'jekyll' gem 'jekyll-minibundle' gem 'coderay' -gem 'rake' \ No newline at end of file +gem 'rake' +gem 'thor' +gem 'activesupport' \ No newline at end of file diff --git a/README.md b/README.md index d6924c7..3aac2fe 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ Looking for a simple, responsive, theme for your Jekyll powered blog? Well look ## So Simple Theme is all about: * Responsive templates. Looking good on mobile, tablet, and desktop. -* Gracefully degrading in older browsers. Compatible with Internet Explorer 8+ and all modern browsers. -* Minimal embellishments and subtle animations. +* Gracefully degrading in older browsers. Compatible with Internet Explorer 8+ and all modern browsers. +* Minimal embellishments and subtle animations. * Readable typography to make your words shine. * Support for large images to call out your favorite posts. * Simple and clear permalink structure. @@ -54,20 +54,20 @@ owner: avatar: your-photo.jpg email: your@email.com # Social networking links used in footer. Update and remove as you like. - twitter: - facebook: - github: - linkedin: - instagram: - tumblr: + twitter: + facebook: + github: + linkedin: + instagram: + tumblr: # For Google Authorship https://plus.google.com/authorship google_plus: "http://plus.google.com/123123123123132123" # Analytics and webmaster tools stuff goes here -google_analytics: -google_verify: +google_analytics: +google_verify: # https://ssl.bing.com/webmaster/configure/verify/ownership Option 2 content= goes here -bing_verify: +bing_verify: # Links to include in top navigation # For external links add external: true @@ -110,7 +110,7 @@ so-simple-theme/ | ├── js | | ├── main.js //jQuery plugins and settings | | └── vendor //all 3rd party scripts -| └── less +| └── less ├── images //images for posts and pages ├── _config.yml //Site options ├── about.md //about page @@ -160,7 +160,7 @@ links: url: /other-page - title: External Link url: http://mademistakes.com - external: true + external: true ``` #### 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 -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 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 image: @@ -252,8 +252,8 @@ To make things easier I use LESS to build So Simple Theme's stylesheets. If you // -------------------------------------------------- @body-color : #ebebeb; @text-color : #333; -@base-color : #343434; -@comp-color : spin(@base-color, 180); +@base-color : #343434; +@comp-color : spin(@base-color, 180); @border-color : @base-color; @white : #fff; @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? 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). diff --git a/post.thor b/post.thor new file mode 100644 index 0000000..71a5f6a --- /dev/null +++ b/post.thor @@ -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 \ No newline at end of file