diff --git a/lib/jekyll.rb b/lib/jekyll.rb index a0a60242..3ea79215 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -88,7 +88,9 @@ module Jekyll def configuration(override) config = Configuration[Configuration::DEFAULTS] override = Configuration[override].stringify_keys - config = config.read_config_files(config.config_files(override)) + unless override.delete('skip_config_files') + config = config.read_config_files(config.config_files(override)) + end # Merge DEFAULTS < _config.yml < override config = Utils.deep_merge_hashes(config, override).stringify_keys diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index 84e207f8..76374d2f 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -36,6 +36,7 @@ module Jekyll def read filtered_entries.each do |file_path| full_path = collection_dir(file_path) + next if File.directory?(full_path) if Utils.has_yaml_header? full_path doc = Jekyll::Document.new(full_path, { site: site, collection: self }) doc.read @@ -86,7 +87,8 @@ module Jekyll @directory ||= site.in_source_dir(relative_directory) end - # The full path to the directory containing the collection. + # The full path to the directory containing the collection, with + # optional subpaths. # # *files - (optional) any other path pieces relative to the # directory to append to the path diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 9cb4264e..0ab0cb72 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -159,7 +159,8 @@ module Jekyll # # Returns the full path to the output file of this document. def destination(base_directory) - path = site.in_dest_dir(base_directory, url) + dest = site.in_dest_dir(base_directory) + path = Jekyll.sanitized_path(dest, url) path = File.join(path, "index.html") if url =~ /\/$/ path end diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 98f730bf..0cd3cf0a 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -140,7 +140,8 @@ module Jekyll # # Returns the destination file path String. def destination(dest) - path = site.in_dest_dir(dest, URL.unescape_path(url)) + dest = site.in_dest_dir(dest) + path = Jekyll.sanitized_path(dest, URL.unescape_path(url)) path = File.join(path, "index.html") if url =~ /\/$/ path end diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index d89034ce..36536173 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -268,7 +268,8 @@ module Jekyll # Returns destination file path String. def destination(dest) # The url needs to be unescaped in order to preserve the correct filename - path = site.in_dest_dir(dest, URL.unescape_path(url)) + dest = site.in_dest_dir(dest) + path = Jekyll.sanitized_path(dest, URL.unescape_path(url)) path = File.join(path, "index.html") if path[/\.html$/].nil? path end diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 0fc5130c..42935638 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -3,12 +3,12 @@ require 'csv' module Jekyll class Site - attr_reader :source, :dest - attr_accessor :config, :layouts, :posts, :pages, :static_files, - :exclude, :include, :lsi, :highlighter, - :permalink_style, :time, :future, :unpublished, :safe, :plugins, :limit_posts, - :show_drafts, :keep_files, :baseurl, :data, :file_read_opts, :gems, - :plugin_manager + attr_reader :source, :dest, :config + attr_accessor :layouts, :posts, :pages, :static_files, + :exclude, :include, :lsi, :highlighter, :permalink_style, + :time, :future, :unpublished, :safe, :plugins, :limit_posts, + :show_drafts, :keep_files, :baseurl, :data, :file_read_opts, + :gems, :plugin_manager attr_accessor :converters, :generators @@ -16,7 +16,7 @@ module Jekyll # # config - A Hash containing site configuration details. def initialize(config) - self.config = config.clone + @config = config.clone %w[safe lsi highlighter baseurl exclude include future unpublished show_drafts limit_posts keep_files gems].each do |opt| diff --git a/test/test_document.rb b/test/test_document.rb index 3464cd2b..412ab0ff 100644 --- a/test/test_document.rb +++ b/test/test_document.rb @@ -10,9 +10,14 @@ class TestDocument < Test::Unit::TestCase "destination" => dest_dir })) @site.process + p @site.collections["methods"] @document = @site.collections["methods"].docs.first end + should "exist" do + assert !@document.nil? + end + should "know its relative path" do assert_equal "_methods/configuration.md", @document.relative_path end @@ -220,6 +225,7 @@ class TestDocument < Test::Unit::TestCase "destination" => dest_dir })) @site.process + p @site.collections["slides"] @document = @site.collections["slides"].docs[3] @document_without_title = @site.collections["slides"].docs[4] end diff --git a/test/test_post.rb b/test/test_post.rb index 48e2eb03..206060d8 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -15,8 +15,11 @@ class TestPost < Test::Unit::TestCase context "A Post" do setup do clear_dest - stub(Jekyll).configuration { Jekyll::Configuration::DEFAULTS } - @site = Site.new(Jekyll.configuration) + @site = Site.new(Jekyll.configuration({ + "skip_config_files" => true, + "source" => source_dir, + "destination" => dest_dir + })) end should "ensure valid posts are valid" do @@ -145,7 +148,7 @@ class TestPost < Test::Unit::TestCase do_render(post) post.write(dest_dir) - assert !File.exist?(unexpected) + assert !File.exist?(unexpected), "../../../baddie.html should not exist." assert File.exist?(File.expand_path("baddie.html", dest_dir)) end @@ -606,7 +609,7 @@ class TestPost < Test::Unit::TestCase should "include templates" do post = setup_post("2008-12-13-include.markdown") - post.site.source = File.join(File.dirname(__FILE__), 'source') + post.site.instance_variable_set(:@source, File.join(File.dirname(__FILE__), 'source')) do_render(post) assert_equal "<<<
Tom Preston-Werner\ngithub.com/mojombo
\n\nThis is cool
\n >>>", post.output