From bf78fe9b754109a96b709dccf5b2790bea1c9498 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 27 Jan 2013 23:23:53 +0100 Subject: [PATCH] Move post scaffold content to a separate method. --- lib/jekyll/commands/new.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index 6f9f9da8..def9a380 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -10,18 +10,21 @@ module Jekyll FileUtils.mkdir_p path FileUtils.cp_r Dir["#{template_site}/*"], path File.open(File.expand_path(self.initialized_post_name, path), "w") do |f| - content = [ - { "layout" => "post", "title" => "Welcome to Jekyll!", "date" => Time.now.strftime('%Y-%m-%d %H:%M:%S'), "categories" => %w(jekyll update) }.to_yaml + "---", - "You'll find this post in your `_posts` directory - edit this post and re-build (or run with the `-w` switch) to see your changes!", - "To add new posts, simply add a file in the `_posts` directory that follows the convention: YYYY-MM-DD-name-of-post.ext.", - "Check out the [Jeyll docs][jekyll] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll's GitHub repo][jekyll-gh].", - "[jekyll-gh]: https://github.com/mojombo/github\n[jekyll]: http://jekyllrb.com" - ] - f.write(content.join("#{$/*2}")) + f.write(self.scaffold_post_content) end puts "New jekyll site installed in #{path}." end - + + def self.scaffold_post_content + [ + { "layout" => "post", "title" => "Welcome to Jekyll!", "date" => Time.now.strftime('%Y-%m-%d %H:%M:%S'), "categories" => %w(jekyll update) }.to_yaml + "---", + "You'll find this post in your `_posts` directory - edit this post and re-build (or run with the `-w` switch) to see your changes!", + "To add new posts, simply add a file in the `_posts` directory that follows the convention: YYYY-MM-DD-name-of-post.ext.", + "Check out the [Jeyll docs][jekyll] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll's GitHub repo][jekyll-gh].", + "[jekyll-gh]: https://github.com/mojombo/github\n[jekyll]: http://jekyllrb.com" + ].join("#{$/*2}") + end + # Internal: Gets the filename of the sample post to be created # # Returns the filename of the sample post, as a String