From 535d78de7d25045341d0501ac6fbb244a09e5a5c Mon Sep 17 00:00:00 2001 From: Thomas Jack Date: Mon, 8 Jun 2009 19:26:03 -0500 Subject: [PATCH 1/2] change features and tests to make sure categories in urls follow the order specified by directory layout or in yaml --- features/post_data.feature | 14 +++++++------- test/test_post.rb | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/features/post_data.feature b/features/post_data.feature index 87f5d851117..9cd9d5074cb 100644 --- a/features/post_data.feature +++ b/features/post_data.feature @@ -82,17 +82,17 @@ Feature: Post data And I should see "Post tags: twist" in "_site/2009/05/18/star-wars.html" Scenario: Use post.categories variable when categories are in folders - Given I have a movies directory - And I have a movies/scifi directory - And I have a movies/scifi/_posts directory + Given I have a scifi directory + And I have a scifi/movies directory + And I have a scifi/movies/_posts directory And I have a _layouts directory - And I have the following post in "movies/scifi": + And I have the following post in "scifi/movies": | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}" When I run jekyll Then the _site directory should exist - And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" + And I should see "Post categories: scifi and movies" in "_site/scifi/movies/2009/03/27/star-wars.html" Scenario: Use post.categories variable when category is in YAML Given I have a _posts directory @@ -110,11 +110,11 @@ Feature: Post data And I have a _layouts directory And I have the following post: | title | date | layout | categories | content | - | Star Wars | 3/27/2009 | simple | ['movies', 'scifi'] | Luke, I am your father. | + | Star Wars | 3/27/2009 | simple | ['scifi', 'movies'] | Luke, I am your father. | And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}" When I run jekyll Then the _site directory should exist - And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" + And I should see "Post categories: scifi and movies" in "_site/scifi/movies/2009/03/27/star-wars.html" Scenario: Disable a post from being published Given I have a _posts directory diff --git a/test/test_post.rb b/test/test_post.rb index b6585cc0a4c..491a42a0765 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -105,7 +105,7 @@ def do_render(post) should "process the url correctly" do assert_equal "/:categories/:year/:month/:day/:title.html", @post.template - assert_equal "/beer/food/2008/10/19/foo-bar.html", @post.url + assert_equal "/food/beer/2008/10/19/foo-bar.html", @post.url end end From 0a1e3cd2508c797d7b8d1038636a6e7111e5cd3d Mon Sep 17 00:00:00 2001 From: Thomas Jack Date: Mon, 8 Jun 2009 19:26:29 -0500 Subject: [PATCH 2/2] stop sorting post categories so they show up in order in the url --- lib/jekyll/post.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index d164fb5e5c7..4e2fc9e51cb 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -132,7 +132,7 @@ def url "month" => date.strftime("%m"), "day" => date.strftime("%d"), "title" => CGI.escape(slug), - "categories" => categories.sort.join('/') + "categories" => categories.join('/') }.inject(template) { |result, token| result.gsub(/:#{token.first}/, token.last) }.gsub(/\/\//, "/")