Adding the categories back into the post payload

This commit is contained in:
Nick Quaranto 2009-04-01 07:36:56 -04:00
parent aff6c9c23a
commit 829530be36
4 changed files with 26 additions and 25 deletions

View File

@ -20,7 +20,7 @@ Feature: Embed filters
And I have the following post: And I have the following post:
| title | date | layout | content | | title | date | layout | content |
| Star & Wars | 3/27/2009 | default | These aren't the droids you're looking for. | | Star & Wars | 3/27/2009 | default | These aren't the droids you're looking for. |
And I have a default layout that contains "{{ page.title | xml_escape }}" And I have a default layout that contains "{{ site.posts.first.title | xml_escape }}"
When I run jekyll When I run jekyll
Then the _site directory should exist Then the _site directory should exist
And I should see "Star & Wars" in "_site/2009/03/27/star-wars.html" And I should see "Star & Wars" in "_site/2009/03/27/star-wars.html"
@ -31,7 +31,7 @@ Feature: Embed filters
And I have the following post: And I have the following post:
| title | date | layout | content | | title | date | layout | content |
| Star Wars | 3/27/2009 | default | These aren't the droids you're looking for. | | Star Wars | 3/27/2009 | default | These aren't the droids you're looking for. |
And I have a default layout that contains "{{ content | xml_escape }}" And I have a default layout that contains "{{ site.posts.first.content | xml_escape }}"
When I run jekyll When I run jekyll
Then the _site directory should exist Then the _site directory should exist
And I should see "7" in "_site/2009/03/27/star-wars.html" And I should see "7" in "_site/2009/03/27/star-wars.html"
@ -42,7 +42,7 @@ Feature: Embed filters
And I have the following post: And I have the following post:
| title | date | layout | tags | content | | title | date | layout | tags | content |
| Star Wars | 3/27/2009 | default | [scifi, movies, force] | These aren't the droids you're looking for. | | Star Wars | 3/27/2009 | default | [scifi, movies, force] | These aren't the droids you're looking for. |
And I have a default layout that contains "{{ page.tags | array_to_sentence_string }}" And I have a default layout that contains "{{ site.posts.first.tags | 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 "scifi, movies, and force" in "_site/2009/03/27/star-wars.html" And I should see "scifi, movies, and force" in "_site/2009/03/27/star-wars.html"

View File

