jekyll-itafroma-archive 0.2.0 → 0.2.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 644948172026b1fee314dad4fb5cf3cce4e2c07d
|
4
|
+
data.tar.gz: 8fcbcb96a7299db26cd5d449fa03587927075623
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34f78dda41ea6c48ffbcc803294b66240f1c757aa453f3001d2409e2f8c09c67d371b76ab8349b22569ae03708898ea47102802ad3405dc1bb5a70040d8cc048
|
7
|
+
data.tar.gz: afb630e416b23c9bf124296a89f3dc763256df4683f55d484694c30e29c294b9ff05ff73fd49e97765db03e9dda229a9feb5f9f4130e22b39825e75567b766ce
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# An archive listing page.
|
3
3
|
#
|
4
4
|
# Author:: Mark Trapp
|
5
|
-
# Copyright: Copyright (c) 2013 Mark Trapp
|
5
|
+
# Copyright: Copyright (c) 2013-2014 Mark Trapp
|
6
6
|
# License:: MIT
|
7
7
|
# Acknowledgements:: Inspired by the work done by nlindley and ilkka on Github:
|
8
8
|
# https://gist.github.com/nlindley/6409459
|
@@ -1,8 +1,10 @@
|
|
1
1
|
#
|
2
2
|
# An archive listing pager.
|
3
3
|
#
|
4
|
+
# Adapted from Jekyll::Generators::Pagination
|
5
|
+
#
|
4
6
|
# Author:: Mark Trapp
|
5
|
-
# Copyright: Copyright (c)
|
7
|
+
# Copyright: Copyright (c) 2014 Mark Trapp
|
6
8
|
# License:: MIT
|
7
9
|
# Acknowledgements:: Inspired by the work done by nlindley and ilkka on Github:
|
8
10
|
# https://gist.github.com/nlindley/6409459
|
@@ -12,14 +14,18 @@
|
|
12
14
|
module Jekyll
|
13
15
|
module Itafroma
|
14
16
|
# Represents the pager used for ArchivePages.
|
15
|
-
class ArchivePager
|
17
|
+
class ArchivePager
|
18
|
+
attr_reader :page, :per_page, :posts, :total_posts, :total_pages,
|
19
|
+
:previous_page, :previous_page_path, :next_page,
|
20
|
+
:next_page_path
|
21
|
+
|
16
22
|
# Static: Return the pagination path of the archive page
|
17
23
|
#
|
18
24
|
# posts - The Array of the archive's Posts.
|
19
25
|
# num_page - the pagination page number
|
20
26
|
#
|
21
27
|
# Returns the pagination path as a string
|
22
|
-
def self.
|
28
|
+
def self.paginate_path(posts, num_page)
|
23
29
|
return posts.first.url if num_page.nil?
|
24
30
|
return nil if num_page < 1
|
25
31
|
return nil if num_page > posts.size
|
@@ -34,9 +40,37 @@ module Jekyll
|
|
34
40
|
# num_pages - The Integer number of pages or nil if you'd like the number
|
35
41
|
# of pages calculated.
|
36
42
|
def initialize(site, page, all_posts, num_pages = nil)
|
37
|
-
|
38
|
-
@
|
39
|
-
@
|
43
|
+
@page = page
|
44
|
+
@per_page = 1
|
45
|
+
@total_pages = num_pages || all_posts.size
|
46
|
+
|
47
|
+
if @page > @total_pages
|
48
|
+
fail "Jekyll Archive Generator: page number can't be greater than total pages: #{@page} > #{@total_pages}"
|
49
|
+
end
|
50
|
+
|
51
|
+
@total_posts = all_posts.size
|
52
|
+
@posts = all_posts
|
53
|
+
@previous_page = @page != 1 ? @page - 1 : nil
|
54
|
+
@previous_page_path = ArchivePager.paginate_path(all_posts, @previous_page)
|
55
|
+
@next_page = @page != @total_pages ? @page + 1 : nil
|
56
|
+
@next_page_path = ArchivePager.paginate_path(all_posts, @next_page)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Convert this Pager's data to a Hash suitable for use by Liquid.
|
60
|
+
#
|
61
|
+
# Returns the Hash representation of this Pager.
|
62
|
+
def to_liquid
|
63
|
+
{
|
64
|
+
'page' => page,
|
65
|
+
'per_page' => per_page,
|
66
|
+
'posts' => posts,
|
67
|
+
'total_posts' => total_posts,
|
68
|
+
'total_pages' => total_pages,
|
69
|
+
'previous_page' => previous_page,
|
70
|
+
'previous_page_path' => previous_page_path,
|
71
|
+
'next_page' => next_page,
|
72
|
+
'next_page_path' => next_page_path
|
73
|
+
}
|
40
74
|
end
|
41
75
|
end
|
42
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-itafroma-archive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Trapp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Jekyll plugin to create a set of archive pages.
|
14
14
|
email: mark@marktrapp.com
|