From 4be5dfdb9a5bcc2befaa057feb13988f909768ef Mon Sep 17 00:00:00 2001 From: Daniel Grieve Date: Wed, 13 Mar 2013 21:27:41 +0000 Subject: [PATCH] fix copying of site template files --- jekyll.gemspec | 2 +- lib/jekyll/commands/new.rb | 16 ++++++---------- test/test_new_command.rb | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/jekyll.gemspec b/jekyll.gemspec index 8291d9ae..0ebd7f67 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -113,7 +113,7 @@ Gem::Specification.new do |s| lib/site_template/_config.yml lib/site_template/_layouts/default.html lib/site_template/_layouts/post.html - lib/site_template/_posts/0000-00-00-sample_post.markdown.erb + lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb lib/site_template/css/screen.css lib/site_template/css/syntax.css lib/site_template/images/.gitkeep diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index 103a5950..e650dc52 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -9,16 +9,16 @@ module Jekyll new_blog_path = File.expand_path(args.join(" "), Dir.pwd) FileUtils.mkdir_p new_blog_path - create_sample_files! new_blog_path + create_sample_files new_blog_path File.open(File.expand_path(self.initialized_post_name, new_blog_path), "w") do |f| - f.write(self.scaffold_post_content(template_site)) + f.write(self.scaffold_post_content(site_template)) end puts "New jekyll site installed in #{new_blog_path}." end def self.scaffold_post_content(template_site) - ERB.new(File.read(File.expand_path(scaffold_path, template_site))).result + ERB.new(File.read(File.expand_path(scaffold_path, site_template))).result end # Internal: Gets the filename of the sample post to be created @@ -29,16 +29,12 @@ module Jekyll end private - def self.create_sample_files!(path) - FileUtils.cp_r sample_files, path + def self.create_sample_files(path) + FileUtils.cp_r site_template + '/.', path FileUtils.rm File.expand_path(scaffold_path, path) end - def self.sample_files - Dir.glob("#{template_site}/**/*") - end - - def self.template_site + def self.site_template File.expand_path("../../site_template", File.dirname(__FILE__)) end diff --git a/test/test_new_command.rb b/test/test_new_command.rb index 739fcb13..bc9e6585 100644 --- a/test/test_new_command.rb +++ b/test/test_new_command.rb @@ -43,7 +43,7 @@ class TestNewCommand < Test::Unit::TestCase capture_stdout { Jekyll::Commands::New.process(@args) } new_site_files = dir_contents(@full_path).reject do |f| - File.extname(f) == '.erb' + File.extname(f) == '.markdown' end assert_same_elements static_template_files, new_site_files