Merge branch 'enh_pages_in_payload'
This commit is contained in:
commit
bfdf7fb13a
|
@ -3,6 +3,7 @@
|
||||||
* Inclusion/exclusion of future dated posts (#59)
|
* Inclusion/exclusion of future dated posts (#59)
|
||||||
* Generation for a specific time (#59)
|
* Generation for a specific time (#59)
|
||||||
* site.time allocated on render not per site_payload invocation (#59)
|
* site.time allocated on render not per site_payload invocation (#59)
|
||||||
|
* pages now present in the site payload and can be used through the site.pages variable
|
||||||
* Bug Fixes
|
* Bug Fixes
|
||||||
* Render highlighted code for non markdown/textile pages (#116)
|
* Render highlighted code for non markdown/textile pages (#116)
|
||||||
* Expand source to full path so includes work anywhere (#101)
|
* Expand source to full path so includes work anywhere (#101)
|
||||||
|
|
|
@ -39,11 +39,11 @@ Feature: Create sites
|
||||||
|
|
||||||
Scenario: Basic site with layouts, pages, posts and files
|
Scenario: Basic site with layouts, pages, posts and files
|
||||||
Given I have a _layouts directory
|
Given I have a _layouts directory
|
||||||
And I have a page layout that contains "Page Layout: {{ site.posts.size }}"
|
And I have a page layout that contains "Page {{ page.title }}: {{ content }}"
|
||||||
And I have a post layout that contains "Post Layout: {{ content }}"
|
And I have a post layout that contains "Post {{ page.title }}: {{ content }}"
|
||||||
And I have an "index.html" page with layout "page" that contains "site index page"
|
And I have an "index.html" page with layout "page" that contains "Site contains {{ site.pages.size }} pages and {{ site.posts.size }} posts"
|
||||||
And I have a blog directory
|
And I have a blog directory
|
||||||
And I have a "blog/index.html" page with layout "page" that contains "category index page"
|
And I have a "blog/index.html" page with layout "page" that contains "blog category index page"
|
||||||
And I have an "about.html" file that contains "No replacement {{ site.posts.size }}"
|
And I have an "about.html" file that contains "No replacement {{ site.posts.size }}"
|
||||||
And I have an "another_file" file that contains ""
|
And I have an "another_file" file that contains ""
|
||||||
And I have a _posts directory
|
And I have a _posts directory
|
||||||
|
@ -58,14 +58,14 @@ Feature: Create sites
|
||||||
| entry4 | 6/27/2009 | post | content for entry4. |
|
| entry4 | 6/27/2009 | post | content for entry4. |
|
||||||
When I run jekyll
|
When I run jekyll
|
||||||
Then the _site directory should exist
|
Then the _site directory should exist
|
||||||
And I should see "Page Layout: 4" in "_site/index.html"
|
And I should see "Page : Site contains 2 pages and 4 posts" in "_site/index.html"
|
||||||
And I should see "No replacement \{\{ site.posts.size \}\}" in "_site/about.html"
|
And I should see "No replacement \{\{ site.posts.size \}\}" in "_site/about.html"
|
||||||
And I should see "" in "_site/another_file"
|
And I should see "" in "_site/another_file"
|
||||||
And I should see "Page Layout: 4" in "_site/blog/index.html"
|
And I should see "Page : blog category index page" in "_site/blog/index.html"
|
||||||
And I should see "Post Layout: <p>content for entry1.</p>" in "_site/2009/03/27/entry1.html"
|
And I should see "Post entry1: <p>content for entry1.</p>" in "_site/2009/03/27/entry1.html"
|
||||||
And I should see "Post Layout: <p>content for entry2.</p>" in "_site/2009/04/27/entry2.html"
|
And I should see "Post entry2: <p>content for entry2.</p>" in "_site/2009/04/27/entry2.html"
|
||||||
And I should see "Post Layout: <p>content for entry3.</p>" in "_site/category/2009/05/27/entry3.html"
|
And I should see "Post entry3: <p>content for entry3.</p>" in "_site/category/2009/05/27/entry3.html"
|
||||||
And I should see "Post Layout: <p>content for entry4.</p>" in "_site/category/2009/06/27/entry4.html"
|
And I should see "Post entry4: <p>content for entry4.</p>" in "_site/category/2009/06/27/entry4.html"
|
||||||
|
|
||||||
Scenario: Basic site with include tag
|
Scenario: Basic site with include tag
|
||||||
Given I have a _includes directory
|
Given I have a _includes directory
|
||||||
|
|
|
@ -80,10 +80,19 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns nothing
|
# Returns nothing
|
||||||
def render(layouts, site_payload)
|
def render(layouts, site_payload)
|
||||||
payload = {"page" => self.data}.deep_merge(site_payload)
|
payload = {
|
||||||
|
"page" => self.to_liquid
|
||||||
|
}.deep_merge(site_payload)
|
||||||
|
|
||||||
do_layout(payload, layouts)
|
do_layout(payload, layouts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_liquid
|
||||||
|
self.data.deep_merge({
|
||||||
|
"url" => self.url,
|
||||||
|
"content" => self.content })
|
||||||
|
end
|
||||||
|
|
||||||
# Write the generated page file to the destination directory.
|
# Write the generated page file to the destination directory.
|
||||||
# +dest_prefix+ is the String path to the destination dir
|
# +dest_prefix+ is the String path to the destination dir
|
||||||
# +dest_suffix+ is a suffix path to the destination dir
|
# +dest_suffix+ is a suffix path to the destination dir
|
||||||
|
|
|
@ -167,12 +167,10 @@ module Jekyll
|
||||||
# Returns nothing
|
# Returns nothing
|
||||||
def render(layouts, site_payload)
|
def render(layouts, site_payload)
|
||||||
# construct payload
|
# construct payload
|
||||||
payload =
|
payload = {
|
||||||
{
|
|
||||||
"site" => { "related_posts" => related_posts(site_payload["site"]["posts"]) },
|
"site" => { "related_posts" => related_posts(site_payload["site"]["posts"]) },
|
||||||
"page" => self.to_liquid
|
"page" => self.to_liquid
|
||||||
}
|
}.deep_merge(site_payload)
|
||||||
payload = payload.deep_merge(site_payload)
|
|
||||||
|
|
||||||
do_layout(payload, layouts)
|
do_layout(payload, layouts)
|
||||||
end
|
end
|
||||||
|
|
|
@ -230,11 +230,13 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns {"site" => {"time" => <Time>,
|
# Returns {"site" => {"time" => <Time>,
|
||||||
# "posts" => [<Post>],
|
# "posts" => [<Post>],
|
||||||
|
# "pages" => [<Page>],
|
||||||
# "categories" => [<Post>]}
|
# "categories" => [<Post>]}
|
||||||
def site_payload
|
def site_payload
|
||||||
{"site" => self.config.merge({
|
{"site" => self.config.merge({
|
||||||
"time" => self.time,
|
"time" => self.time,
|
||||||
"posts" => self.posts.sort { |a,b| b <=> a },
|
"posts" => self.posts.sort { |a,b| b <=> a },
|
||||||
|
"pages" => self.pages,
|
||||||
"categories" => post_attr_hash('categories'),
|
"categories" => post_attr_hash('categories'),
|
||||||
"tags" => post_attr_hash('tags')})}
|
"tags" => post_attr_hash('tags')})}
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,21 +3,21 @@ layout: nil
|
||||||
---
|
---
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<urlset
|
<urlset
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
|
||||||
<url>
|
<url>
|
||||||
<loc>http://example.com</loc>
|
<loc>http://example.com</loc>
|
||||||
<lastmod>{{ site.time | date_to_xmlschema }}</lastmod>
|
<lastmod>{{ site.time | date: "%Y-%m-%d" }}</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
<priority>1.0</priority>
|
<priority>1.0</priority>
|
||||||
</url>
|
</url>
|
||||||
|
|
||||||
{% for post in site.posts %}
|
{% for post in site.posts %}
|
||||||
<url>
|
<url>
|
||||||
<loc>http://example.com/{{ post.url }}/</loc>
|
<loc>http://example.com/{{ post.url }}/</loc>
|
||||||
<lastmod>{{ site.time }}</lastmod>
|
<lastmod>{{ post.date | date: "%Y-%m-%d" }}</lastmod>
|
||||||
<changefreq>monthly</changefreq>
|
<changefreq>monthly</changefreq>
|
||||||
<priority>0.2</priority>
|
<priority>0.2</priority>
|
||||||
</url>
|
</url>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</urlset>
|
</urlset>
|
||||||
|
|
Loading…
Reference in New Issue