fenton-jekyll-boilerplate 0.0.1 → 0.0.4
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/_plugins/article_paging.rb +223 -0
- data/_plugins/breadcrumbs.rb +28 -1
- data/favicon.ico +0 -0
- data/robots.txt +5 -0
- metadata +4 -11
- data/_plugins/breadcrumbs/breadcrumb_item.rb +0 -29
- data/_plugins/jekyll-paginate/pager.rb +0 -141
- data/_plugins/jekyll-paginate/pagination.rb +0 -85
- data/_plugins/paging.rb +0 -7
- data/articles/index.html +0 -70
- data/feed/atom.xml +0 -39
- data/search.json +0 -38
- data/sitemap/authors.xml +0 -15
- data/sitemap/pages.xml +0 -15
- data/sitemap/posts.xml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af30c302bcf50fae1383a74f61613dc3726292676d0cec2fab01e0d70219bd15
|
4
|
+
data.tar.gz: e112fc85ae75e903f15942681485fca1bb86c9abf39e7c0da76aec06e05ffbdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fbf9ad896fdd6cd5040abaaab5f635d9907e7ffec5e03908daae431b2c8f5ca61681930b5a00040158e456eadf1364ea9f3f6bf76e6276c5cf3cf4d3cb95c48
|
7
|
+
data.tar.gz: 76eb029b5839ffb4c5f334ae32a8b0b0e3e2fc79253595e468eb75fc597825474b2b172a95484b8f55952e943458999ac0ea28fd3e6321ecb0003f7d8d98c3ad
|
@@ -0,0 +1,223 @@
|
|
1
|
+
module Paginate
|
2
|
+
class Pagination < Jekyll::Generator
|
3
|
+
# This generator is safe from arbitrary code execution.
|
4
|
+
safe true
|
5
|
+
|
6
|
+
# This generator should be passive with regard to its execution
|
7
|
+
priority :lowest
|
8
|
+
|
9
|
+
# Generate paginated pages if necessary.
|
10
|
+
#
|
11
|
+
# site - The Site.
|
12
|
+
#
|
13
|
+
# Returns nothing.
|
14
|
+
def generate(site)
|
15
|
+
if Pager.pagination_enabled?(site)
|
16
|
+
if template = self.class.template_page(site)
|
17
|
+
paginate(site, template)
|
18
|
+
else
|
19
|
+
Jekyll.logger.warn "Pagination:", "Pagination is enabled, but I couldn't find " +
|
20
|
+
"an index.html page to use as the pagination template. Skipping pagination."
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Paginates the blog's posts. Renders the index.html file into paginated
|
26
|
+
# directories, e.g.: page2/index.html, page3/index.html, etc and adds more
|
27
|
+
# site-wide data.
|
28
|
+
#
|
29
|
+
# site - The Site.
|
30
|
+
# page - The index.html Page that requires pagination.
|
31
|
+
#
|
32
|
+
# {"paginator" => { "page" => <Number>,
|
33
|
+
# "per_page" => <Number>,
|
34
|
+
# "posts" => [<Post>],
|
35
|
+
# "total_posts" => <Number>,
|
36
|
+
# "total_pages" => <Number>,
|
37
|
+
# "previous_page" => <Number>,
|
38
|
+
# "next_page" => <Number> }}
|
39
|
+
def paginate(site, page)
|
40
|
+
all_posts = site.site_payload['site']['posts'].reject { |post| post['hidden'] }
|
41
|
+
pages = Pager.calculate_pages(all_posts, site.config['page_size'].to_i)
|
42
|
+
(1..pages).each do |num_page|
|
43
|
+
pager = Pager.new(site, num_page, all_posts, pages)
|
44
|
+
if num_page > 1
|
45
|
+
newpage = Jekyll::Page.new(site, site.source, page.dir, page.name)
|
46
|
+
newpage.pager = pager
|
47
|
+
newpage.dir = Pager.paginate_path(site, num_page)
|
48
|
+
site.pages << newpage
|
49
|
+
else
|
50
|
+
page.pager = pager
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Static: Fetch the URL of the template page. Used to determine the
|
56
|
+
# path to the first pager in the series.
|
57
|
+
#
|
58
|
+
# site - the Jekyll::Site object
|
59
|
+
#
|
60
|
+
# Returns the url of the template page
|
61
|
+
def self.first_page_url(site)
|
62
|
+
if page = Pagination.template_page(site)
|
63
|
+
page.url
|
64
|
+
else
|
65
|
+
nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Public: Find the Jekyll::Page which will act as the pager template
|
70
|
+
#
|
71
|
+
# site - the Jekyll::Site object
|
72
|
+
#
|
73
|
+
# Returns the Jekyll::Page which will act as the pager template
|
74
|
+
def self.template_page(site)
|
75
|
+
site.pages.select do |page|
|
76
|
+
Pager.pagination_candidate?(site.config, page)
|
77
|
+
end.sort do |one, two|
|
78
|
+
two.path.size <=> one.path.size
|
79
|
+
end.first
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
module Paginate
|
86
|
+
class Pager
|
87
|
+
attr_reader :page, :per_page, :posts, :total_posts, :total_pages,
|
88
|
+
:previous_page, :previous_page_path, :next_page, :next_page_path
|
89
|
+
|
90
|
+
# Calculate the number of pages.
|
91
|
+
#
|
92
|
+
# all_posts - The Array of all Posts.
|
93
|
+
# per_page - The Integer of entries per page.
|
94
|
+
#
|
95
|
+
# Returns the Integer number of pages.
|
96
|
+
def self.calculate_pages(all_posts, per_page)
|
97
|
+
(all_posts.size.to_f / per_page.to_i).ceil
|
98
|
+
end
|
99
|
+
|
100
|
+
# Determine if pagination is enabled the site.
|
101
|
+
#
|
102
|
+
# site - the Jekyll::Site object
|
103
|
+
#
|
104
|
+
# Returns true if pagination is enabled, false otherwise.
|
105
|
+
def self.pagination_enabled?(site)
|
106
|
+
!site.config['page_size'].nil? &&
|
107
|
+
site.pages.size > 0
|
108
|
+
end
|
109
|
+
|
110
|
+
# Static: Determine if a page is a possible candidate to be a template page.
|
111
|
+
# Page's name must be `index.html` and exist in any of the directories
|
112
|
+
# between the site source and `paginate_path`.
|
113
|
+
#
|
114
|
+
# config - the site configuration hash
|
115
|
+
# page - the Jekyll::Page about which we're inquiring
|
116
|
+
#
|
117
|
+
# Returns true if the
|
118
|
+
def self.pagination_candidate?(config, page)
|
119
|
+
page_dir = File.dirname(File.expand_path(remove_leading_slash(page.path), config['source']))
|
120
|
+
paginate_path = remove_leading_slash(config['paginate_path'])
|
121
|
+
paginate_path = File.expand_path(paginate_path, config['source'])
|
122
|
+
page.name == 'index.html' &&
|
123
|
+
in_hierarchy(config['source'], page_dir, File.dirname(paginate_path))
|
124
|
+
end
|
125
|
+
|
126
|
+
# Determine if the subdirectories of the two paths are the same relative to source
|
127
|
+
#
|
128
|
+
# source - the site source
|
129
|
+
# page_dir - the directory of the Jekyll::Page
|
130
|
+
# paginate_path - the absolute paginate path (from root of FS)
|
131
|
+
#
|
132
|
+
# Returns whether the subdirectories are the same relative to source
|
133
|
+
def self.in_hierarchy(source, page_dir, paginate_path)
|
134
|
+
return false if paginate_path == File.dirname(paginate_path)
|
135
|
+
return false if paginate_path == Pathname.new(source).parent
|
136
|
+
page_dir == paginate_path ||
|
137
|
+
in_hierarchy(source, page_dir, File.dirname(paginate_path))
|
138
|
+
end
|
139
|
+
|
140
|
+
# Static: Return the pagination path of the page
|
141
|
+
#
|
142
|
+
# site - the Jekyll::Site object
|
143
|
+
# num_page - the pagination page number
|
144
|
+
#
|
145
|
+
# Returns the pagination path as a string
|
146
|
+
def self.paginate_path(site, num_page)
|
147
|
+
return nil if num_page.nil?
|
148
|
+
return Pagination.first_page_url(site) if num_page <= 1
|
149
|
+
format = site.config['paginate_path']
|
150
|
+
if format.include?(":num")
|
151
|
+
format = format.sub(':num', num_page.to_s)
|
152
|
+
else
|
153
|
+
raise ArgumentError.new("Invalid pagination path: '#{format}'. It must include ':num'.")
|
154
|
+
end
|
155
|
+
ensure_leading_slash(format)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Static: Return a String version of the input which has a leading slash.
|
159
|
+
# If the input already has a forward slash in position zero, it will be
|
160
|
+
# returned unchanged.
|
161
|
+
#
|
162
|
+
# path - a String path
|
163
|
+
#
|
164
|
+
# Returns the path with a leading slash
|
165
|
+
def self.ensure_leading_slash(path)
|
166
|
+
path[0..0] == "/" ? path : "/#{path}"
|
167
|
+
end
|
168
|
+
|
169
|
+
# Static: Return a String version of the input without a leading slash.
|
170
|
+
#
|
171
|
+
# path - a String path
|
172
|
+
#
|
173
|
+
# Returns the input without the leading slash
|
174
|
+
def self.remove_leading_slash(path)
|
175
|
+
ensure_leading_slash(path)[1..-1]
|
176
|
+
end
|
177
|
+
|
178
|
+
# Initialize a new Pager.
|
179
|
+
#
|
180
|
+
# site - the Jekyll::Site object
|
181
|
+
# page - The Integer page number.
|
182
|
+
# all_posts - The Array of all the site's Posts.
|
183
|
+
# num_pages - The Integer number of pages or nil if you'd like the number
|
184
|
+
# of pages calculated.
|
185
|
+
def initialize(site, page, all_posts, num_pages = nil)
|
186
|
+
@page = page
|
187
|
+
@per_page = site.config['page_size'].to_i
|
188
|
+
@total_pages = num_pages || Pager.calculate_pages(all_posts, @per_page)
|
189
|
+
|
190
|
+
if @page > @total_pages
|
191
|
+
raise RuntimeError, "page number can't be greater than total pages: #{@page} > #{@total_pages}"
|
192
|
+
end
|
193
|
+
|
194
|
+
init = (@page - 1) * @per_page
|
195
|
+
offset = (init + @per_page - 1) >= all_posts.size ? all_posts.size : (init + @per_page - 1)
|
196
|
+
|
197
|
+
@total_posts = all_posts.size
|
198
|
+
@posts = all_posts[init..offset]
|
199
|
+
@previous_page = @page != 1 ? @page - 1 : nil
|
200
|
+
@previous_page_path = Pager.paginate_path(site, @previous_page)
|
201
|
+
@next_page = @page != @total_pages ? @page + 1 : nil
|
202
|
+
@next_page_path = Pager.paginate_path(site, @next_page)
|
203
|
+
end
|
204
|
+
|
205
|
+
# Convert this Pager's data to a Hash suitable for use by Liquid.
|
206
|
+
#
|
207
|
+
# Returns the Hash representation of this Pager.
|
208
|
+
def to_liquid
|
209
|
+
{
|
210
|
+
'page' => page,
|
211
|
+
'per_page' => per_page,
|
212
|
+
'posts' => posts,
|
213
|
+
'total_posts' => total_posts,
|
214
|
+
'total_pages' => total_pages,
|
215
|
+
'previous_page' => previous_page,
|
216
|
+
'previous_page_path' => previous_page_path,
|
217
|
+
'next_page' => next_page,
|
218
|
+
'next_page_path' => next_page_path
|
219
|
+
}
|
220
|
+
end
|
221
|
+
|
222
|
+
end
|
223
|
+
end
|
data/_plugins/breadcrumbs.rb
CHANGED
@@ -1,4 +1,31 @@
|
|
1
|
-
|
1
|
+
module Jekyll
|
2
|
+
module Breadcrumbs
|
3
|
+
class BreadcrumbItem < Liquid::Drop
|
4
|
+
extend Forwardable
|
5
|
+
|
6
|
+
def initialize(side)
|
7
|
+
@side = side
|
8
|
+
end
|
9
|
+
|
10
|
+
def position
|
11
|
+
@side[:position]
|
12
|
+
end
|
13
|
+
|
14
|
+
def title
|
15
|
+
@side[:title]
|
16
|
+
end
|
17
|
+
|
18
|
+
def url
|
19
|
+
@side[:url]
|
20
|
+
end
|
21
|
+
|
22
|
+
def rootimage
|
23
|
+
@side[:root_image]
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
2
29
|
|
3
30
|
module Jekyll
|
4
31
|
module Breadcrumbs
|
data/favicon.ico
ADDED
Binary file
|
data/robots.txt
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fenton-jekyll-boilerplate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Fenton
|
@@ -62,15 +62,11 @@ files:
|
|
62
62
|
- _layouts/page.html
|
63
63
|
- _layouts/post.html
|
64
64
|
- _layouts/search.html
|
65
|
+
- _plugins/article_paging.rb
|
65
66
|
- _plugins/breadcrumbs.rb
|
66
|
-
- _plugins/breadcrumbs/breadcrumb_item.rb
|
67
|
-
- _plugins/jekyll-paginate/pager.rb
|
68
|
-
- _plugins/jekyll-paginate/pagination.rb
|
69
67
|
- _plugins/liquid_language.rb
|
70
68
|
- _plugins/liquid_regex.rb
|
71
69
|
- _plugins/markdown.rb
|
72
|
-
- _plugins/paging.rb
|
73
|
-
- articles/index.html
|
74
70
|
- assets/css/code.css
|
75
71
|
- assets/css/main.css
|
76
72
|
- assets/css/vars.css
|
@@ -98,12 +94,9 @@ files:
|
|
98
94
|
- assets/js/modules/string.js
|
99
95
|
- assets/js/search.js
|
100
96
|
- assets/svg/down.svg
|
101
|
-
-
|
102
|
-
-
|
97
|
+
- favicon.ico
|
98
|
+
- robots.txt
|
103
99
|
- sitemap.xml
|
104
|
-
- sitemap/authors.xml
|
105
|
-
- sitemap/pages.xml
|
106
|
-
- sitemap/posts.xml
|
107
100
|
homepage: https://jekyll.stevefenton.co.uk/
|
108
101
|
licenses:
|
109
102
|
- Apache-2.0
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Jekyll
|
2
|
-
module Breadcrumbs
|
3
|
-
class BreadcrumbItem < Liquid::Drop
|
4
|
-
extend Forwardable
|
5
|
-
|
6
|
-
def initialize(side)
|
7
|
-
@side = side
|
8
|
-
end
|
9
|
-
|
10
|
-
def position
|
11
|
-
@side[:position]
|
12
|
-
end
|
13
|
-
|
14
|
-
def title
|
15
|
-
@side[:title]
|
16
|
-
end
|
17
|
-
|
18
|
-
def url
|
19
|
-
@side[:url]
|
20
|
-
end
|
21
|
-
|
22
|
-
def rootimage
|
23
|
-
@side[:root_image]
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
@@ -1,141 +0,0 @@
|
|
1
|
-
module Jekyll
|
2
|
-
module Paginate
|
3
|
-
class Pager
|
4
|
-
attr_reader :page, :per_page, :posts, :total_posts, :total_pages,
|
5
|
-
:previous_page, :previous_page_path, :next_page, :next_page_path
|
6
|
-
|
7
|
-
# Calculate the number of pages.
|
8
|
-
#
|
9
|
-
# all_posts - The Array of all Posts.
|
10
|
-
# per_page - The Integer of entries per page.
|
11
|
-
#
|
12
|
-
# Returns the Integer number of pages.
|
13
|
-
def self.calculate_pages(all_posts, per_page)
|
14
|
-
(all_posts.size.to_f / per_page.to_i).ceil
|
15
|
-
end
|
16
|
-
|
17
|
-
# Determine if pagination is enabled the site.
|
18
|
-
#
|
19
|
-
# site - the Jekyll::Site object
|
20
|
-
#
|
21
|
-
# Returns true if pagination is enabled, false otherwise.
|
22
|
-
def self.pagination_enabled?(site)
|
23
|
-
!site.config['paginate'].nil? &&
|
24
|
-
site.pages.size > 0
|
25
|
-
end
|
26
|
-
|
27
|
-
# Static: Determine if a page is a possible candidate to be a template page.
|
28
|
-
# Page's name must be `index.html` and exist in any of the directories
|
29
|
-
# between the site source and `paginate_path`.
|
30
|
-
#
|
31
|
-
# config - the site configuration hash
|
32
|
-
# page - the Jekyll::Page about which we're inquiring
|
33
|
-
#
|
34
|
-
# Returns true if the
|
35
|
-
def self.pagination_candidate?(config, page)
|
36
|
-
page_dir = File.dirname(File.expand_path(remove_leading_slash(page.path), config['source']))
|
37
|
-
paginate_path = remove_leading_slash(config['paginate_path'])
|
38
|
-
paginate_path = File.expand_path(paginate_path, config['source'])
|
39
|
-
page.name == 'index.html' &&
|
40
|
-
in_hierarchy(config['source'], page_dir, File.dirname(paginate_path))
|
41
|
-
end
|
42
|
-
|
43
|
-
# Determine if the subdirectories of the two paths are the same relative to source
|
44
|
-
#
|
45
|
-
# source - the site source
|
46
|
-
# page_dir - the directory of the Jekyll::Page
|
47
|
-
# paginate_path - the absolute paginate path (from root of FS)
|
48
|
-
#
|
49
|
-
# Returns whether the subdirectories are the same relative to source
|
50
|
-
def self.in_hierarchy(source, page_dir, paginate_path)
|
51
|
-
return false if paginate_path == File.dirname(paginate_path)
|
52
|
-
return false if paginate_path == Pathname.new(source).parent
|
53
|
-
page_dir == paginate_path ||
|
54
|
-
in_hierarchy(source, page_dir, File.dirname(paginate_path))
|
55
|
-
end
|
56
|
-
|
57
|
-
# Static: Return the pagination path of the page
|
58
|
-
#
|
59
|
-
# site - the Jekyll::Site object
|
60
|
-
# num_page - the pagination page number
|
61
|
-
#
|
62
|
-
# Returns the pagination path as a string
|
63
|
-
def self.paginate_path(site, num_page)
|
64
|
-
return nil if num_page.nil?
|
65
|
-
return Pagination.first_page_url(site) if num_page <= 1
|
66
|
-
format = site.config['paginate_path']
|
67
|
-
if format.include?(":num")
|
68
|
-
format = format.sub(':num', num_page.to_s)
|
69
|
-
else
|
70
|
-
raise ArgumentError.new("Invalid pagination path: '#{format}'. It must include ':num'.")
|
71
|
-
end
|
72
|
-
ensure_leading_slash(format)
|
73
|
-
end
|
74
|
-
|
75
|
-
# Static: Return a String version of the input which has a leading slash.
|
76
|
-
# If the input already has a forward slash in position zero, it will be
|
77
|
-
# returned unchanged.
|
78
|
-
#
|
79
|
-
# path - a String path
|
80
|
-
#
|
81
|
-
# Returns the path with a leading slash
|
82
|
-
def self.ensure_leading_slash(path)
|
83
|
-
path[0..0] == "/" ? path : "/#{path}"
|
84
|
-
end
|
85
|
-
|
86
|
-
# Static: Return a String version of the input without a leading slash.
|
87
|
-
#
|
88
|
-
# path - a String path
|
89
|
-
#
|
90
|
-
# Returns the input without the leading slash
|
91
|
-
def self.remove_leading_slash(path)
|
92
|
-
ensure_leading_slash(path)[1..-1]
|
93
|
-
end
|
94
|
-
|
95
|
-
# Initialize a new Pager.
|
96
|
-
#
|
97
|
-
# site - the Jekyll::Site object
|
98
|
-
# page - The Integer page number.
|
99
|
-
# all_posts - The Array of all the site's Posts.
|
100
|
-
# num_pages - The Integer number of pages or nil if you'd like the number
|
101
|
-
# of pages calculated.
|
102
|
-
def initialize(site, page, all_posts, num_pages = nil)
|
103
|
-
@page = page
|
104
|
-
@per_page = site.config['paginate'].to_i
|
105
|
-
@total_pages = num_pages || Pager.calculate_pages(all_posts, @per_page)
|
106
|
-
|
107
|
-
if @page > @total_pages
|
108
|
-
raise RuntimeError, "page number can't be greater than total pages: #{@page} > #{@total_pages}"
|
109
|
-
end
|
110
|
-
|
111
|
-
init = (@page - 1) * @per_page
|
112
|
-
offset = (init + @per_page - 1) >= all_posts.size ? all_posts.size : (init + @per_page - 1)
|
113
|
-
|
114
|
-
@total_posts = all_posts.size
|
115
|
-
@posts = all_posts[init..offset]
|
116
|
-
@previous_page = @page != 1 ? @page - 1 : nil
|
117
|
-
@previous_page_path = Pager.paginate_path(site, @previous_page)
|
118
|
-
@next_page = @page != @total_pages ? @page + 1 : nil
|
119
|
-
@next_page_path = Pager.paginate_path(site, @next_page)
|
120
|
-
end
|
121
|
-
|
122
|
-
# Convert this Pager's data to a Hash suitable for use by Liquid.
|
123
|
-
#
|
124
|
-
# Returns the Hash representation of this Pager.
|
125
|
-
def to_liquid
|
126
|
-
{
|
127
|
-
'page' => page,
|
128
|
-
'per_page' => per_page,
|
129
|
-
'posts' => posts,
|
130
|
-
'total_posts' => total_posts,
|
131
|
-
'total_pages' => total_pages,
|
132
|
-
'previous_page' => previous_page,
|
133
|
-
'previous_page_path' => previous_page_path,
|
134
|
-
'next_page' => next_page,
|
135
|
-
'next_page_path' => next_page_path
|
136
|
-
}
|
137
|
-
end
|
138
|
-
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
module Jekyll
|
2
|
-
module Paginate
|
3
|
-
class Pagination < Generator
|
4
|
-
# This generator is safe from arbitrary code execution.
|
5
|
-
safe true
|
6
|
-
|
7
|
-
# This generator should be passive with regard to its execution
|
8
|
-
priority :lowest
|
9
|
-
|
10
|
-
# Generate paginated pages if necessary.
|
11
|
-
#
|
12
|
-
# site - The Site.
|
13
|
-
#
|
14
|
-
# Returns nothing.
|
15
|
-
def generate(site)
|
16
|
-
if Pager.pagination_enabled?(site)
|
17
|
-
if template = self.class.template_page(site)
|
18
|
-
paginate(site, template)
|
19
|
-
else
|
20
|
-
Jekyll.logger.warn "Pagination:", "Pagination is enabled, but I couldn't find " +
|
21
|
-
"an index.html page to use as the pagination template. Skipping pagination."
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Paginates the blog's posts. Renders the index.html file into paginated
|
27
|
-
# directories, e.g.: page2/index.html, page3/index.html, etc and adds more
|
28
|
-
# site-wide data.
|
29
|
-
#
|
30
|
-
# site - The Site.
|
31
|
-
# page - The index.html Page that requires pagination.
|
32
|
-
#
|
33
|
-
# {"paginator" => { "page" => <Number>,
|
34
|
-
# "per_page" => <Number>,
|
35
|
-
# "posts" => [<Post>],
|
36
|
-
# "total_posts" => <Number>,
|
37
|
-
# "total_pages" => <Number>,
|
38
|
-
# "previous_page" => <Number>,
|
39
|
-
# "next_page" => <Number> }}
|
40
|
-
def paginate(site, page)
|
41
|
-
all_posts = site.site_payload['site']['posts'].reject { |post| post['hidden'] }
|
42
|
-
pages = Pager.calculate_pages(all_posts, site.config['paginate'].to_i)
|
43
|
-
(1..pages).each do |num_page|
|
44
|
-
pager = Pager.new(site, num_page, all_posts, pages)
|
45
|
-
if num_page > 1
|
46
|
-
newpage = Page.new(site, site.source, page.dir, page.name)
|
47
|
-
newpage.pager = pager
|
48
|
-
newpage.dir = Pager.paginate_path(site, num_page)
|
49
|
-
site.pages << newpage
|
50
|
-
else
|
51
|
-
page.pager = pager
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# Static: Fetch the URL of the template page. Used to determine the
|
57
|
-
# path to the first pager in the series.
|
58
|
-
#
|
59
|
-
# site - the Jekyll::Site object
|
60
|
-
#
|
61
|
-
# Returns the url of the template page
|
62
|
-
def self.first_page_url(site)
|
63
|
-
if page = Pagination.template_page(site)
|
64
|
-
page.url
|
65
|
-
else
|
66
|
-
nil
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
# Public: Find the Jekyll::Page which will act as the pager template
|
71
|
-
#
|
72
|
-
# site - the Jekyll::Site object
|
73
|
-
#
|
74
|
-
# Returns the Jekyll::Page which will act as the pager template
|
75
|
-
def self.template_page(site)
|
76
|
-
site.pages.select do |page|
|
77
|
-
Pager.pagination_candidate?(site.config, page)
|
78
|
-
end.sort do |one, two|
|
79
|
-
two.path.size <=> one.path.size
|
80
|
-
end.first
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
data/_plugins/paging.rb
DELETED
data/articles/index.html
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: default
|
3
|
-
title: Articles
|
4
|
-
date: 2022-09-06
|
5
|
-
authors: steve-fenton
|
6
|
-
description: Articles about Jekyll Boilerplate.
|
7
|
-
nav-title: Articles
|
8
|
-
nav-level: 1
|
9
|
-
nav-order: 3000
|
10
|
-
published: true
|
11
|
-
nav-sitemap: true
|
12
|
-
nav-search: true
|
13
|
-
# Don't use permalink on list pages
|
14
|
-
---
|
15
|
-
<main id="site-main">
|
16
|
-
<h1>{{ 'articles' | t: 'title' }}</h1>
|
17
|
-
{%- if site.paginate %}
|
18
|
-
{% assign posts = paginator.posts %}
|
19
|
-
{% else %}
|
20
|
-
{% assign posts = site.posts %}
|
21
|
-
{% endif %}
|
22
|
-
{%- if posts.size > 0 -%}
|
23
|
-
<ul class="post-list">
|
24
|
-
{%- assign date_format = site.date_format | default: "%b %-d, %Y" -%}
|
25
|
-
{%- for post in posts -%}
|
26
|
-
<li class="list-item" data-destination="{{ post.url | relative_url }}">
|
27
|
-
{%- if post.banner-image -%}
|
28
|
-
<img src="{{ post.banner-image }}" alt="{{ post.banner-image-alt }}" {% unless forloop.first %}loading="lazy"{% endunless %} />
|
29
|
-
{%- endif -%}
|
30
|
-
<div class="list-item-content">
|
31
|
-
<span class="post-meta">{{ post.date | date: date_format }}</span>
|
32
|
-
<h2>
|
33
|
-
<a href="{{ post.url | relative_url }}">
|
34
|
-
{{ post.title | escape }}
|
35
|
-
</a>
|
36
|
-
</h2>
|
37
|
-
{%- if site.show_excerpts -%}
|
38
|
-
{{ post.excerpt | default: post.description }}
|
39
|
-
{%- endif -%}
|
40
|
-
</div>
|
41
|
-
</li>
|
42
|
-
{%- endfor -%}
|
43
|
-
</ul>
|
44
|
-
|
45
|
-
{% if paginator.total_pages > 1 %}
|
46
|
-
<div class="post-paging">
|
47
|
-
{% if paginator.previous_page %}
|
48
|
-
<a href="{{ paginator.previous_page_path | relative_url }}">« {{ 'articles' | t: 'previous' }}</a>
|
49
|
-
{% else %}
|
50
|
-
<span>« {{ 'articles' | t: 'previous' }}</span>
|
51
|
-
{% endif %}
|
52
|
-
|
53
|
-
{% for page in (1..paginator.total_pages) %}
|
54
|
-
{% if page == paginator.page %}
|
55
|
-
<em>{{ page }}</em>
|
56
|
-
{% else %}
|
57
|
-
{% assign page_one_link = '/' | append: site.paginate_page | append: '1' | append: '/' %}
|
58
|
-
<a href="{{ site.paginate_path | relative_url | replace: ':num', page | replace: page_one_link, '/' }}">{{ page }}</a>
|
59
|
-
{% endif %}
|
60
|
-
{% endfor %}
|
61
|
-
|
62
|
-
{% if paginator.next_page %}
|
63
|
-
<a href="{{ paginator.next_page_path | relative_url }}">{{ 'articles' | t: 'next' }} »</a>
|
64
|
-
{% else %}
|
65
|
-
<span>{{ 'articles' | t: 'next' }} »</span>
|
66
|
-
{% endif %}
|
67
|
-
</div>
|
68
|
-
{% endif %}
|
69
|
-
{%- endif -%}
|
70
|
-
</main>
|
data/feed/atom.xml
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: null
|
3
|
-
---
|
4
|
-
<?xml version="1.0" encoding="utf-8"?>
|
5
|
-
<feed xmlns="http://www.w3.org/2005/Atom">
|
6
|
-
<title>{{ site.title }}</title>
|
7
|
-
<subtitle>{{ site.description }}</subtitle>
|
8
|
-
<link href="{{ site.url }}{{ '/feed/atom.xml' | prepend: site.baseurl}}" rel="self" />
|
9
|
-
<link href="{{ site.url }}" />
|
10
|
-
<id>{{ site.url }}{{ '/feed/atom.xml' | prepend: site.baseurl}}</id>
|
11
|
-
|
12
|
-
{%- for post in site.posts limit:1 %}
|
13
|
-
<updated>{{ post.date | date_to_xmlschema }}</updated>
|
14
|
-
{%- endfor %}
|
15
|
-
|
16
|
-
{%- for post in site.posts limit:20 %}
|
17
|
-
<entry>
|
18
|
-
<title>{{ post.title }}</title>
|
19
|
-
<link href="{{site.url}}{{ post.url | prepend: site.baseurl }}" />
|
20
|
-
<id>{{ post.url | prepend: site.url }}</id>
|
21
|
-
<published>{{ post.date | date_to_xmlschema }}</published>
|
22
|
-
<updated>{{ post.date | date_to_xmlschema }}</updated>
|
23
|
-
<summary>{{ post.excerpt | default: post.description }}</summary>
|
24
|
-
<author>
|
25
|
-
{%- assign authordata = '' | split:'@' %}
|
26
|
-
{%- for author in site.authors %}
|
27
|
-
{%- if post.authors contains author.username or author.username == post.authors %}
|
28
|
-
{%- capture data %}
|
29
|
-
<name>{{ author.name }}</name>
|
30
|
-
<email>{{ author.email }}</email>
|
31
|
-
{%- endcapture %}
|
32
|
-
{%- assign authordata = authordata | push: data %}
|
33
|
-
{%- endif %}
|
34
|
-
{%- endfor %}
|
35
|
-
{{- authordata | array_to_sentence_string }}
|
36
|
-
</author>
|
37
|
-
</entry>
|
38
|
-
{%- endfor %}
|
39
|
-
</feed>
|
data/search.json
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: null
|
3
|
-
---
|
4
|
-
{% assign pages = site.pages | where: 'nav-search', 'true' %}
|
5
|
-
{% assign posts = site.posts | where: 'nav-search', 'true' %}
|
6
|
-
{% assign authors = site.authors | where: 'nav-search', 'true' %}
|
7
|
-
[
|
8
|
-
{% for page in pages %}{
|
9
|
-
"title" : "{{ page.title | escape }}",
|
10
|
-
"category" : "{{ page.category }}",
|
11
|
-
"tags" : "{{ page.tags | join: ' ' }} {{page.keywords}}",
|
12
|
-
"url" : "{{ site.baseurl }}{{ page.url }}",
|
13
|
-
"date" : "{{ page.date }}"
|
14
|
-
}
|
15
|
-
|
16
|
-
{%- if authors.size > 0 %},{% endif %}
|
17
|
-
{%- endfor %}
|
18
|
-
{%- for author in authors %}{
|
19
|
-
"title" : "{{ author.name | escape }}",
|
20
|
-
"category" : "{{ author.category }}",
|
21
|
-
"tags" : "{{ page.tags | join: ' ' }} {{page.keywords}}",
|
22
|
-
"url" : "{{ site.baseurl }}{{ author.url }}",
|
23
|
-
"date" : "{{ author.date }}"
|
24
|
-
}
|
25
|
-
|
26
|
-
{%- if posts.size > 0 %},{% endif %}
|
27
|
-
{%- endfor %}
|
28
|
-
{%- for post in posts %}{
|
29
|
-
"title" : "{{ post.title | escape }}",
|
30
|
-
"category" : "{{ post.category }}",
|
31
|
-
"tags" : "{{ page.tags | join: ' ' }} {{page.keywords}}",
|
32
|
-
"url" : "{{ site.baseurl }}{{ post.url }}",
|
33
|
-
"date" : "{{ post.date }}"
|
34
|
-
}
|
35
|
-
{%- unless forloop.last %},{% endunless %}
|
36
|
-
{%- endfor %}
|
37
|
-
]
|
38
|
-
|
data/sitemap/authors.xml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: null
|
3
|
-
---
|
4
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
5
|
-
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
6
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
7
|
-
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
|
8
|
-
http://www.sitemaps.org/schemas/sitemap/0.9.xsd">
|
9
|
-
{%- assign authors = site.authors | where: 'nav-sitemap','true' %}
|
10
|
-
{%- for author in authors %} <url>
|
11
|
-
<loc>{{ site.url }}{{ author.url }}</loc>
|
12
|
-
<lastmod>{{ author.date }}</lastmod>
|
13
|
-
</url>
|
14
|
-
{%- endfor %}
|
15
|
-
</urlset>
|
data/sitemap/pages.xml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: null
|
3
|
-
---
|
4
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
5
|
-
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
6
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
7
|
-
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
|
8
|
-
http://www.sitemaps.org/schemas/sitemap/0.9.xsd">
|
9
|
-
{%- assign pages = site.pages | where: 'nav-sitemap','true' %}
|
10
|
-
{% for page in pages %} <url>
|
11
|
-
<loc>{{ site.url }}{{ page.url }}</loc>
|
12
|
-
<lastmod>{{ page.date }}</lastmod>
|
13
|
-
</url>
|
14
|
-
{% endfor %}
|
15
|
-
</urlset>
|
data/sitemap/posts.xml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: null
|
3
|
-
---
|
4
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
5
|
-
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
6
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
7
|
-
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
|
8
|
-
http://www.sitemaps.org/schemas/sitemap/0.9.xsd">
|
9
|
-
{%- assign posts = site.posts | where: 'nav-sitemap','true' %}
|
10
|
-
{%- for post in posts %} <url>
|
11
|
-
<loc>{{ site.url }}{{ post.url }}</loc>
|
12
|
-
<lastmod>{{ post.date }}</lastmod>
|
13
|
-
</url>
|
14
|
-
{%- endfor %}
|
15
|
-
</urlset>
|