@ -9,7 +9,7 @@ Feature: Post data
And I have the following post: And I have the following post:
| title | date | layout | content | | title | date | layout | content |
| Star Wars | 3/27/2009 | simple | Luke, I am your father. | | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
And I have a simple layout that contains "Post title: {{ post.title }}" And I have a simple layout that contains "Post title: {{ site.posts.first.title }}"
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 title: Star Wars" in "_site/2009/03/27/star-wars.html" And I should see "Post title: Star Wars" in "_site/2009/03/27/star-wars.html"
@ -20,7 +20,7 @@ Feature: Post data
And I have the following post: And I have the following post:
| title | date | layout | content | | title | date | layout | content |
| Star Wars | 3/27/2009 | simple | Luke, I am your father. | | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
And I have a simple layout that contains "Post url: {{ post.url }}" And I have a simple layout that contains "Post url: {{ site.posts.first.url }}"
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 url: /2009/03/27/star-wars.html" in "_site/2009/03/27/star-wars.html" And I should see "Post url: /2009/03/27/star-wars.html" in "_site/2009/03/27/star-wars.html"
@ -31,10 +31,10 @@ Feature: Post data
And I have the following post: And I have the following post:
| title | date | layout | content | | title | date | layout | content |
| Star Wars | 3/27/2009 | simple | Luke, I am your father. | | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
And I have a simple layout that contains "Post date: {{ post.date }}" And I have a simple layout that contains "Post date: {{ site.posts.first.date }}"
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 url: 2009-03-27" in "_site/2009/03/27/star-wars.html" And I should see "Post date: Fri Mar 27" in "_site/2009/03/27/star-wars.html"
Scenario: Use post.id variable Scenario: Use post.id variable
Given I have a _posts directory Given I have a _posts directory
@ -42,7 +42,7 @@ Feature: Post data
And I have the following post: And I have the following post:
| title | date | layout | content | | title | date | layout | content |
| Star Wars | 3/27/2009 | simple | Luke, I am your father. | | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
And I have a simple layout that contains "Post id: {{ post.id }}" And I have a simple layout that contains "Post id: {{ site.posts.first.id }}"
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 id: /2009/03/27/star-wars" in "_site/2009/03/27/star-wars.html" And I should see "Post id: /2009/03/27/star-wars" in "_site/2009/03/27/star-wars.html"
@ -53,10 +53,10 @@ Feature: Post data
And I have the following post: And I have the following post:
| title | date | layout | content | | title | date | layout | content |
| Star Wars | 3/27/2009 | simple | Luke, I am your father. | | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
And I have a simple layout that contains "Post content: {{ post.content }}" And I have a simple layout that contains "Post content: {{ site.posts.first.content }}"
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 content: Luke, I am your father." in "_site/2009/03/27/star-wars.html" And I should see "Post content: <p>Luke, I am your father.</p>" in "_site/2009/03/27/star-wars.html"
Scenario: Use post.categories variable when category is in a folder Scenario: Use post.categories variable when category is in a folder
Given I have a movies directory Given I have a movies directory
@ -65,7 +65,7 @@ Feature: Post data
And I have the following post in "movies": And I have the following post in "movies":
| title | date | layout | content | | title | date | layout | content |
| Star Wars | 3/27/2009 | simple | Luke, I am your father. | | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
And I have a simple layout that contains "Post category: {{ post.categories }}" And I have a simple layout that contains "Post category: {{ site.posts.first.categories }}"
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 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"
@ -78,7 +78,7 @@ Feature: Post data
And I have the following post in "movies/scifi": And I have the following post in "movies/scifi":
| title | date | layout | content | | title | date | layout | content |
| Star Wars | 3/27/2009 | simple | Luke, I am your father. | | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
And I have a simple layout that contains "Post categories: {{ post.categories }}" And I have a simple layout that contains "Post categories: {{ site.posts.first.categories }}"
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: movies scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" And I should see "Post categories: movies scifi" in "_site/movies/scifi/2009/03/27/star-wars.html"
@ -89,7 +89,7 @@ Feature: Post data
And I have the following post: And I have the following post:
| title | date | layout | category | content | | title | date | layout | category | content |
| Star Wars | 3/27/2009 | simple | 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: {{ post.categories }}" And I have a simple layout that contains "Post category: {{ site.posts.first.categories }}"
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: movies" in "_site/movies/2009/03/27/star-wars.html" And I should see "Post categories: movies" in "_site/movies/2009/03/27/star-wars.html"
@ -100,7 +100,7 @@ Feature: Post data
And I have the following post: And I have the following post:
| title | date | layout | categories | content | | title | date | layout | categories | content |
| Star Wars | 3/27/2009 | simple | movies, scifi | Luke, I am your father. | | Star Wars | 3/27/2009 | simple | movies, scifi | Luke, I am your father. |
And I have a simple layout that contains "Post categories: {{ post.categories }}" And I have a simple layout that contains "Post categories: {{ site.posts.first.categories }}"
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: movies scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" And I should see "Post categories: movies scifi" in "_site/movies/scifi/2009/03/27/star-wars.html"
@ -112,7 +112,7 @@ Feature: Post data
And I have the following post: And I have the following post:
| title | date | layout | content | | title | date | layout | content |
| Star Wars | 3/27/2009 | simple | Luke, I am your father. | | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
And I have a simple layout that contains "Post topics: {{ post.topics }}" And I have a simple layout that contains "Post topics: {{ site.posts.first.topics }}"
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 topics: movies scifi" in "_site/2009/03/27/star-wars.html" And I should see "Post topics: movies scifi" in "_site/2009/03/27/star-wars.html"
@ -131,7 +131,7 @@ Feature: Post data
And I have the following post: And I have the following post:
| title | date | layout | author | content | | title | date | layout | author | content |
| Star Wars | 3/27/2009 | simple | Darth Vader | Luke, I am your father. | | Star Wars | 3/27/2009 | simple | Darth Vader | Luke, I am your father. |
And I have a simple layout that contains "Post author: {{ post.author }}" And I have a simple layout that contains "Post author: {{ site.posts.first.author }}"
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 author: Darth Vader" in "_site/2009/03/27/star-wars.html" And I should see "Post author: Darth Vader" in "_site/2009/03/27/star-wars.html"

View File

@ -42,19 +42,19 @@ end
Given /^I have the following posts?(?: in "(.*)")?:$/ do |dir, table| Given /^I have the following posts?(?: in "(.*)")?:$/ do |dir, table|
table.hashes.each do |post| table.hashes.each do |post|
date = Date.parse(post['date']).strftime('%Y-%m-%d') date = Date.parse(post['date']).strftime('%Y-%m-%d')
title = post['title'].downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-') title = post['title'].downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-')
path = File.join("_posts", "#{date}-#{title}.#{post['type'] || 'textile'}") path = File.join(dir || '', '_posts', "#{date}-#{title}.#{post['type'] || 'textile'}")
matter_hash = {} matter_hash = {}
%w(title layout tags).each do |key| %w(title layout tags).each do |key|
matter_hash[key] = post[key] if post[key] matter_hash[key] = post[key] if post[key]
end end
matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp
content = post['content'] content = post['content']
if post['input'] && post['filter'] if post['input'] && post['filter']
content = "{{ #{post['input']} | #{post['filter']} }}" content = "{{ #{post['input']} | #{post['filter']} }}"
end end
File.open(path, 'w') do |f| File.open(path, 'w') do |f|
f.write <<EOF f.write <<EOF

View File

@ -193,6 +193,7 @@ module Jekyll
"date" => self.date, "date" => self.date,
"id" => self.id, "id" => self.id,
"topics" => self.topics, "topics" => self.topics,
"categories" => self.categories,
"content" => self.content }.deep_merge(self.data) "content" => self.content }.deep_merge(self.data)
end end