Merge pull request #872 from mojombo/downcase-post-cats

Ensure all Post categories are downcase
This commit is contained in:
Parker Moore 2013-03-17 15:59:25 -07:00
commit b83d0a3fa5
2 changed files with 43 additions and 6 deletions

View File

@ -94,6 +94,19 @@ Feature: Post data
Then the _site directory should exist Then the _site directory should exist
And I should see "Post categories: scifi and movies" in "_site/scifi/movies/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 categories are in folders with mixed case
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 "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: {{ page.categories | array_to_sentence_string }}"
When I run jekyll
Then the _site directory should exist
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 Scenario: Use post.categories variable when category is in YAML
Given I have a _posts directory Given I have a _posts directory
And I have a _layouts directory And I have a _layouts directory
@ -105,16 +118,40 @@ Feature: Post data
Then the _site directory should exist Then the _site directory should exist
And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html" And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
Scenario: Use post.categories variable when categories are in YAML Scenario: Use post.categories variable when category is in YAML and is mixed-case
Given I have a _posts directory Given I have a _posts directory
And I have a _layouts directory And I have a _layouts directory
And I have the following post: And I have the following post:
| title | date | layout | categories | content | | title | date | layout | category | content |
| Star Wars | 3/27/2009 | simple | ['scifi', 'movies'] | Luke, I am your father. | | Star Wars | 3/27/2009 | simple | Movies | Luke, I am your father. |
And I have a simple layout that contains "Post category: {{ page.categories }}"
When I run jekyll
Then the _site directory should exist
And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
Scenario: Use post.categories variable when category is in YAML
Given I have a _posts directory
And I have a _layouts directory
And I have the following post:
| title | date | layout | category | content |
| Star Wars | 3/27/2009 | simple | movies | Luke, I am your father. |
And I have a simple layout that contains "Post category: {{ page.categories }}"
When I run jekyll
Then the _site directory should exist
And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
Scenario: Use post.categories variable when categories are in YAML with mixed case
Given I have a _posts directory
And I have a _layouts directory
And I have the following posts:
| title | date | layout | categories | content |
| Star Wars | 3/27/2009 | simple | ['scifi', 'Movies'] | Luke, I am your father. |
| Star Trek | 3/17/2013 | simple | ['SciFi', 'movies'] | Jean Luc, I am your father. |
And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}" And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}"
When I run jekyll When I run jekyll
Then the _site directory should exist Then the _site directory should exist
And I should see "Post categories: scifi and movies" in "_site/scifi/movies/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"
And I should see "Post categories: scifi and movies" in "_site/scifi/movies/2013/03/17/star-trek.html"
Scenario: Disable a post from being published Scenario: Disable a post from being published
Given I have a _posts directory Given I have a _posts directory

View File

@ -36,7 +36,7 @@ module Jekyll
@base = self.containing_dir(source, dir) @base = self.containing_dir(source, dir)
@name = name @name = name
self.categories = dir.split('/').reject { |x| x.empty? } self.categories = dir.downcase.split('/').reject { |x| x.empty? }
self.process(name) self.process(name)
begin begin
self.read_yaml(@base, name) self.read_yaml(@base, name)
@ -60,7 +60,7 @@ module Jekyll
self.tags = self.data.pluralized_array("tag", "tags") self.tags = self.data.pluralized_array("tag", "tags")
if self.categories.empty? if self.categories.empty?
self.categories = self.data.pluralized_array('category', 'categories') self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.downcase}
end end
end end