Fixing permalink support

This commit is contained in:
Luismi Cavalle 2009-01-05 00:35:59 +01:00
parent 94c06d0100
commit 15c5a78a47
2 changed files with 11 additions and 3 deletions

View File

@ -66,7 +66,7 @@ module Jekyll
# Returns <String> # Returns <String>
def dir def dir
if permalink if permalink
permalink.to_s.split("/")[0..-2].join("/") permalink.to_s.split("/")[0..-2].join("/") + '/'
else else
prefix = self.categories.empty? ? '' : '/' + self.categories.join('/') prefix = self.categories.empty? ? '' : '/' + self.categories.join('/')
prefix + date.strftime("/%Y/%m/%d/") prefix + date.strftime("/%Y/%m/%d/")
@ -87,7 +87,7 @@ module Jekyll
# #
# Returns <String> # Returns <String>
def url def url
self.dir + self.slug + ".html" permalink || self.dir + self.slug + ".html"
end end
# The UID for this post (useful in feeds) # The UID for this post (useful in feeds)

View File

@ -43,7 +43,15 @@ class TestPost < Test::Unit::TestCase
p.process("2008-12-03-permalinked-post.textile") 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") 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 end
def test_read_yaml def test_read_yaml