jekyll-index-pages 0.5.1 → 0.5.2
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/README.md +4 -1
- data/jekyll-index-pages.gemspec +1 -1
- data/lib/jekyll-index-pages/generator.rb +3 -2
- data/lib/jekyll-index-pages/index-page.rb +1 -1
- data/lib/jekyll-index-pages/version.rb +1 -1
- data/spec/fixtures/index-page/_starships/deep-space-nine.md +1 -0
- data/spec/fixtures/index-page/_starships/enterprise-d.md +1 -0
- data/spec/fixtures/index-page/_starships/enterprise.md +1 -0
- data/spec/fixtures/index-page/_starships/voyager.md +1 -0
- data/spec/generator_spec.rb +117 -6
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1229998c1d43a580d8b502d6e80d309b753e9cf
|
4
|
+
data.tar.gz: e8da9dee48aa8484a28e91b9c6aad773117715d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fa256f6a0eff606f548a28b24a42bcdeaa583721d130dfb85ec31e80b67328b8c581a717e30255d6dab80ca5df7126de23324bb29164a77f0861b53fbf812c3
|
7
|
+
data.tar.gz: 43fb7b088bcca51ece6699fdeb9f310693e8ac33232abaab808a8a9dbbca817d184fed1458c3bf8f429069ca1385e157a18e16f9c9d5e9c9b1110575cf7d7cab
|
data/README.md
CHANGED
@@ -52,9 +52,12 @@ index_pages:
|
|
52
52
|
|
53
53
|
This will tell the plugin to generate index pages with given title and excerpt,
|
54
54
|
using the layout named `_layouts/blog.html`. Each index page will contain up to
|
55
|
-
20
|
55
|
+
20 documents. First page can be accessed at `/blog/`. Subsequent pages can be
|
56
56
|
accessed at `/blog/<page-num>/`.
|
57
57
|
|
58
|
+
> Documents are sorted automatically using document's `date` setting, the
|
59
|
+
> first being the most recent.
|
60
|
+
|
58
61
|
If you want to generate index pages for categories, add the `categories`
|
59
62
|
setting to `index_page` section:
|
60
63
|
|
data/jekyll-index-pages.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
spec.add_dependency("i18n", "~> 0.8")
|
25
|
-
spec.add_dependency("jekyll", "~> 3.
|
25
|
+
spec.add_dependency("jekyll", "~> 3.4.0")
|
26
26
|
|
27
27
|
spec.add_development_dependency("bundler", "~> 1.14")
|
28
28
|
spec.add_development_dependency("rake", "~> 10.0")
|
@@ -15,7 +15,7 @@ module JekyllIndexPages
|
|
15
15
|
doc_group =
|
16
16
|
case kind
|
17
17
|
when "posts"
|
18
|
-
{ "posts" => site.posts.docs
|
18
|
+
{ "posts" => site.posts.docs }
|
19
19
|
when "categories"
|
20
20
|
site.categories
|
21
21
|
when "tags"
|
@@ -29,7 +29,8 @@ module JekyllIndexPages
|
|
29
29
|
end
|
30
30
|
|
31
31
|
doc_group.each do |label, docs|
|
32
|
-
|
32
|
+
sorted_docs = docs.sort { |x, y| y.date <=> x.date }
|
33
|
+
pagination = Pagination.new(sorted_docs, per_page)
|
33
34
|
|
34
35
|
(0...pagination.total).each do |current|
|
35
36
|
pagination.paginate(current)
|
@@ -26,7 +26,7 @@ module JekyllIndexPages
|
|
26
26
|
self.data["excerpt"] = excerpt.sub(":label", label)
|
27
27
|
|
28
28
|
self.data["pager"] = Hash.new
|
29
|
-
self.data["pager"]["docs"] = pager.docs
|
29
|
+
self.data["pager"]["docs"] = pager.docs
|
30
30
|
self.data["pager"]["total_pages"] = pager.total_pages
|
31
31
|
self.data["pager"]["current_page"] = pager.current_page
|
32
32
|
self.data["pager"]["prev_page"] = pager.prev_page
|
data/spec/generator_spec.rb
CHANGED
@@ -45,18 +45,32 @@ describe JekyllIndexPages::Generator do
|
|
45
45
|
expect(site.pages[0].url).to eq("/posts/")
|
46
46
|
end
|
47
47
|
|
48
|
+
it "generates a post index page with a pager" do
|
49
|
+
expect(site.pages[0].data["pager"]).to be_instance_of(Hash)
|
50
|
+
end
|
51
|
+
|
48
52
|
it "generates a post index page with six documents" do
|
49
53
|
expect(site.pages[0].data["pager"]["docs"].length).to eq(6)
|
50
54
|
end
|
51
55
|
|
52
56
|
it "generates a post index page with recent documents first" do
|
53
|
-
|
54
|
-
|
55
|
-
expect(recent_doc.date).to be > older_doc.date
|
56
|
-
end
|
57
|
+
first = site.pages[0].data["pager"]["docs"][0]
|
58
|
+
expect(first.date).to eq(Time.new(2001, 9, 26))
|
57
59
|
|
58
|
-
|
59
|
-
expect(
|
60
|
+
second = site.pages[0].data["pager"]["docs"][1]
|
61
|
+
expect(second.date).to eq(Time.new(1995, 1, 16))
|
62
|
+
|
63
|
+
third = site.pages[0].data["pager"]["docs"][2]
|
64
|
+
expect(third.date).to eq(Time.new(1993, 1, 03))
|
65
|
+
|
66
|
+
fourth = site.pages[0].data["pager"]["docs"][3]
|
67
|
+
expect(fourth.date).to eq(Time.new(1987, 9, 28))
|
68
|
+
|
69
|
+
fifth = site.pages[0].data["pager"]["docs"][4]
|
70
|
+
expect(fifth.date).to eq(Time.new(1966, 9, 8))
|
71
|
+
|
72
|
+
sixth = site.pages[0].data["pager"]["docs"][5]
|
73
|
+
expect(sixth.date).to eq(Time.new(1966, 9, 8))
|
60
74
|
end
|
61
75
|
end
|
62
76
|
end
|
@@ -100,6 +114,14 @@ describe JekyllIndexPages::Generator do
|
|
100
114
|
expect(page.data["pager"]["docs"].length).to eq(2)
|
101
115
|
end
|
102
116
|
|
117
|
+
it "sorted by date, recent first" do
|
118
|
+
first = page.data["pager"]["docs"][0]
|
119
|
+
expect(first.date).to eq(Time.new(2001, 9, 26))
|
120
|
+
|
121
|
+
second = page.data["pager"]["docs"][1]
|
122
|
+
expect(second.date).to eq(Time.new(1995, 1, 16))
|
123
|
+
end
|
124
|
+
|
103
125
|
it "and next page url only" do
|
104
126
|
expect(page.data["pager"]["prev_page_url"]).to eq("")
|
105
127
|
expect(page.data["pager"]["next_page_url"]).to eq("/posts/2/")
|
@@ -109,6 +131,18 @@ describe JekyllIndexPages::Generator do
|
|
109
131
|
context "generates the second post index page" do
|
110
132
|
let(:page) { site.pages[1] }
|
111
133
|
|
134
|
+
it "with two documents" do
|
135
|
+
expect(page.data["pager"]["docs"].length).to eq(2)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "sorted by date, recent first" do
|
139
|
+
first = page.data["pager"]["docs"][0]
|
140
|
+
expect(first.date).to eq(Time.new(1993, 1, 03))
|
141
|
+
|
142
|
+
second = page.data["pager"]["docs"][1]
|
143
|
+
expect(second.date).to eq(Time.new(1987, 9, 28))
|
144
|
+
end
|
145
|
+
|
112
146
|
it "with previous and next page urls" do
|
113
147
|
expect(page.data["pager"]["prev_page_url"]).to eq("/posts/")
|
114
148
|
expect(page.data["pager"]["next_page_url"]).to eq("/posts/3/")
|
@@ -268,6 +302,83 @@ describe JekyllIndexPages::Generator do
|
|
268
302
|
it "generates the first collection index page at /starships/" do
|
269
303
|
expect(site.pages[0].url).to eq("/starships/")
|
270
304
|
end
|
305
|
+
|
306
|
+
it "generates a post index page with four documents" do
|
307
|
+
expect(site.pages[0].data["pager"]["docs"].length).to eq(4)
|
308
|
+
end
|
309
|
+
|
310
|
+
it "generates a post index page with recent documents first" do
|
311
|
+
first = site.pages[0].data["pager"]["docs"][0]
|
312
|
+
expect(first.date).to eq(Time.new(2371, 1, 1))
|
313
|
+
|
314
|
+
second = site.pages[0].data["pager"]["docs"][1]
|
315
|
+
expect(second.date).to eq(Time.new(2363, 1, 1))
|
316
|
+
|
317
|
+
third = site.pages[0].data["pager"]["docs"][2]
|
318
|
+
expect(third.date).to eq(Time.new(2351, 1, 1))
|
319
|
+
|
320
|
+
fourth = site.pages[0].data["pager"]["docs"][3]
|
321
|
+
expect(fourth.date).to eq(Time.new(2245, 1, 1))
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
context "When custom 'per page' setting for posts index page is provided" do
|
327
|
+
let(:overrides) do
|
328
|
+
{
|
329
|
+
"collections" => ["starships"],
|
330
|
+
"index_pages" => {
|
331
|
+
"custom" => {
|
332
|
+
"per_page" => 2,
|
333
|
+
"layout" => "custom-layout",
|
334
|
+
"collection" => "starships"
|
335
|
+
}
|
336
|
+
}
|
337
|
+
}
|
338
|
+
end
|
339
|
+
|
340
|
+
describe "Generator.generate" do
|
341
|
+
context "generates the first collection index page" do
|
342
|
+
let(:page) { site.pages[0] }
|
343
|
+
|
344
|
+
it "with two documents" do
|
345
|
+
expect(page.data["pager"]["docs"].length).to eq(2)
|
346
|
+
end
|
347
|
+
|
348
|
+
it "sorted by date, recent first" do
|
349
|
+
first = page.data["pager"]["docs"][0]
|
350
|
+
expect(first.date).to eq(Time.new(2371, 1, 1))
|
351
|
+
|
352
|
+
second = page.data["pager"]["docs"][1]
|
353
|
+
expect(second.date).to eq(Time.new(2363, 1, 1))
|
354
|
+
end
|
355
|
+
|
356
|
+
it "and next page url only" do
|
357
|
+
expect(page.data["pager"]["prev_page_url"]).to eq("")
|
358
|
+
expect(page.data["pager"]["next_page_url"]).to eq("/starships/2/")
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
context "generates the second collection index page" do
|
363
|
+
let(:page) { site.pages[1] }
|
364
|
+
|
365
|
+
it "with two documents" do
|
366
|
+
expect(page.data["pager"]["docs"].length).to eq(2)
|
367
|
+
end
|
368
|
+
|
369
|
+
it "sorted by date, recent first" do
|
370
|
+
first = page.data["pager"]["docs"][0]
|
371
|
+
expect(first.date).to eq(Time.new(2351, 1, 1))
|
372
|
+
|
373
|
+
second = page.data["pager"]["docs"][1]
|
374
|
+
expect(second.date).to eq(Time.new(2245, 1, 1))
|
375
|
+
end
|
376
|
+
|
377
|
+
it "and previous page url only" do
|
378
|
+
expect(page.data["pager"]["prev_page_url"]).to eq("/starships/")
|
379
|
+
expect(page.data["pager"]["next_page_url"]).to eq("")
|
380
|
+
end
|
381
|
+
end
|
271
382
|
end
|
272
383
|
end
|
273
384
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-index-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jose Miguel Venegas Mendoza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 3.4.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 3.4.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
165
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
166
|
+
rubygems_version: 2.6.13
|
167
167
|
signing_key:
|
168
168
|
specification_version: 4
|
169
169
|
summary: Index page generator for Jekyll sites.
|