jekyll-paginate 1.0.0.rc1
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 +7 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/jekyll-paginate.gemspec +24 -0
- data/lib/jekyll-paginate.rb +8 -0
- data/lib/jekyll-paginate/pager.rb +137 -0
- data/lib/jekyll-paginate/pagination.rb +85 -0
- data/lib/jekyll-paginate/version.rb +5 -0
- data/script/bootstrap +3 -0
- data/script/cibuild +3 -0
- data/spec/pager_spec.rb +134 -0
- data/spec/pagination_spec.rb +0 -0
- data/spec/source/_posts/2014-05-20-blah.html +0 -0
- data/spec/source/_posts/2014-05-21-bleh.html +0 -0
- data/spec/source/_posts/2014-05-22-humor.html +0 -0
- data/spec/source/_posts/2014-05-23-hey-there.html +0 -0
- data/spec/source/_posts/2014-05-24-whateva.html +0 -0
- data/spec/source/_posts/2014-05-25-oh-yes.html +0 -0
- data/spec/source/contacts/index.html +2 -0
- data/spec/source/index.html +2 -0
- data/spec/spec_helper.rb +40 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0c5fb560a34bf2fd26ddfca7dc2ae33c2d923426
|
4
|
+
data.tar.gz: 9a52441aaa8bd179c48930cb67cb7696ced64170
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 94ef1f8b09e849fb5f1ca02bd22beca83b9e2bdf591c9efda28887ece8cc7333202fd2654987d67cc2f21fd896ffe4cd4625875fc549de524b32c241851f92fe
|
7
|
+
data.tar.gz: 1fb0f9a8f3fc038280b34fe69a4e468da5bbe5628314d12f96f53f47d1b11719c0b578633794dbb18bf7dbcfe52c3f3dbdf0181c3f353fb687918a8648ef7a0d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Parker Moore
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Jekyll::Generators::Pagination
|
2
|
+
|
3
|
+
Default pagination generator for Jekyll.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'jekyll-paginate'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install jekyll-paginate
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Once the gem is installed on your system, Jekyll will auto-require it. Just set the following configuration
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( http://github.com/jekyll/jekyll-paginate/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jekyll-paginate/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jekyll-paginate"
|
8
|
+
spec.version = Jekyll::Paginate::VERSION
|
9
|
+
spec.authors = ["Parker Moore"]
|
10
|
+
spec.email = ["parkrmoore@gmail.com"]
|
11
|
+
spec.summary = %q{Built-in Pagination Generator for Jekyll}
|
12
|
+
spec.homepage = "https://github.com/jekyll/jekyll-paginate"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "jekyll", "~> 2.0"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
@@ -0,0 +1,137 @@
|
|
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 Generators::Pagination.first_page_url(site) if num_page <= 1
|
66
|
+
format = site.config['paginate_path']
|
67
|
+
format = format.sub(':num', num_page.to_s)
|
68
|
+
ensure_leading_slash(format)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Static: Return a String version of the input which has a leading slash.
|
72
|
+
# If the input already has a forward slash in position zero, it will be
|
73
|
+
# returned unchanged.
|
74
|
+
#
|
75
|
+
# path - a String path
|
76
|
+
#
|
77
|
+
# Returns the path with a leading slash
|
78
|
+
def self.ensure_leading_slash(path)
|
79
|
+
path[0..0] == "/" ? path : "/#{path}"
|
80
|
+
end
|
81
|
+
|
82
|
+
# Static: Return a String version of the input without a leading slash.
|
83
|
+
#
|
84
|
+
# path - a String path
|
85
|
+
#
|
86
|
+
# Returns the input without the leading slash
|
87
|
+
def self.remove_leading_slash(path)
|
88
|
+
ensure_leading_slash(path)[1..-1]
|
89
|
+
end
|
90
|
+
|
91
|
+
# Initialize a new Pager.
|
92
|
+
#
|
93
|
+
# site - the Jekyll::Site object
|
94
|
+
# page - The Integer page number.
|
95
|
+
# all_posts - The Array of all the site's Posts.
|
96
|
+
# num_pages - The Integer number of pages or nil if you'd like the number
|
97
|
+
# of pages calculated.
|
98
|
+
def initialize(site, page, all_posts, num_pages = nil)
|
99
|
+
@page = page
|
100
|
+
@per_page = site.config['paginate'].to_i
|
101
|
+
@total_pages = num_pages || Pager.calculate_pages(all_posts, @per_page)
|
102
|
+
|
103
|
+
if @page > @total_pages
|
104
|
+
raise RuntimeError, "page number can't be greater than total pages: #{@page} > #{@total_pages}"
|
105
|
+
end
|
106
|
+
|
107
|
+
init = (@page - 1) * @per_page
|
108
|
+
offset = (init + @per_page - 1) >= all_posts.size ? all_posts.size : (init + @per_page - 1)
|
109
|
+
|
110
|
+
@total_posts = all_posts.size
|
111
|
+
@posts = all_posts[init..offset]
|
112
|
+
@previous_page = @page != 1 ? @page - 1 : nil
|
113
|
+
@previous_page_path = Pager.paginate_path(site, @previous_page)
|
114
|
+
@next_page = @page != @total_pages ? @page + 1 : nil
|
115
|
+
@next_page_path = Pager.paginate_path(site, @next_page)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Convert this Pager's data to a Hash suitable for use by Liquid.
|
119
|
+
#
|
120
|
+
# Returns the Hash representation of this Pager.
|
121
|
+
def to_liquid
|
122
|
+
{
|
123
|
+
'page' => page,
|
124
|
+
'per_page' => per_page,
|
125
|
+
'posts' => posts,
|
126
|
+
'total_posts' => total_posts,
|
127
|
+
'total_pages' => total_pages,
|
128
|
+
'previous_page' => previous_page,
|
129
|
+
'previous_page_path' => previous_page_path,
|
130
|
+
'next_page' => next_page,
|
131
|
+
'next_page_path' => next_page_path
|
132
|
+
}
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Generators
|
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 = 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']
|
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.new.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 template_page(site)
|
76
|
+
site.pages.dup.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/script/bootstrap
ADDED
data/script/cibuild
ADDED
data/spec/pager_spec.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe(Jekyll::Paginate::Pager) do
|
4
|
+
|
5
|
+
it "calculate number of pages" do
|
6
|
+
expect(described_class.calculate_pages([], '2')).to eql(0)
|
7
|
+
expect(described_class.calculate_pages([1], '2')).to eql(1)
|
8
|
+
expect(described_class.calculate_pages([1,2], '2')).to eql(1)
|
9
|
+
expect(described_class.calculate_pages([1,2,3], '2')).to eql(2)
|
10
|
+
expect(described_class.calculate_pages([1,2,3,4], '2')).to eql(2)
|
11
|
+
expect(described_class.calculate_pages([1,2,3,4,5], '2')).to eql(3)
|
12
|
+
end
|
13
|
+
|
14
|
+
context "with the default paginate_path" do
|
15
|
+
let(:site) { build_site }
|
16
|
+
|
17
|
+
it "determines the correct pagination path for each page" do
|
18
|
+
expect(described_class.paginate_path(site, 1)).to eql("/index.html")
|
19
|
+
expect(described_class.paginate_path(site, 2)).to eql("/page2")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with paginate_path set to a subdirectory with no index.html" do
|
24
|
+
let(:site) { build_site({'paginate_path' => '/blog/page-:num'}) }
|
25
|
+
|
26
|
+
it "determines the correct pagination path for each page" do
|
27
|
+
expect(described_class.paginate_path(site, 1)).to eql("/index.html")
|
28
|
+
expect(described_class.paginate_path(site, 2)).to eql("/blog/page-2")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "with paginate_path set to a subdirectory with no index.html with num pages being in subdirectories" do
|
33
|
+
let(:site) { build_site({'paginate_path' => '/blog/page/:num'}) }
|
34
|
+
|
35
|
+
it "determines the correct pagination path for each page" do
|
36
|
+
expect(described_class.paginate_path(site, 1)).to eql("/index.html")
|
37
|
+
expect(described_class.paginate_path(site, 2)).to eql("/blog/page/2")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "with paginate_path set to a subdirectory wherein an index.html exists" do
|
42
|
+
let(:site) { build_site({'paginate_path' => '/contacts/page:num'}) }
|
43
|
+
|
44
|
+
it "determines the correct pagination path for each page" do
|
45
|
+
expect(described_class.paginate_path(site, 1)).to eql("/contacts/index.html")
|
46
|
+
expect(described_class.paginate_path(site, 2)).to eql("/contacts/page2")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "with paginate_path set to a subdir wherein an index.html exists with pages in subdirs" do
|
51
|
+
let(:site) { build_site({'paginate_path' => '/contacts/page/:num'}) }
|
52
|
+
|
53
|
+
it "determines the correct pagination path for each page" do
|
54
|
+
expect(described_class.paginate_path(site, 1)).to eql("/contacts/index.html")
|
55
|
+
expect(described_class.paginate_path(site, 2)).to eql("/contacts/page/2")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "pagination disabled" do
|
60
|
+
let(:site) { build_site('paginate' => nil) }
|
61
|
+
|
62
|
+
it "report that pagination is disabled" do
|
63
|
+
expect(described_class.pagination_enabled?(site)).to be_false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "pagination enabled for 2" do
|
68
|
+
let(:site) { build_site('paginate' => 2) }
|
69
|
+
let(:posts) { site.posts }
|
70
|
+
|
71
|
+
it "report that pagination is enabled" do
|
72
|
+
expect(described_class.pagination_enabled?(site)).to be_true
|
73
|
+
end
|
74
|
+
|
75
|
+
context "with 4 posts" do
|
76
|
+
let(:posts) { site.posts[1..4] }
|
77
|
+
|
78
|
+
it "create first pager" do
|
79
|
+
pager = described_class.new(site, 1, posts)
|
80
|
+
expect(pager.posts.size).to eql(2)
|
81
|
+
expect(pager.total_pages).to eql(2)
|
82
|
+
expect(pager.previous_page).to be_nil
|
83
|
+
expect(pager.next_page).to eql(2)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "create second pager" do
|
87
|
+
pager = described_class.new(site, 2, posts)
|
88
|
+
expect(pager.posts.size).to eql(2)
|
89
|
+
expect(pager.total_pages).to eql(2)
|
90
|
+
expect(pager.previous_page).to eql(1)
|
91
|
+
expect(pager.next_page).to be_nil
|
92
|
+
end
|
93
|
+
|
94
|
+
it "not create third pager" do
|
95
|
+
expect { described_class.new(site, 3, posts) }.to raise_error
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
context "with 5 posts" do
|
101
|
+
let(:posts) { site.posts[1..5] }
|
102
|
+
|
103
|
+
it "create first pager" do
|
104
|
+
pager = described_class.new(site, 1, posts)
|
105
|
+
expect(pager.posts.size).to eql(2)
|
106
|
+
expect(pager.total_pages).to eql(3)
|
107
|
+
expect(pager.previous_page).to be_nil
|
108
|
+
expect(pager.next_page).to eql(2)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "create second pager" do
|
112
|
+
pager = described_class.new(site, 2, posts)
|
113
|
+
expect(pager.posts.size).to eql(2)
|
114
|
+
expect(pager.total_pages).to eql(3)
|
115
|
+
expect(pager.previous_page).to eql(1)
|
116
|
+
expect(pager.next_page).to eql(3)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "create third pager" do
|
120
|
+
pager = described_class.new(site, 3, posts)
|
121
|
+
expect(pager.posts.size).to eql(1)
|
122
|
+
expect(pager.total_pages).to eql(3)
|
123
|
+
expect(pager.previous_page).to eql(2)
|
124
|
+
expect(pager.next_page).to be_nil
|
125
|
+
end
|
126
|
+
|
127
|
+
it "not create fourth pager" do
|
128
|
+
expect { described_class.new(site, 4, posts) }.to raise_error(RuntimeError)
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'jekyll'
|
2
|
+
require File.expand_path("../lib/jekyll-paginate", File.dirname(__FILE__))
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
6
|
+
config.run_all_when_everything_filtered = true
|
7
|
+
config.filter_run :focus
|
8
|
+
config.order = 'random'
|
9
|
+
|
10
|
+
def test_dir(*subdirs)
|
11
|
+
File.join(File.dirname(__FILE__), *subdirs)
|
12
|
+
end
|
13
|
+
|
14
|
+
def dest_dir(*subdirs)
|
15
|
+
test_dir('dest', *subdirs)
|
16
|
+
end
|
17
|
+
|
18
|
+
def source_dir(*subdirs)
|
19
|
+
test_dir('source', *subdirs)
|
20
|
+
end
|
21
|
+
|
22
|
+
def build_configs(overrides, base_hash = Jekyll::Configuration::DEFAULTS)
|
23
|
+
Jekyll::Utils.deep_merge_hashes(base_hash, overrides)
|
24
|
+
end
|
25
|
+
|
26
|
+
def site_configuration(overrides = {})
|
27
|
+
build_configs({
|
28
|
+
"source" => source_dir,
|
29
|
+
"destination" => dest_dir
|
30
|
+
}, build_configs(overrides))
|
31
|
+
end
|
32
|
+
|
33
|
+
def build_site(config = {})
|
34
|
+
site = Jekyll::Site.new(site_configuration(
|
35
|
+
{"paginate" => 1}.merge(config)
|
36
|
+
))
|
37
|
+
site.process
|
38
|
+
site
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-paginate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.rc1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Parker Moore
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- parkrmoore@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- jekyll-paginate.gemspec
|
83
|
+
- lib/jekyll-paginate.rb
|
84
|
+
- lib/jekyll-paginate/pager.rb
|
85
|
+
- lib/jekyll-paginate/pagination.rb
|
86
|
+
- lib/jekyll-paginate/version.rb
|
87
|
+
- script/bootstrap
|
88
|
+
- script/cibuild
|
89
|
+
- spec/pager_spec.rb
|
90
|
+
- spec/pagination_spec.rb
|
91
|
+
- spec/source/_posts/2014-05-20-blah.html
|
92
|
+
- spec/source/_posts/2014-05-21-bleh.html
|
93
|
+
- spec/source/_posts/2014-05-22-humor.html
|
94
|
+
- spec/source/_posts/2014-05-23-hey-there.html
|
95
|
+
- spec/source/_posts/2014-05-24-whateva.html
|
96
|
+
- spec/source/_posts/2014-05-25-oh-yes.html
|
97
|
+
- spec/source/contacts/index.html
|
98
|
+
- spec/source/index.html
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
homepage: https://github.com/jekyll/jekyll-paginate
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.3.1
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.2.2
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Built-in Pagination Generator for Jekyll
|
124
|
+
test_files:
|
125
|
+
- spec/pager_spec.rb
|
126
|
+
- spec/pagination_spec.rb
|
127
|
+
- spec/source/_posts/2014-05-20-blah.html
|
128
|
+
- spec/source/_posts/2014-05-21-bleh.html
|
129
|
+
- spec/source/_posts/2014-05-22-humor.html
|
130
|
+
- spec/source/_posts/2014-05-23-hey-there.html
|
131
|
+
- spec/source/_posts/2014-05-24-whateva.html
|
132
|
+
- spec/source/_posts/2014-05-25-oh-yes.html
|
133
|
+
- spec/source/contacts/index.html
|
134
|
+
- spec/source/index.html
|
135
|
+
- spec/spec_helper.rb
|