From fc09ac4862cff934f9b7d3a7ff2d1f1c05cb7191 Mon Sep 17 00:00:00 2001 From: Dave Cole Date: Thu, 25 Apr 2013 13:58:05 -0400 Subject: [PATCH 1/3] Use post's directory path when matching for the post_url tag --- lib/jekyll/tags/post_url.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index dd02d3bf..6814c3ca 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -6,13 +6,15 @@ module Jekyll attr_accessor :date, :slug def initialize(name) - who, cares, date, slug = *name.match(MATCHER) - @slug = slug + all, path, date, slug = *name.sub(/^\//, "").match(MATCHER) + @slug = path ? path + slug : slug @date = Time.parse(date) end def ==(other) - slug == other.slug && + path = other.name.split("/")[0...-1].join("/") + otherslug = path != "" ? path + '/' + other.slug : other.slug + slug == otherslug && date.year == other.date.year && date.month == other.date.month && date.day == other.date.day From 805f378586341ff13df6f8d7051e08d737e44cc5 Mon Sep 17 00:00:00 2001 From: Dave Cole Date: Mon, 29 Apr 2013 17:48:10 -0400 Subject: [PATCH 2/3] Add test for nested post_url --- .../_posts/es/2008-11-21-nested.textile | 8 +++++++ test/test_generated_site.rb | 2 +- test/test_tags.rb | 21 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/source/_posts/es/2008-11-21-nested.textile diff --git a/test/source/_posts/es/2008-11-21-nested.textile b/test/source/_posts/es/2008-11-21-nested.textile new file mode 100644 index 00000000..6140a46e --- /dev/null +++ b/test/source/_posts/es/2008-11-21-nested.textile @@ -0,0 +1,8 @@ +--- +layout: default +title: Nested +--- + +url: {{ page.url }} +date: {{ page.date }} +id: {{ page.id }} \ No newline at end of file diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index ca676861..85a0a2c7 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase end should "ensure post count is as expected" do - assert_equal 32, @site.posts.size + assert_equal 33, @site.posts.size end should "insert site.posts into the index" do diff --git a/test/test_tags.rb b/test/test_tags.rb index 0ba6b647..09dd1003 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -204,6 +204,27 @@ CONTENT end end + context "simple page with nested post linking" do + setup do + content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) + end + + should "not cause an error" do + assert_no_match /markdown\-html\-error/, @result + end + + should "have the url to the \"complex\" post from 2008-11-21" do + assert_match %r{/2008/11/21/nested/}, @result + end + end + context "gist tag" do context "simple" do setup do From b1cf3d5dd5bec20fd5bb4167df4f7b6c4d34cdec Mon Sep 17 00:00:00 2001 From: Dave Cole Date: Tue, 30 Apr 2013 12:46:31 -0400 Subject: [PATCH 3/3] Adjust expected post count for tests. --- test/test_site.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_site.rb b/test/test_site.rb index e8eb104d..f59c0ea9 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -162,7 +162,7 @@ class TestSite < Test::Unit::TestCase @site.read_posts('') posts = Dir[source_dir('_posts', '*')] posts.delete_if { |post| File.directory?(post) } - assert_equal posts.size - 1, @site.posts.size + assert_equal posts.size, @site.posts.size end should "deploy payload" do @@ -173,7 +173,7 @@ class TestSite < Test::Unit::TestCase posts.delete_if { |post| File.directory?(post) } categories = %w(bar baz category foo z_category publish_test win).sort - assert_equal posts.size, @site.posts.size + assert_equal posts.size + 1, @site.posts.size assert_equal categories, @site.categories.keys.sort assert_equal 4, @site.categories['foo'].size end