octopress-paginate 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cdb9b591fdc9f11af9fc2cb3a20baef96d83db36
4
- data.tar.gz: dad38d9bfc07d065a2ebe20dc1aff8bffb46e256
3
+ metadata.gz: 0e51b533c9a6bd3891a2ebb123e591dbe2cd9b4d
4
+ data.tar.gz: 824b2087235013b04bea4392847660c9486e5696
5
5
  SHA512:
6
- metadata.gz: ee890b2580f06e6e9d370d7414e350ebfe6290040989f6addf786e6837abb37a00f3dd64e07b09e62331756b781b9bf07497ceba4ab65ddaed60f0c7ea063c1d
7
- data.tar.gz: 95b88ea34100c6dfac058b34a4e9520c55223028e47073c5191345eaa8f97c12b6e72aa12fcc124fcb03f20db9a6fdc129f4851ebbb49dc98e0424726fcae208
6
+ metadata.gz: d374f7bd5aaf4570dd6137ef8c3f53b335b689aa533668a03352c55aba1d46480af3ab4faa8c9a86a1709b3d0c2c790e22d46857bf432ff456f8dbcc13f58004
7
+ data.tar.gz: 072069d8e94b0d55c029a0ba6a41b6fdfdf95750a942ede3f379c7683d2ade00bf3f078d847484a5bc124fa866e1af9a1bb6a8a62c6f33eb4bc9e13c3be5d9f9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.1.1 (2015-02-27)
4
+
5
+ - Fix: Typo caused paginated collections to fail.
6
+
3
7
  ### 1.1.0 (2015-02-11)
4
8
 
5
9
  - New: Configure site-wide defaults in _config.yml
data/README.md CHANGED
@@ -8,6 +8,10 @@ Simple and flexible pagination for Jekyll sites featuring:
8
8
  - Filter by categories or tags
