From a6262dcbff3901135f0941e1f5f03be0db196874 Mon Sep 17 00:00:00 2001 From: B Mathis Date: Mon, 7 Dec 2009 10:55:13 -0600 Subject: added a rake task for creating a new post --- Rakefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Rakefile b/Rakefile index 15c82b08..6998deaa 100644 --- a/Rakefile +++ b/Rakefile @@ -35,6 +35,18 @@ task :default => [:generate_site, :generate_style] do puts ">>> Site Generating Complete! <<<\n\n" end +# usage rake post[my-new-post] or rake post['my new post'] or rake post (defaults to "new-post") +desc "Begin a new post in #{source}/_posts" +task :post, :filename do |t, args| + args.with_defaults(:filename => 'new-post') + #system "touch #{source}/_posts/#{Time.now.strftime('%Y-%m-%d_%H-%M')}-#{args.filename}.markdown" + open("#{source}/_posts/#{Time.now.strftime('%Y-%m-%d_%H-%M')}-#{args.filename.gsub(/[ _]/, '-')}.markdown", 'w') do |post| + post.puts "---" + post.puts "title: \"#{args.filename.gsub(/[-_]/, ' ').titlecase}\"" + post.puts "---" + end +end + desc "list tasks" task :list do puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).to_sentence}" -- cgit v1.2.1