generate phase added to site#process and pagination is now a generator

This commit is contained in:
Kris Brown 2010-02-27 15:31:59 +00:00
parent bae52e0aba
commit 1261840769
4 changed files with 17 additions and 12 deletions

View File

@ -4,6 +4,7 @@
* Generation for a specific time (#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 and site.html_pages variables
* generate phase added to site#process and pagination is now a generator
* Bug Fixes
* Render highlighted code for non markdown/textile pages (#116)
* Expand source to full path so includes work anywhere (#101)

View File

@ -3,7 +3,7 @@ module Jekyll
class Page
include Convertible
attr_accessor :site
attr_accessor :site, :pager
attr_accessor :name, :ext, :basename, :dir
attr_accessor :data, :content, :output
@ -81,7 +81,8 @@ module Jekyll
# Returns nothing
def render(layouts, site_payload)
payload = {
"page" => self.to_liquid
"page" => self.to_liquid,
'paginator' => pager.to_liquid
}.deep_merge(site_payload)
do_layout(payload, layouts)

View File

@ -30,7 +30,7 @@ module Jekyll
@next_page = @page != @total_pages ? @page + 1 : nil
end
def to_hash
def to_liquid
{
'page' => page,
'per_page' => per_page,

View File

@ -92,13 +92,14 @@ module Jekyll
end
# Do the actual work of processing the site and generating the
# real deal. Now has 4 phases; reset, read, render, write. This allows
# real deal. 5 phases; reset, read, generate, render, write. This allows
# rendering to have full site payload available.
#
# Returns nothing
def process
self.reset
self.read
self.generate
self.render
self.write
end
@ -154,13 +155,9 @@ module Jekyll
post.render(self.layouts, site_payload)
end
self.pages.dup.each do |page|
if Pager.pagination_enabled?(self.config, page.name)
paginate(page)
else
self.pages.each do |page|
page.render(self.layouts, site_payload)
end
end
self.categories.values.map { |ps| ps.sort! { |a, b| b <=> a} }
self.tags.values.map { |ps| ps.sort! { |a, b| b <=> a} }
@ -254,6 +251,12 @@ module Jekyll
end
end
def generate
self.pages.dup.each do |page|
paginate(page) if Pager.pagination_enabled?(self.config, page.name)
end
end
# Paginates the blog's posts. Renders the index.html file into paginated
# directories, ie: page2/index.html, page3/index.html, etc and adds more
# site-wide data.
@ -273,11 +276,11 @@ module Jekyll
pager = Pager.new(self.config, num_page, all_posts, pages)
if num_page > 1
newpage = Page.new(self, self.source, page.dir, page.name)
newpage.render(self.layouts, site_payload.merge({'paginator' => pager.to_hash}))
newpage.pager = pager
newpage.dir = File.join(page.dir, "page#{num_page}")
self.pages << newpage
else
page.render(self.layouts, site_payload.merge({'paginator' => pager.to_hash}))
page.pager = pager
end
end
end