lib/nanoc/creator.rb in nanoc-1.5 vs lib/nanoc/creator.rb in nanoc-1.6
- old
+ new
@@ -4,11 +4,10 @@
def create_site(a_sitename)
ensure_nonexistant(a_sitename)
FileManager.create_dir a_sitename do
- FileManager.create_dir 'assets'
FileManager.create_dir 'output'
FileManager.create_file 'config.yaml' do
"output_dir: \"output\"\n"
end
@@ -18,11 +17,11 @@
"# Other metafiles can override the contents of this one.\n" +
"\n" +
"# Built-in\n" +
"layout: \"default\"\n" +
"filters: []\n" +
- "filename: \"index\"\n" +
+ "filename: \"index\"\n" +
"extension: \"html\"\n" +
"\n" +
"# Custom\n"
end
@@ -99,23 +98,37 @@
Nanoc.ensure_in_site
ensure_nonexistant(File.join(['content', a_pagename]))
# Sanitize page name
if a_pagename =~ /^[\/\.]+/
- $stderr.puts 'ERROR: page name starts with dots and/or slashes, aborting' unless $quiet == true
+ $stderr.puts 'ERROR: page name starts with dots and/or slashes, aborting' unless $quiet
return
end
# Read template
template = a_params[:template] || 'default'
begin
template_meta = File.read("templates/#{template}/meta.yaml")
+
+ # Find all files
template_content_filenames = Dir["templates/#{template}/#{template}.*"]
+
+ # Find all index.* files (used to be a fallback for nanoc 1.0, kinda...)
template_content_filenames += Dir["templates/#{template}/index.*"]
+
+ # Reject backups
+ template_content_filenames.reject! { |f| f =~ /~$/ }
+
+ # Make sure there is only one content file
+ template_content_filenames.ensure_single('template files', template)
+
+ # Get the first (and only one)
template_content_filename = template_content_filenames[0]
+
template_index = File.read(template_content_filename)
- rescue
- $stderr.puts 'ERROR: no such template' unless $quiet == true
+ rescue => e
+ puts e.inspect
+ $stderr.puts 'ERROR: no such template' unless $quiet
exit
end
template_meta = template_meta.eruby
template_index = template_index.eruby