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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +35 -17
- data/lib/octopress-paginate.rb +21 -2
- data/lib/octopress-paginate/version.rb +1 -1
- metadata +2 -3
- data/lib/octopress-paginate/page.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e51b533c9a6bd3891a2ebb123e591dbe2cd9b4d
|
4
|
+
data.tar.gz: 824b2087235013b04bea4392847660c9486e5696
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d374f7bd5aaf4570dd6137ef8c3f53b335b689aa533668a03352c55aba1d46480af3ab4faa8c9a86a1709b3d0c2c790e22d46857bf432ff456f8dbcc13f58004
|
7
|
+
data.tar.gz: 072069d8e94b0d55c029a0ba6a41b6fdfdf95750a942ede3f379c7683d2ade00bf3f078d847484a5bc124fa866e1af9a1bb6a8a62c6f33eb4bc9e13c3be5d9f9
|
data/CHANGELOG.md
CHANGED
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
|
+
[](https://travis-ci.org/octopress/paginate)
|
12
|
+
[](https://rubygems.org/gems/octopress-paginate)
|
13
|
+
[](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
|
-
|
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
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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
|
-
|
101
|
+
pagination.total_penguins # Total number of peguins being paginated
|
84
102
|
```
|
85
103
|
|
86
104
|
## Configuration
|
data/lib/octopress-paginate.rb
CHANGED
@@ -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
|
-
|
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)
|
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.
|
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
|
+
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
|