Refactored per @parkr suggestions. Much cleaner.
This commit is contained in:
parent
eb06cf0d3d
commit
a3d53a74be
|
@ -13,27 +13,26 @@ module Jekyll
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
create_sample_files new_blog_path
|
if options[:blank]
|
||||||
|
create_blank_site new_blog_path
|
||||||
|
else
|
||||||
|
create_sample_files new_blog_path
|
||||||
|
end
|
||||||
|
|
||||||
File.open(File.expand_path(self.initialized_post_name, new_blog_path), "w") do |f|
|
File.open(File.expand_path(self.initialized_post_name, new_blog_path), "w") do |f|
|
||||||
f.write(self.scaffold_post_content(site_template))
|
f.write(self.scaffold_post_content(site_template))
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:blank]
|
|
||||||
file_to_truncate = "#{new_blog_path}/index.html"
|
|
||||||
file_list = [Dir.glob("#{new_blog_path}/**/_layouts/*"),
|
|
||||||
Dir.glob("#{new_blog_path}/**/_posts/*")]
|
|
||||||
|
|
||||||
FileUtils.rm_rf Dir.glob("#{new_blog_path}/**/css")
|
|
||||||
FileUtils.rm Dir.glob("#{new_blog_path}/**/_config.yml")
|
|
||||||
|
|
||||||
FileUtils.rm_rf(file_list)
|
|
||||||
File.truncate(file_to_truncate, 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
puts "New jekyll site installed in #{new_blog_path}."
|
puts "New jekyll site installed in #{new_blog_path}."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.create_blank_site(path)
|
||||||
|
Dir.chdir(path) do
|
||||||
|
FileUtils.mkdir(%w(_layouts _posts))
|
||||||
|
FileUtils.touch("index.html")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.scaffold_post_content(template_site)
|
def self.scaffold_post_content(template_site)
|
||||||
ERB.new(File.read(File.expand_path(scaffold_path, site_template))).result
|
ERB.new(File.read(File.expand_path(scaffold_path, site_template))).result
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue