mirror of
https://github.com/moparisthebest/www.moparscape.org
synced 2024-12-25 00:48:49 -05:00
added a rake task for creating a new post
This commit is contained in:
parent
af719fb4dd
commit
a6262dcbff
12
Rakefile
12
Rakefile
@ -35,6 +35,18 @@ task :default => [:generate_site, :generate_style] do
|
|||||||
puts ">>> Site Generating Complete! <<<\n\n"
|
puts ">>> Site Generating Complete! <<<\n\n"
|
||||||
end
|
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"
|
desc "list tasks"
|
||||||
task :list do
|
task :list do
|
||||||
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).to_sentence}"
|
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).to_sentence}"
|
||||||
|
Loading…
Reference in New Issue
Block a user