From d0ac4915cb05e4b306ef6c6dadb581157d499629 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Wed, 6 Aug 2014 14:20:03 -0700 Subject: [PATCH 1/3] Reverts 18c033dc5c00b2ce0b3528cb310bf3988377e39f The merge that is reverted assigned categories to posts based on the subfolders in the _posts directory and was merged under the understanding that it was fixing a bug. Subfolders in the _posts directory should not assign metadata information to posts at this point in time and was not a bug. --- lib/jekyll/post.rb | 2 -- test/test_post.rb | 17 +---------------- test/test_site.rb | 2 +- test/test_tags.rb | 4 ++-- 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 49839f6b..b13deff8 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -159,8 +159,6 @@ module Jekyll # Returns nothing. def process(name) m, cats, date, slug, ext = *name.match(MATCHER) - self.categories ||= [] - self.categories += (cats || '').downcase.split('/') self.date = Utils.parse_date(date, "Post '#{relative_path}' does not have a valid date in the filename.") self.slug = slug self.ext = ext diff --git a/test/test_post.rb b/test/test_post.rb index bf9b741c..28c6366b 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -76,21 +76,6 @@ class TestPost < Test::Unit::TestCase assert_equal "/2008/09/09/foo-bar", @post.id end - should "keep categories" do - post = Post.allocate - post.site = @site - post.process("cat1/2008-09-09-foo-bar.textile") - assert_equal 1, post.categories.size - assert_equal "cat1", post.categories[0] - - post = Post.allocate - post.site = @site - post.process("cat2/CAT3/2008-09-09-foo-bar.textile") - assert_equal 2, post.categories.size - assert_equal "cat2", post.categories[0] - assert_equal "cat3", post.categories[1] - end - should "create url based on date and title" do @post.categories = [] @post.process(@fake_file) @@ -630,7 +615,7 @@ class TestPost < Test::Unit::TestCase should "generate categories and topics" do post = Post.new(@site, File.join(File.dirname(__FILE__), *%w[source]), 'foo', 'bar/2008-12-12-topical-post.textile') - assert_equal ['foo', 'bar'], post.categories + assert_equal ['foo'], post.categories end end diff --git a/test/test_site.rb b/test/test_site.rb index 0ca90937..a343b1c9 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -212,7 +212,7 @@ class TestSite < Test::Unit::TestCase posts = Dir[source_dir("**", "_posts", "**", "*")] posts.delete_if { |post| File.directory?(post) && !Post.valid?(post) } - categories = %w(2013 bar baz category es foo z_category publish_test win).sort + categories = %w(2013 bar baz category foo z_category publish_test win).sort assert_equal posts.size - @num_invalid_posts, @site.posts.size assert_equal categories, @site.categories.keys.sort diff --git a/test/test_tags.rb b/test/test_tags.rb index 815f14d5..12402c7f 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -275,8 +275,8 @@ CONTENT end should "have the url to the \"nested\" post from 2008-11-21" do - assert_match %r{3\s/es/2008/11/21/nested/}, @result - assert_match %r{4\s/es/2008/11/21/nested/}, @result + assert_match %r{3\s/2008/11/21/nested/}, @result + assert_match %r{4\s/2008/11/21/nested/}, @result end end From f29884593b41666066eb1d38f0833c1d185e544a Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Wed, 6 Aug 2014 16:05:53 -0700 Subject: [PATCH 2/3] Reverted deleted test and modified ensure subdirs are ignored. --- test/test_post.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/test_post.rb b/test/test_post.rb index 28c6366b..ff8953d5 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -76,6 +76,19 @@ class TestPost < Test::Unit::TestCase assert_equal "/2008/09/09/foo-bar", @post.id end + should "ignore subfolders" do + post = Post.allocate + post.site = @site + post.process("cat1/2008-09-09-foo-bar.textile") + assert_equal 0, post.categories.size + + post = Post.allocate + post.site = @site + post.process("cat2/CAT3/2008-09-09-foo-bar.textile") + assert_equal 0, post.categories.size + + end + should "create url based on date and title" do @post.categories = [] @post.process(@fake_file) From 311f3be63bdd423190a33bc77530b6d2a0e2c680 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Wed, 6 Aug 2014 16:25:16 -0700 Subject: [PATCH 3/3] Fixed ignore subir test. --- test/test_post.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/test_post.rb b/test/test_post.rb index ff8953d5..98a3ff4b 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -78,14 +78,19 @@ class TestPost < Test::Unit::TestCase should "ignore subfolders" do post = Post.allocate + post.categories = ['foo'] post.site = @site post.process("cat1/2008-09-09-foo-bar.textile") - assert_equal 0, post.categories.size + assert_equal 1, post.categories.size + assert_equal "foo", post.categories[0] post = Post.allocate + post.categories = ['foo', 'bar'] post.site = @site post.process("cat2/CAT3/2008-09-09-foo-bar.textile") - assert_equal 0, post.categories.size + assert_equal 2, post.categories.size + assert_equal "foo", post.categories[0] + assert_equal "bar", post.categories[1] end