octopress-paginate 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/octopress-paginate.rb +48 -13
- data/lib/octopress-paginate/hooks.rb +2 -0
- data/lib/octopress-paginate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beb5d4ee3e941d744aee3f99b22c7723a20685c4
|
4
|
+
data.tar.gz: b87404e4acae09cc52761909ae5076a4d3132695
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ada480c93b4a62c44eae073690f13d8d35aa057f4febf88436882430e2136e572bcf9843943359d4e0bb55c29ee6c5d879c81f12c81efae62ca5e3ad99f40115
|
7
|
+
data.tar.gz: 16e17a538b19aaaba378524f8cdfa99605260a7d7ab4bbc759cc604a7bf2ec5fb1a28ac7eaeff4df314e746bc6365841b879e4a13d5ac687c6195325da9ad823
|
data/lib/octopress-paginate.rb
CHANGED
@@ -20,6 +20,12 @@ module Octopress
|
|
20
20
|
# Simple Page class override
|
21
21
|
class PaginationPage < Jekyll::Page
|
22
22
|
attr_accessor :dir, :name
|
23
|
+
|
24
|
+
def relative_asset_path
|
25
|
+
site_source = Pathname.new Octopress.site.source
|
26
|
+
page_source = Pathname.new @base
|
27
|
+
page_source.relative_path_from(site_source).to_s
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
25
31
|
def paginate(page)
|
@@ -57,19 +63,17 @@ module Octopress
|
|
57
63
|
|
58
64
|
pages.times do |i|
|
59
65
|
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
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
67
|
+
# If page is generated by an Octopress Ink plugin, use the built in
|
68
|
+
# methods for cloning the page
|
69
|
+
#
|
70
|
+
if page.respond_to?(:asset) && page.asset.to_s.match('Octopress::Ink')
|
71
|
+
new_page = page.asset.new_page(page_data(page, index))
|
72
|
+
else
|
73
|
+
new_page = PaginationPage.new(page.site, page.site.source, File.dirname(page.path), File.basename(page.path))
|
74
|
+
new_page.data.merge!(page_data(page, index))
|
75
|
+
new_page.process('index.html')
|
76
|
+
end
|
73
77
|
|
74
78
|
new_pages << new_page
|
75
79
|
end
|
@@ -93,10 +97,41 @@ module Octopress
|
|
93
97
|
page.site.pages.concat new_pages
|
94
98
|
end
|
95
99
|
|
100
|
+
def page_data(page, index)
|
101
|
+
{
|
102
|
+
'paginate' => paginate_data(page, index),
|
103
|
+
'permalink' => page_permalink(page, index),
|
104
|
+
'title' => page_title(page, index),
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
def page_permalink(page, index)
|
109
|
+
subdir = page.data['paginate']['permalink'].clone.sub(':num', index.to_s)
|
110
|
+
File.join(page.dir, subdir)
|
111
|
+
end
|
112
|
+
|
113
|
+
def paginate_data(page, index)
|
114
|
+
paginate_data = page.data['paginate'].clone
|
115
|
+
paginate_data['page_num'] = index
|
116
|
+
paginate_data
|
117
|
+
end
|
118
|
+
|
119
|
+
def page_title(page, index)
|
120
|
+
title = if page.data['title']
|
121
|
+
page.data['title']
|
122
|
+
else
|
123
|
+
page.data['paginate']['collection'].capitalize
|
124
|
+
end
|
125
|
+
|
126
|
+
title += page.data['paginate']['title_suffix'].sub(/:num/, index.to_s)
|
127
|
+
|
128
|
+
title
|
129
|
+
end
|
130
|
+
|
96
131
|
def collection(page)
|
97
132
|
collection = if page['paginate']['collection'] == 'posts'
|
98
133
|
if defined?(Octopress::Multilingual) && page.lang
|
99
|
-
page.site.posts_by_language
|
134
|
+
page.site.posts_by_language(page.lang)
|
100
135
|
else
|
101
136
|
page.site.posts.reverse
|
102
137
|
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.
|
4
|
+
version: 1.1.2
|
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-
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octopress-hooks
|