Permalink
Browse files

Added option to specify time when creating posts

  • Loading branch information...
1 parent 12e4175 commit 02e2f861e799310994e5dfd42df479a443d9e963 Andrea Schiavini committed with plusjade Feb 8, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 Rakefile
View
@@ -39,13 +39,14 @@ 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 FileTest.directory?(CONFIG['posts'])
title = ENV["title"] || "new-post"
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
- filename = File.join(CONFIG['posts'], "#{Time.now.strftime('%Y-%m-%d')}-#{slug}.#{CONFIG['post_ext']}")
+ date = ENV['date'] || Time.now.strftime('%Y-%m-%d')
+ 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'
end

0 comments on commit 02e2f86

Please sign in to comment.