Skip to content

Commit

Permalink
Feature for the pagination templating
Browse files Browse the repository at this point in the history
  • Loading branch information
ujh committed Jun 2, 2009
1 parent 937efcf commit 5bbdf22
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 17 additions & 0 deletions features/pagination.feature
Expand Up @@ -21,3 +21,20 @@ Feature: Site pagination
| num |
| 1 |
| 2 |

Scenario: Correct liquid paginator replacements
Given I have a configuration file with "paginate" set to "1"
And I have a _layouts directory
And I have an "index.html" file that contains "{{ paginator.page }}"
And I have a _posts directory
And I have the following post:
| title | date | layout | content |
| Wargames | 3/27/2009 | default | The only winning move is not to play. |
| Wargames2 | 4/27/2009 | default | The only winning move is not to play2. |
When I run jekyll
Then the _site/index.html file should exist
And I should see "1" in "_site/index.html"
Then the _site/page2 directory should exist
And the _site/page2/index.html file should exist
And I should see "2" in "_site/page2/index.html"

2 changes: 0 additions & 2 deletions lib/jekyll/site.rb
Expand Up @@ -250,11 +250,9 @@ def filter_entries(entries)
# "next_page" => <Number> }}
def paginate_posts(file, dir)
all_posts = self.posts.sort { |a,b| b <=> a }

pages = Pager.calculate_pages(all_posts, self.config['paginate'].to_i)
pages += 1
(1..pages).each do |num_page|

pager = Pager.new(self.config, num_page, all_posts, pages)
page = Page.new(self, self.source, dir, file)
page.render(self.layouts, site_payload.merge({'paginator' => pager.to_hash}))
Expand Down

0 comments on commit 5bbdf22

Please sign in to comment.