Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fix for the error on post creation if date was not specified. #56

merged 1 commit into from

2 participants


The current implementation of the optional date parameter for posts fails on master if the date is not provided.
This fixes that, whilst still providing the error if an invalid date is specified.

@plusjade plusjade referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@plusjade plusjade merged commit 804723b into plusjade:jb-development

This is preferable since I did want to verify the Date if it was provided rather than just reverting to today. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 2 deletions.
  1. +8 −2 Rakefile
10 Rakefile
@@ -39,13 +39,19 @@ module JB
end #Path
end #JB
-# Usage: rake post title="A Title"
+# Usage: rake post title="A Title" [date="2012-02-09"]
desc "Begin a new post in #{CONFIG['posts']}"
task :post do
abort("rake aborted: '#{CONFIG['posts']}' directory not found.") unless['posts'])
title = ENV["title"] || "new-post"
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
- filename = File.join(CONFIG['posts'], "#{'%Y-%m-%d')}-#{slug}.#{CONFIG['post_ext']}")
+ begin
+ date = (ENV['date'] ? Time.parse(ENV['date']) :'%Y-%m-%d')
+ rescue Exception => e
+ puts "Error - date format must be YYYY-MM-DD, please check you typed it correctly!"
+ exit -1
+ end
+ filename = File.join(CONFIG['posts'], "##{date}-#{slug}.#{CONFIG['post_ext']}")
if File.exist?(filename)
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
Something went wrong with that request. Please try again.