jekyll-paginate-v2 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -1
- data/README.md +107 -3
- data/examples/01-typicalblog/Gemfile +28 -0
- data/examples/01-typicalblog/README.md +91 -0
- data/examples/01-typicalblog/_config.yml +51 -0
- data/examples/01-typicalblog/_includes/header.html +31 -0
- data/examples/01-typicalblog/_layouts/home.html +52 -0
- data/examples/01-typicalblog/_posts/2016-11-20-geography-of-minneapolis.md +29 -0
- data/examples/01-typicalblog/_posts/2016-11-21-sailing-summer-olympics-1988.md +15 -0
- data/examples/01-typicalblog/_posts/2016-11-22-rotary-engine.md +27 -0
- data/examples/01-typicalblog/_posts/2016-11-23-luft-fahrzeug-gesellschaft.md +27 -0
- data/examples/01-typicalblog/_posts/2016-11-24-narcisse-snake-pits.md +18 -0
- data/examples/01-typicalblog/_posts/2016-11-25-tele7jours.md +43 -0
- data/examples/01-typicalblog/_posts/2016-11-26-columbia-river.md +41 -0
- data/examples/01-typicalblog/_posts/2016-11-27-welcome-to-jekyll-paginate-v2.md +33 -0
- data/examples/01-typicalblog/about.md +15 -0
- data/examples/01-typicalblog/index.html +8 -0
- data/examples/02-category/Gemfile +28 -0
- data/examples/02-category/README.md +119 -0
- data/examples/02-category/_config.yml +47 -0
- data/examples/02-category/_includes/header.html +31 -0
- data/examples/02-category/_layouts/home.html +52 -0
- data/examples/02-category/_posts/2016-10-27-welcome-to-jekyll-paginate-v2.md +32 -0
- data/examples/02-category/about.md +15 -0
- data/examples/02-category/cars/_posts/2016-10-18-Porsche-918-Spyder.md +13 -0
- data/examples/02-category/cars/_posts/2016-10-19-Porsche-964.md +12 -0
- data/examples/02-category/cars/_posts/2016-10-20-porsche-911-gt3.md +13 -0
- data/examples/02-category/cars/_posts/2016-10-21-porsche-911.md +13 -0
- data/examples/02-category/cars/_posts/2016-10-22-porsche-962.md +18 -0
- data/examples/02-category/cars/_posts/2016-10-23-Toyota-GT-One.md +20 -0
- data/examples/02-category/cars/_posts/2016-10-24-Mercedes-Benz-CLK-GTR.md +40 -0
- data/examples/02-category/cars/_posts/2016-10-25-rolls-royce-silver-ghost.md +31 -0
- data/examples/02-category/categories/byname.md +11 -0
- data/examples/02-category/categories/porsche.md +10 -0
- data/examples/02-category/index.md +13 -0
- data/examples/02-category/toyota/index.md +7 -0
- data/examples/03-tags/Gemfile +28 -0
- data/examples/03-tags/README.md +60 -0
- data/examples/03-tags/_config.yml +45 -0
- data/examples/03-tags/_includes/header.html +31 -0
- data/examples/03-tags/_layouts/home.html +51 -0
- data/examples/03-tags/_layouts/post.html +20 -0
- data/examples/03-tags/biography/_posts/2016-10-27-born-to-run.md +26 -0
- data/examples/03-tags/biography/_posts/2016-10-27-forty-autumns.md +26 -0
- data/examples/03-tags/biography/_posts/2016-10-27-life-in-questions-a.md +27 -0
- data/examples/03-tags/biography/_posts/2016-10-27-not-dead-yet.md +24 -0
- data/examples/03-tags/biography/_posts/2016-10-27-princess-diarist-the.md +26 -0
- data/examples/03-tags/biography/_posts/2016-10-27-when-breath-becomes-air.md +24 -0
- data/examples/03-tags/biography/biography-musicians.md +13 -0
- data/examples/03-tags/biography/biography.md +12 -0
- data/examples/03-tags/blog/_posts/2016-09-30-welcome-to-jekyll-paginate-v2.md +32 -0
- data/examples/03-tags/byisbn.md +13 -0
- data/examples/03-tags/fantasy/_posts/2016-10-27-harry-potter-deathly-hallows.md +24 -0
- data/examples/03-tags/fantasy/_posts/2016-10-27-harry-potter-philosophers-stone.md +24 -0
- data/examples/03-tags/fantasy/_posts/2016-10-27-mistborn-trilogy.md +24 -0
- data/examples/03-tags/fantasy/_posts/2016-10-27-ready-player-one.md +24 -0
- data/examples/03-tags/fantasy/_posts/2016-10-27-sword-of-destiny.md +24 -0
- data/examples/03-tags/fantasy/_posts/2016-10-27-terry-pratchet-diary-2017.md +24 -0
- data/examples/03-tags/index.md +18 -0
- data/examples/03-tags/romance/_posts/2016-10-27-breath-of-snow-and-ashes-a.md +25 -0
- data/examples/03-tags/romance/_posts/2016-10-27-dressmaker-the.md +24 -0
- data/examples/03-tags/romance/_posts/2016-10-27-fiery-cross-the.md +26 -0
- data/examples/03-tags/romance/_posts/2016-10-27-it-ends-with-us.md +28 -0
- data/examples/03-tags/romance/_posts/2016-10-27-outlander-novel.md +34 -0
- data/examples/03-tags/romance/_posts/2016-10-27-virgins-outlander-short-story.md +26 -0
- data/examples/03-tags/romance/romance-historical.md +14 -0
- data/examples/03-tags/tags/contemporary.md +10 -0
- data/examples/03-tags/tags/fantasy.md +12 -0
- data/examples/03-tags/tags/sci-fi.md +13 -0
- data/examples/README.md +21 -0
- data/examples/img/01-example-screenshot-main.png +0 -0
- data/examples/img/02-example-screenshot-main.png +0 -0
- data/examples/img/03-example-screenshot-main.png +0 -0
- data/lib/jekyll-paginate-v2.rb +1 -0
- data/lib/jekyll-paginate-v2/compatibilityUtils.rb +4 -3
- data/lib/jekyll-paginate-v2/paginationGenerator.rb +15 -8
- data/lib/jekyll-paginate-v2/paginationModel.rb +58 -37
- data/lib/jekyll-paginate-v2/paginationPage.rb +38 -0
- data/lib/jekyll-paginate-v2/paginator.rb +3 -3
- data/lib/jekyll-paginate-v2/utils.rb +47 -1
- data/lib/jekyll-paginate-v2/version.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- metadata +74 -2
@@ -0,0 +1,38 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module PaginateV2
|
3
|
+
|
4
|
+
#
|
5
|
+
# This page handles the creation of the fake pagination pages based on the original page configuration
|
6
|
+
# The code does the same things as the default Jekyll/page.rb code but just forces the code to look
|
7
|
+
# into the template instead of the (currently non-existing) pagination page.
|
8
|
+
#
|
9
|
+
class PaginationPage < Page
|
10
|
+
def initialize(site, base, dir, template_path)
|
11
|
+
@site = site
|
12
|
+
@base = base
|
13
|
+
@dir = dir
|
14
|
+
@template = template_path
|
15
|
+
@name = 'index.html'
|
16
|
+
|
17
|
+
templ_dir = File.dirname(template_path)
|
18
|
+
templ_file = File.basename(template_path)
|
19
|
+
|
20
|
+
# Path is only used by the convertible module and accessed below when calling read_yaml
|
21
|
+
# in our case we have the path point to the original template instead of our faux new pagination page
|
22
|
+
@path = if site.in_theme_dir(base) == base # we're in a theme
|
23
|
+
site.in_theme_dir(base, templ_dir, templ_file)
|
24
|
+
else
|
25
|
+
site.in_source_dir(base, templ_dir, templ_file)
|
26
|
+
end
|
27
|
+
|
28
|
+
self.process(@name)
|
29
|
+
self.read_yaml(templ_dir, templ_file)
|
30
|
+
|
31
|
+
data.default_proc = proc do |_, key|
|
32
|
+
site.frontmatter_defaults.find(File.join(templ_dir, templ_file), type, key)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end # class PaginationPage
|
37
|
+
end # module PaginateV2
|
38
|
+
end # module Jekyll
|
@@ -15,7 +15,7 @@ module Jekyll
|
|
15
15
|
# all_posts - The Array of all the site's Posts.
|
16
16
|
# num_pages - The Integer number of pages or nil if you'd like the number
|
17
17
|
# of pages calculated.
|
18
|
-
def initialize(config_per_page, config_permalink, posts, cur_page_nr, num_pages, template_url )
|
18
|
+
def initialize(config_per_page, config_permalink, posts, cur_page_nr, num_pages, template_url, template_path )
|
19
19
|
@page = cur_page_nr
|
20
20
|
@per_page = config_per_page.to_i
|
21
21
|
@total_pages = num_pages
|
@@ -30,9 +30,9 @@ module Jekyll
|
|
30
30
|
@total_posts = posts.size
|
31
31
|
@posts = posts[init..offset]
|
32
32
|
@previous_page = @page != 1 ? @page - 1 : nil
|
33
|
-
@previous_page_path = @page != 1 ? Utils.paginate_path(template_url, @previous_page, config_permalink) : nil
|
33
|
+
@previous_page_path = @page != 1 ? Utils.paginate_path(template_url, template_path, @previous_page, config_permalink) : nil
|
34
34
|
@next_page = @page != @total_pages ? @page + 1 : nil
|
35
|
-
@next_page_path = @page != @total_pages ? Utils.paginate_path(template_url, @next_page, config_permalink) : nil
|
35
|
+
@next_page_path = @page != @total_pages ? Utils.paginate_path(template_url, template_path, @next_page, config_permalink) : nil
|
36
36
|
end
|
37
37
|
|
38
38
|
# Convert this Paginator's data to a Hash suitable for use by Liquid.
|
@@ -24,7 +24,7 @@ module Jekyll
|
|
24
24
|
# config - the current configuration in use
|
25
25
|
#
|
26
26
|
# Returns the pagination path as a string
|
27
|
-
def self.paginate_path(template_url, cur_page_nr, permalink_format)
|
27
|
+
def self.paginate_path(template_url, template_path, cur_page_nr, permalink_format)
|
28
28
|
return nil if cur_page_nr.nil?
|
29
29
|
return template_url if cur_page_nr <= 1
|
30
30
|
if permalink_format.include?(":num")
|
@@ -32,6 +32,13 @@ module Jekyll
|
|
32
32
|
else
|
33
33
|
raise ArgumentError.new("Invalid pagination path: '#{permalink_format}'. It must include ':num'.")
|
34
34
|
end
|
35
|
+
|
36
|
+
# If the template url is not just root "/" then pre-pend the template_url path to it
|
37
|
+
template_dir = File.dirname(template_path)
|
38
|
+
if( template_dir != "" && template_dir != "/" )
|
39
|
+
permalink_format = File.join(template_url, permalink_format)
|
40
|
+
end
|
41
|
+
|
35
42
|
Utils.ensure_leading_slash(permalink_format)
|
36
43
|
end #function paginate_path
|
37
44
|
|
@@ -61,6 +68,45 @@ module Jekyll
|
|
61
68
|
path[0..0] == "/" ? path[1..-1] : path
|
62
69
|
end
|
63
70
|
|
71
|
+
#
|
72
|
+
# Sorting routine used for ordering posts by custom fields.
|
73
|
+
# Handles Strings separately as we want a case-insenstive sorting
|
74
|
+
#
|
75
|
+
def self.sort_values(a, b)
|
76
|
+
if a.is_a?(String)
|
77
|
+
return a.downcase <=> b.downcase
|
78
|
+
end
|
79
|
+
|
80
|
+
# By default use the built in sorting for the data type
|
81
|
+
return a <=> b
|
82
|
+
end
|
83
|
+
|
84
|
+
# Retrieves the given sort field from the given post
|
85
|
+
# the sort_field variable can be a hierarchical value on the form "parent_field:child_field" repeated as many times as needed
|
86
|
+
# only the leaf child_field will be retrieved
|
87
|
+
def self.sort_get_post_data(post, sort_field)
|
88
|
+
|
89
|
+
# Begin by splitting up the sort_field by (;,:.)
|
90
|
+
sort_split = sort_field.split(":")
|
91
|
+
sort_value = post.data
|
92
|
+
|
93
|
+
for r_key in sort_split
|
94
|
+
key = r_key.downcase.strip # Remove any erronious whitespace and convert to lower case
|
95
|
+
if !sort_value.has_key?(key)
|
96
|
+
return nil
|
97
|
+
end
|
98
|
+
# Work my way through the hash
|
99
|
+
sort_value = sort_value[key]
|
100
|
+
end
|
101
|
+
|
102
|
+
# If the sort value is a hash then return nil else return the value
|
103
|
+
if( sort_value.is_a?(Hash) )
|
104
|
+
return nil
|
105
|
+
else
|
106
|
+
return sort_value
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
64
110
|
end
|
65
111
|
|
66
112
|
end # module PaginateV2
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Jekyll
|
2
2
|
module PaginateV2
|
3
|
-
VERSION = "1.
|
3
|
+
VERSION = "1.4.0"
|
4
4
|
# When modifying remember to issue a new tag command in git before committing, then push the new tag
|
5
|
-
# git tag -a v1.
|
5
|
+
# git tag -a v1.4.0 -m "Gem v1.4.0"
|
6
6
|
# git push origin --tags
|
7
7
|
end
|
8
8
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,6 +7,7 @@ require_relative '../lib/jekyll-paginate-v2/defaults'
|
|
7
7
|
require_relative '../lib/jekyll-paginate-v2/utils'
|
8
8
|
require_relative '../lib/jekyll-paginate-v2/compatibilityUtils'
|
9
9
|
require_relative '../lib/jekyll-paginate-v2/paginator'
|
10
|
+
require_relative '../lib/jekyll-paginate-v2/paginationPage'
|
10
11
|
require_relative '../lib/jekyll-paginate-v2/paginationModel'
|
11
12
|
require_relative '../lib/jekyll-paginate-v2/paginationGenerator'
|
12
13
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-paginate-v2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sverrir Sigmundarson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -67,12 +67,84 @@ files:
|
|
67
67
|
- LICENSE
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
|
+
- examples/01-typicalblog/Gemfile
|
71
|
+
- examples/01-typicalblog/README.md
|
72
|
+
- examples/01-typicalblog/_config.yml
|
73
|
+
- examples/01-typicalblog/_includes/header.html
|
74
|
+
- examples/01-typicalblog/_layouts/home.html
|
75
|
+
- examples/01-typicalblog/_posts/2016-11-20-geography-of-minneapolis.md
|
76
|
+
- examples/01-typicalblog/_posts/2016-11-21-sailing-summer-olympics-1988.md
|
77
|
+
- examples/01-typicalblog/_posts/2016-11-22-rotary-engine.md
|
78
|
+
- examples/01-typicalblog/_posts/2016-11-23-luft-fahrzeug-gesellschaft.md
|
79
|
+
- examples/01-typicalblog/_posts/2016-11-24-narcisse-snake-pits.md
|
80
|
+
- examples/01-typicalblog/_posts/2016-11-25-tele7jours.md
|
81
|
+
- examples/01-typicalblog/_posts/2016-11-26-columbia-river.md
|
82
|
+
- examples/01-typicalblog/_posts/2016-11-27-welcome-to-jekyll-paginate-v2.md
|
83
|
+
- examples/01-typicalblog/about.md
|
84
|
+
- examples/01-typicalblog/index.html
|
85
|
+
- examples/02-category/Gemfile
|
86
|
+
- examples/02-category/README.md
|
87
|
+
- examples/02-category/_config.yml
|
88
|
+
- examples/02-category/_includes/header.html
|
89
|
+
- examples/02-category/_layouts/home.html
|
90
|
+
- examples/02-category/_posts/2016-10-27-welcome-to-jekyll-paginate-v2.md
|
91
|
+
- examples/02-category/about.md
|
92
|
+
- examples/02-category/cars/_posts/2016-10-18-Porsche-918-Spyder.md
|
93
|
+
- examples/02-category/cars/_posts/2016-10-19-Porsche-964.md
|
94
|
+
- examples/02-category/cars/_posts/2016-10-20-porsche-911-gt3.md
|
95
|
+
- examples/02-category/cars/_posts/2016-10-21-porsche-911.md
|
96
|
+
- examples/02-category/cars/_posts/2016-10-22-porsche-962.md
|
97
|
+
- examples/02-category/cars/_posts/2016-10-23-Toyota-GT-One.md
|
98
|
+
- examples/02-category/cars/_posts/2016-10-24-Mercedes-Benz-CLK-GTR.md
|
99
|
+
- examples/02-category/cars/_posts/2016-10-25-rolls-royce-silver-ghost.md
|
100
|
+
- examples/02-category/categories/byname.md
|
101
|
+
- examples/02-category/categories/porsche.md
|
102
|
+
- examples/02-category/index.md
|
103
|
+
- examples/02-category/toyota/index.md
|
104
|
+
- examples/03-tags/Gemfile
|
105
|
+
- examples/03-tags/README.md
|
106
|
+
- examples/03-tags/_config.yml
|
107
|
+
- examples/03-tags/_includes/header.html
|
108
|
+
- examples/03-tags/_layouts/home.html
|
109
|
+
- examples/03-tags/_layouts/post.html
|
110
|
+
- examples/03-tags/biography/_posts/2016-10-27-born-to-run.md
|
111
|
+
- examples/03-tags/biography/_posts/2016-10-27-forty-autumns.md
|
112
|
+
- examples/03-tags/biography/_posts/2016-10-27-life-in-questions-a.md
|
113
|
+
- examples/03-tags/biography/_posts/2016-10-27-not-dead-yet.md
|
114
|
+
- examples/03-tags/biography/_posts/2016-10-27-princess-diarist-the.md
|
115
|
+
- examples/03-tags/biography/_posts/2016-10-27-when-breath-becomes-air.md
|
116
|
+
- examples/03-tags/biography/biography-musicians.md
|
117
|
+
- examples/03-tags/biography/biography.md
|
118
|
+
- examples/03-tags/blog/_posts/2016-09-30-welcome-to-jekyll-paginate-v2.md
|
119
|
+
- examples/03-tags/byisbn.md
|
120
|
+
- examples/03-tags/fantasy/_posts/2016-10-27-harry-potter-deathly-hallows.md
|
121
|
+
- examples/03-tags/fantasy/_posts/2016-10-27-harry-potter-philosophers-stone.md
|
122
|
+
- examples/03-tags/fantasy/_posts/2016-10-27-mistborn-trilogy.md
|
123
|
+
- examples/03-tags/fantasy/_posts/2016-10-27-ready-player-one.md
|
124
|
+
- examples/03-tags/fantasy/_posts/2016-10-27-sword-of-destiny.md
|
125
|
+
- examples/03-tags/fantasy/_posts/2016-10-27-terry-pratchet-diary-2017.md
|
126
|
+
- examples/03-tags/index.md
|
127
|
+
- examples/03-tags/romance/_posts/2016-10-27-breath-of-snow-and-ashes-a.md
|
128
|
+
- examples/03-tags/romance/_posts/2016-10-27-dressmaker-the.md
|
129
|
+
- examples/03-tags/romance/_posts/2016-10-27-fiery-cross-the.md
|
130
|
+
- examples/03-tags/romance/_posts/2016-10-27-it-ends-with-us.md
|
131
|
+
- examples/03-tags/romance/_posts/2016-10-27-outlander-novel.md
|
132
|
+
- examples/03-tags/romance/_posts/2016-10-27-virgins-outlander-short-story.md
|
133
|
+
- examples/03-tags/romance/romance-historical.md
|
134
|
+
- examples/03-tags/tags/contemporary.md
|
135
|
+
- examples/03-tags/tags/fantasy.md
|
136
|
+
- examples/03-tags/tags/sci-fi.md
|
137
|
+
- examples/README.md
|
138
|
+
- examples/img/01-example-screenshot-main.png
|
139
|
+
- examples/img/02-example-screenshot-main.png
|
140
|
+
- examples/img/03-example-screenshot-main.png
|
70
141
|
- jekyll-paginate-v2.gemspec
|
71
142
|
- lib/jekyll-paginate-v2.rb
|
72
143
|
- lib/jekyll-paginate-v2/compatibilityUtils.rb
|
73
144
|
- lib/jekyll-paginate-v2/defaults.rb
|
74
145
|
- lib/jekyll-paginate-v2/paginationGenerator.rb
|
75
146
|
- lib/jekyll-paginate-v2/paginationModel.rb
|
147
|
+
- lib/jekyll-paginate-v2/paginationPage.rb
|
76
148
|
- lib/jekyll-paginate-v2/paginator.rb
|
77
149
|
- lib/jekyll-paginate-v2/utils.rb
|
78
150
|
- lib/jekyll-paginate-v2/version.rb
|