Move post scaffold content to a separate method.

This commit is contained in:
Parker Moore 2013-01-27 23:23:53 +01:00
parent a68b67c65e
commit bf78fe9b75
1 changed files with 12 additions and 9 deletions

View File

@ -10,18 +10,21 @@ module Jekyll
FileUtils.mkdir_p path FileUtils.mkdir_p path
FileUtils.cp_r Dir["#{template_site}/*"], path FileUtils.cp_r Dir["#{template_site}/*"], path
File.open(File.expand_path(self.initialized_post_name, path), "w") do |f| File.open(File.expand_path(self.initialized_post_name, path), "w") do |f|
content = [ f.write(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"
]
f.write(content.join("#{$/*2}"))
end end
puts "New jekyll site installed in #{path}." puts "New jekyll site installed in #{path}."
end 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 # Internal: Gets the filename of the sample post to be created
# #
# Returns the filename of the sample post, as a String # Returns the filename of the sample post, as a String