File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,14 @@ module JB
3939 end #Path
4040end #JB
4141
42- # Usage: rake post title="A Title"
42+ # Usage: rake post title="A Title" date="2012-02-09"
4343desc "Begin a new post in #{ CONFIG [ 'posts' ] } "
4444task :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
You can’t perform that action at this time.
0 commit comments