From 02676572dd3455414cf10a2c586932adf7b0f539 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sat, 28 Jun 2014 16:51:19 -0400 Subject: [PATCH 1/3] Allow dots in collection labels. --- lib/jekyll/collection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index 03474582..97371ac6 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -105,7 +105,7 @@ module Jekyll # # Returns a sanitized version of the label. def sanitize_label(label) - label.gsub(/[^a-z0-9_\-]/i, '') + label.gsub(/[^a-z0-9_\-\.]/i, '') end # Produce a representation of this Collection for use in Liquid. From 5f7a3f2b69ea355cf862b40377fae6bc3d6265a8 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sat, 28 Jun 2014 16:51:30 -0400 Subject: [PATCH 2/3] Filter out directories from entries in the collection --- lib/jekyll/collection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index 97371ac6..8db6c54c 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -52,7 +52,7 @@ module Jekyll def filtered_entries return Array.new unless exists? Dir.chdir(directory) do - entry_filter.filter(entries) + entry_filter.filter(entries).reject { |f| File.directory?(f) } end end From 0b9eb3c11129a7632069f97ad9f19f4bc02095a1 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sat, 28 Jun 2014 16:51:44 -0400 Subject: [PATCH 3/3] Ensure collections with dots work. --- test/source/_with.dots/all.dots/2.4.0.md | 5 ++++ test/source/_with.dots/file.with.dots.md | 0 test/test_collections.rb | 33 +++++++++++++++++++++--- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 test/source/_with.dots/all.dots/2.4.0.md create mode 100644 test/source/_with.dots/file.with.dots.md diff --git a/test/source/_with.dots/all.dots/2.4.0.md b/test/source/_with.dots/all.dots/2.4.0.md new file mode 100644 index 00000000..74d96bb1 --- /dev/null +++ b/test/source/_with.dots/all.dots/2.4.0.md @@ -0,0 +1,5 @@ +--- +title: v2.4.0 +--- + +v2.4.0 \ No newline at end of file diff --git a/test/source/_with.dots/file.with.dots.md b/test/source/_with.dots/file.with.dots.md new file mode 100644 index 00000000..e69de29b diff --git a/test/test_collections.rb b/test/test_collections.rb index 6cdb3184..97b891ef 100644 --- a/test/test_collections.rb +++ b/test/test_collections.rb @@ -17,15 +17,15 @@ class TestCollections < Test::Unit::TestCase end should "sanitize the label name" do - assert_equal @collection.label, "etcpassword" + assert_equal @collection.label, "....etcpassword" end should "have a sanitized relative path name" do - assert_equal @collection.relative_directory, "_etcpassword" + assert_equal @collection.relative_directory, "_....etcpassword" end should "have a sanitized full path" do - assert_equal @collection.directory, source_dir("_etcpassword") + assert_equal @collection.directory, source_dir("_....etcpassword") end end @@ -194,4 +194,31 @@ class TestCollections < Test::Unit::TestCase end end + context "with dots in the filenames" do + setup do + @site = fixture_site({ + "collections" => ["with.dots"], + "safe" => true + }) + @site.process + @collection = @site.collections["with.dots"] + end + + should "exist" do + assert_not_nil @collection + end + + should "contain one document" do + assert_equal 2, @collection.docs.size + end + + should "allow dots in the filename" do + assert_equal "_with.dots", @collection.relative_directory + end + + should "read document in subfolders with dots" do + assert @collection.docs.any? { |d| d.path.include?("all.dots") } + end + end + end