Skip to content

Commit 02e2f86

Browse files
Andrea Schiaviniplusjade
authored andcommitted
Added option to specify time when creating posts
1 parent 12e4175 commit 02e2f86

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Rakefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ module JB
3939
end #Path
4040
end #JB
4141

42-
# Usage: rake post title="A Title"
42+
# Usage: rake post title="A Title" date="2012-02-09"
4343
desc "Begin a new post in #{CONFIG['posts']}"
4444
task :post do
4545
abort("rake aborted: '#{CONFIG['posts']}' directory not found.") unless FileTest.directory?(CONFIG['posts'])
4646
title = ENV["title"] || "new-post"
4747
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
48-
filename = File.join(CONFIG['posts'], "#{Time.now.strftime('%Y-%m-%d')}-#{slug}.#{CONFIG['post_ext']}")
48+
date = ENV['date'] || Time.now.strftime('%Y-%m-%d')
49+
filename = File.join(CONFIG['posts'], "#{date}-#{slug}.#{CONFIG['post_ext']}")
4950
if File.exist?(filename)
5051
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
5152
end

0 commit comments

Comments
 (0)