From 15c5a78a47967667a146d1ecdcc75ccedbaaef71 Mon Sep 17 00:00:00 2001 From: Luismi Cavalle Date: Mon, 5 Jan 2009 00:35:59 +0100 Subject: [PATCH] Fixing permalink support --- lib/jekyll/post.rb | 4 ++-- test/test_post.rb | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 890cae8d..ae729a54 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -66,7 +66,7 @@ module Jekyll # Returns def dir if permalink - permalink.to_s.split("/")[0..-2].join("/") + permalink.to_s.split("/")[0..-2].join("/") + '/' else prefix = self.categories.empty? ? '' : '/' + self.categories.join('/') prefix + date.strftime("/%Y/%m/%d/") @@ -87,7 +87,7 @@ module Jekyll # # Returns def url - self.dir + self.slug + ".html" + permalink || self.dir + self.slug + ".html" end # The UID for this post (useful in feeds) diff --git a/test/test_post.rb b/test/test_post.rb index 01e1dd8b..9ff73bae 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -43,7 +43,15 @@ class TestPost < Test::Unit::TestCase p.process("2008-12-03-permalinked-post.textile") p.read_yaml(File.join(File.dirname(__FILE__), *%w[source _posts]), "2008-12-03-permalinked-post.textile") - assert_equal "my_category", p.dir + assert_equal "my_category/", p.dir + end + + def test_url_respects_permalink + p = Post.allocate + p.process("2008-12-03-permalinked-post.textile") + p.read_yaml(File.join(File.dirname(__FILE__), *%w[source _posts]), "2008-12-03-permalinked-post.textile") + + assert_equal "my_category/permalinked-post", p.url end def test_read_yaml