diff --git a/features/collections.feature b/features/collections.feature index 4f69e8b9..1cdbff4b 100644 --- a/features/collections.feature +++ b/features/collections.feature @@ -9,7 +9,7 @@ Feature: Collections And I have a configuration file with "collections" set to "['methods']" When I run jekyll build Then the _site directory should exist - And I should see "Collections:
Use Jekyll.configuration
to build a full configuration for use w/Jekyll.
Whatever: foo.bar
\nJekyll.sanitized_path
is used to make sure your path is in your source.
Run your generators! default
\nPage without title.
\nRun your generators! default
" in "_site/index.html" + And I should see "Collections:Use Jekyll.configuration
to build a full configuration for use w/Jekyll.
Whatever: foo.bar
\nSigns are nice
\nJekyll.sanitized_path
is used to make sure your path is in your source.
Run your generators! default
\nPage without title.
\nRun your generators! default
" in "_site/index.html" And the "_site/methods/configuration.html" file should not exist Scenario: Rendered collection @@ -70,7 +70,7 @@ Feature: Collections """ When I run jekyll build Then the _site directory should exist - And I should see "Collections: _methods/configuration.md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html" + And I should see "Collections: _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html" Scenario: Collections specified as an hash Given I have an "index.html" page that contains "Collections: {% for method in site.methods %}{{ method.relative_path }} {% endfor %}" @@ -82,7 +82,7 @@ Feature: Collections """ When I run jekyll build Then the _site directory should exist - And I should see "Collections: _methods/configuration.md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html" + And I should see "Collections: _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html" Scenario: All the documents Given I have an "index.html" page that contains "All documents: {% for doc in site.documents %}{{ doc.relative_path }} {% endfor %}" @@ -94,7 +94,7 @@ Feature: Collections """ When I run jekyll build Then the _site directory should exist - And I should see "All documents: _methods/configuration.md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html" + And I should see "All documents: _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html" Scenario: Documents have an output attribute, which is the converted HTML Given I have an "index.html" page that contains "First document's output: {{ site.documents.first.output }}" @@ -130,7 +130,7 @@ Feature: Collections """ When I run jekyll build Then the _site directory should exist - And I should see "1. of 5:Page without title.
" in "_site/index.html" + And I should see "1. of 6:Page without title.
" in "_site/index.html" Scenario: Sort by relative_path Given I have an "index.html" page that contains "Collections: {% assign methods = site.methods | sort: 'relative_path' %}{% for method in methods %}{{ method.title }}, {% endfor %}" @@ -142,4 +142,4 @@ Feature: Collections """ When I run jekyll build Then the _site directory should exist - And I should see "Collections: Jekyll.configuration, Jekyll.sanitized_path, Site#generate, , Site#generate," in "_site/index.html" + And I should see "Collections: Jekyll.configuration, Jekyll.escape, Jekyll.sanitized_path, Site#generate, , Site#generate," in "_site/index.html" diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 31317a46..f01c15e2 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -167,7 +167,7 @@ module Jekyll # Returns the full path to the output file of this document. def destination(base_directory) dest = site.in_dest_dir(base_directory) - path = site.in_dest_dir(dest, url) + path = site.in_dest_dir(dest, URL.unescape_path(url)) path = File.join(path, "index.html") if url =~ /\/$/ path end diff --git a/test/source/_methods/escape-+ #%20[].md b/test/source/_methods/escape-+ #%20[].md new file mode 100644 index 00000000..528317a7 --- /dev/null +++ b/test/source/_methods/escape-+ #%20[].md @@ -0,0 +1,5 @@ +--- +title: "Jekyll.escape" +--- + +Signs are nice diff --git a/test/test_collections.rb b/test/test_collections.rb index 1975e402..e9f324ee 100644 --- a/test/test_collections.rb +++ b/test/test_collections.rb @@ -138,6 +138,7 @@ class TestCollections < Test::Unit::TestCase _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md + _methods/escape-+\ #%20[].md ], doc.relative_path end end diff --git a/test/test_document.rb b/test/test_document.rb index a4543148..7ba17b04 100644 --- a/test/test_document.rb +++ b/test/test_document.rb @@ -275,4 +275,34 @@ class TestDocument < Test::Unit::TestCase end end + context "a document in a collection with non-alphabetic file name" do + setup do + @site = Site.new(Jekyll.configuration({ + "collections" => { + "methods" => { + "output" => true + } + }, + "source" => source_dir, + "destination" => dest_dir + })) + @site.process + @document = @site.collections["methods"].docs.find { |doc| doc.relative_path == "_methods/escape-+ #%20[].md" } + @dest_file = dest_dir("methods/escape-+ #%20[].html") + end + + should "produce the right URL" do + assert_equal "/methods/escape-+%20%23%2520%5B%5D.html", @document.url + end + + should "produce the right destination" do + assert_equal @dest_file, @document.destination(dest_dir) + end + + should "be output in the correct place" do + assert_equal true, File.file?(@dest_file) + end + + end + end