Skip to content

Commit

Permalink
Fixing permalink support
Browse files Browse the repository at this point in the history
  • Loading branch information
cavalle committed Jan 4, 2009
1 parent 94c06d0 commit 15c5a78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/jekyll/post.rb
Expand Up @@ -66,7 +66,7 @@ def process(name)
# Returns <String>
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/")
Expand All @@ -87,7 +87,7 @@ def permalink
#
# Returns <String>
def url
self.dir + self.slug + ".html"
permalink || self.dir + self.slug + ".html"
end

# The UID for this post (useful in feeds)
Expand Down
10 changes: 9 additions & 1 deletion test/test_post.rb
Expand Up @@ -43,7 +43,15 @@ def test_dir_respects_permalink
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
Expand Down

0 comments on commit 15c5a78

Please sign in to comment.