9
9
  - Multi-language support (with [octopress-multilingual](https://github.com/octopress/multilingual))
10
10
 
11
+ [![Build Status](http://img.shields.io/travis/octopress/paginate.svg)](https://travis-ci.org/octopress/paginate)
12
+ [![Gem Version](http://img.shields.io/gem/v/octopress-paginate.svg)](https://rubygems.org/gems/octopress-paginate)
13
+ [![License](http://img.shields.io/:license-mit-blue.svg)](http://octopress.mit-license.org)
14
+
11
15
  ## Installation
12
16
 
13
17
  If you're using bundler add this gem to your site's Gemfile in the `:jekyll_plugins` group:
@@ -31,9 +35,7 @@ Then add the gem to your Jekyll configuration.
31
35
 
32
36
  ## Usage
33
37
 
34
- ### To paginate posts
35
-
36
- Create a page to be used as the pagination template.
38
+ To paginate posts, create a page to be used as the pagination template.
37
39
 
38
40
  ```
39
41
  ---
@@ -46,10 +48,7 @@ paginate: true
46
48
  {% endfor %}
47
49
  ```
48
50
 
49
- ### To paginate collections
50
-
51
- This is basically the same as paginating posts, except you have to configure the paginate collection and set up the paginator to
52
- use the collection name.
51
+ Paginating collection is almost the same as posts except you need to set the collection to paginate.
53
52
 
54
53
  ```
55
54
  ---
@@ -63,24 +62,43 @@ paginate:
63
62
  {% endfor %}
64
63
  ```
65
64
 
65
+ ### Multilingual pagination
66
+
67
+ If you are running a multilingual site with [octopress-multilingual](https://github.com/octopress/multilingual), simply set a language for your pagination template and posts will be filtered by that language. For example:
68
+
69
+ ```
70
+ ---
71
+ Title: "Deutsch Posts"
72
+ permalink: /de/posts/ # <- Or wherever makes sense on your site
73
+ paginate: true
74
+ lang: de # <- Add a language
75
+ ---
76
+
77
+ {% for posts in paginator.posts %}
78
+ / do stuff /
79
+ {% endfor %}
80
+ ```
81
+
82
+ That's all there is to it.
83
+
66
84
  ### Template variables
67
85
 
68
86
  Just like Jekyll's paginator, your pagination pages will have access to the following liquid variables.
69
87
 
70
88
 
71
89
  ```yaml
72
- {{ paginator.total_pages }} # Number of paginated pages
73
- {{ paginator.total_posts }} # Total number of posts being paginated
74
- {{ paginator.per_page }} # Posts per page
75
- {{ paginator.limit }} # Maximum number of paginated pages
76
- {{ paginator.page }} # Current page number
77
- {{ paginator.previous_page }} # Previous page number (nil if first page)
78
- {{ paginator.previous_page_path }} # Url for previous page (nil if first page)
79
- {{ paginator.next_page }} # Next page number (nil if last page)
80
- {{ paginator.next_page_path }} # Next page URL (nil if last page)
90
+ paginator.total_pages # Number of paginated pages
91
+ paginator.total_posts # Total number of posts being paginated
92
+ paginator.per_page # Posts per page
93
+ paginator.limit # Maximum number of paginated pages
94
+ paginator.page # Current page number
95
+ paginator.previous_page # Previous page number (nil if first page)
96
+ paginator.previous_page_path # Url for previous page (nil if first page)
97
+ paginator.next_page # Next page number (nil if last page)
98
+ paginator.next_page_path # Next page URL (nil if last page)
81
99
 
82
100
  # If you're pagination through a collection named `penguins`
83
- {{ pagination.total_penguins }} # Total number of peguins being paginated
101
+ pagination.total_penguins # Total number of peguins being paginated
84
102
  ```
85
103
 
86
104
  ## Configuration
@@ -1,7 +1,6 @@
1
1
  require "octopress-hooks"
2
2
  require "octopress-paginate/version"
3
3
  require "octopress-paginate/hooks"
4
- require "octopress-paginate/page"
5
4
 
6
5
  module Octopress
7
6
  module Paginate
@@ -18,6 +17,11 @@ module Octopress
18
17
 
19
18
  LOOP = /(paginate.+\s+in)\s+(site\.(.+?))(.+)%}/
20
19
 
20
+ # Simple Page class override
21
+ class PaginationPage < Jekyll::Page
22
+ attr_accessor :dir, :name
23
+ end
24
+
21
25
  def paginate(page)
22
26
 
23
27
  defaults = DEFAULT.merge(page.site.config['pagination'] || {})
@@ -52,7 +56,22 @@ module Octopress
52
56
  new_pages = []
53
57
 
54
58
  pages.times do |i|
55
- new_pages << PaginationPage.new(page.site, page.site.source, i+2, page)
59
+ index = i+2
60
+ new_page = PaginationPage.new(page.site, page.site.source, File.dirname(page.path), File.basename(page.path))
61
+ new_page.process('index.html')
62
+ new_page.data.delete('permalink')
63
+
64
+ new_page.data.merge!({'paginate' => page.data['paginate'].clone})
65
+ new_page.data['paginate']['page_num'] = index
66
+
67
+ title = page.data['title'].clone || page.data['paginate']['collection'].capitalize
68
+ title << page.data['paginate']['title_suffix'].sub(/:num/, index.to_s)
69
+ new_page.data['title'] = title
70
+
71
+ subdir = page.data['paginate']['permalink'].clone.sub(':num', index.to_s)
72
+ new_page.dir = File.join(page.dir, subdir)
73
+
74
+ new_pages << new_page
56
75
  end
57
76
 
58
77
  all_pages = [page].concat(new_pages)
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Paginate
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-paginate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-11 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octopress-hooks
@@ -120,7 +120,6 @@ files:
120
120
  - README.md
121
121
  - lib/octopress-paginate.rb
122
122
  - lib/octopress-paginate/hooks.rb
123
- - lib/octopress-paginate/page.rb
124
123
  - lib/octopress-paginate/version.rb
125
124
  homepage: https://github.com/octopress/paginate
126
125
  licenses:
@@ -1,21 +0,0 @@
1
- module Octopress
2
- module Paginate
3
- class PaginationPage < Jekyll::Page
4
- def initialize(site, base, index, template)
5
- @site = site
6
- @base = base
7
- @dir = File.join(template.dir, template.data['paginate']['permalink'].clone.sub(':num', index.to_s))
8
- @name = 'index.html'
9
- process(name)
10
- read_yaml(File.join(base, File.dirname(template.path)), File.basename(template.path))
11
-
12
- self.data.delete('permalink')
13
- self.data.merge!({ 'paginate' => template.data['paginate'].clone })
14
- self.data['paginate']['page_num'] = index
15
-
16
- self.data['title'] ||= self.data['paginate']['collection'].capitlaize
17
- self.data['title'] << data['paginate']['title_suffix'].sub(/:num/, data['paginate']['page_num'].to_s)
18
- end
19
- end
20
- end
21
- end