Merge commit 'ujh/master'
This commit is contained in:
commit
606269b33c
|
@ -3,8 +3,8 @@ Feature: Site pagination
|
|||
As a blog's user
|
||||
I want divide the posts in several pages
|
||||
|
||||
Scenario: Create pages
|
||||
Given I have a configuration file with "paginate" set to "1"
|
||||
Scenario Outline: Paginate with N posts per page
|
||||
Given I have a configuration file with "paginate" set to "<num>"
|
||||
And I have a _layouts directory
|
||||
And I have an "index.html" file that contains "Basic Site"
|
||||
And I have a _posts directory
|
||||
|
@ -12,6 +12,29 @@ Feature: Site pagination
|
|||
| 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. |
|
||||
| Wargames3 | 5/27/2009 | default | The only winning move is not to play2. |
|
||||
When I run jekyll
|
||||
Then the _site/page2 directory should exist
|
||||
And the _site/page2/index.html file should exist
|
||||
|
||||
Examples:
|
||||
| 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"
|
||||
|
|
@ -59,3 +59,18 @@ Feature: Site data
|
|||
When I run jekyll
|
||||
Then the _site directory should exist
|
||||
And I should see "Yuengling" in "_site/index.html"
|
||||
|
||||
Scenario: Order Posts by name when on the same date
|
||||
Given I have a _posts directory
|
||||
And I have an "index.html" page that contains "{% for post in site.posts %}{{ post.title }}:{{ post.previous.title}},{{ post.next.title}} {% endfor %}"
|
||||
And I have the following posts:
|
||||
| title | date | content |
|
||||
| first | 2/26/2009 | first |
|
||||
| A | 3/26/2009 | A |
|
||||
| B | 3/26/2009 | B |
|
||||
| C | 3/26/2009 | C |
|
||||
| last | 4/26/2009 | last |
|
||||
When I run jekyll
|
||||
Then the _site directory should exist
|
||||
And I should see "last:C, C:B,last B:A,C A:first,B first:,A" in "_site/index.html"
|
||||
|
|
@ -70,11 +70,15 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
|
||||
# Spaceship is based on Post#date
|
||||
# Spaceship is based on Post#date, slug
|
||||
#
|
||||
# Returns -1, 0, 1
|
||||
def <=>(other)
|
||||
self.date <=> other.date
|
||||
cmp = self.date <=> other.date
|
||||
if 0 == cmp
|
||||
cmp = self.slug <=> other.slug
|
||||
end
|
||||
return cmp
|
||||
end
|
||||
|
||||
# Extract information from the post filename
|
||||
|
|
|
@ -250,13 +250,11 @@ module Jekyll
|
|||
# "next_page" => <Number> }}
|
||||
def paginate_posts(file, dir)
|
||||
all_posts = self.posts.sort { |a,b| b <=> a }
|
||||
page = Page.new(self, self.source, dir, file)
|
||||
|
||||
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}))
|
||||
suffix = "page#{num_page}" if num_page > 1
|
||||
page.write(self.dest, suffix)
|
||||
|
|
Loading…
Reference in New Issue