kaminari 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of kaminari might be problematic. Click here for more details.
- data/CHANGELOG +7 -0
- data/VERSION +1 -1
- data/app/views/kaminari/_current_page.html.erb +8 -0
- data/app/views/kaminari/_current_page.html.haml +7 -0
- data/app/views/kaminari/_first_page_link.html.erb +8 -0
- data/app/views/kaminari/_first_page_link.html.haml +7 -0
- data/app/views/kaminari/_last_page_link.html.erb +8 -0
- data/app/views/kaminari/_last_page_link.html.haml +7 -0
- data/app/views/kaminari/_next_link.html.erb +7 -0
- data/app/views/kaminari/_next_link.html.haml +6 -0
- data/app/views/kaminari/_next_span.html.erb +6 -0
- data/app/views/kaminari/_next_span.html.haml +5 -0
- data/app/views/kaminari/_page_link.html.erb +8 -0
- data/app/views/kaminari/_page_link.html.haml +7 -0
- data/app/views/kaminari/_paginator.html.erb +6 -0
- data/app/views/kaminari/_paginator.html.haml +5 -0
- data/app/views/kaminari/_prev_link.html.erb +7 -0
- data/app/views/kaminari/_prev_link.html.haml +6 -0
- data/app/views/kaminari/_prev_span.html.erb +6 -0
- data/app/views/kaminari/_prev_span.html.haml +5 -0
- data/app/views/kaminari/_truncated_span.html.erb +6 -0
- data/app/views/kaminari/_truncated_span.html.haml +5 -0
- data/kaminari.gemspec +2 -2
- data/lib/kaminari/helpers.rb +2 -1
- data/spec/helpers/helpers_spec.rb +89 -82
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.9.0
|
2
|
+
|
3
|
+
* added "per_page" to the template local variables #3 [hsbt]
|
4
|
+
|
5
|
+
* show no contents when the current page is the only page (in other words,
|
6
|
+
num_pages == 1) #2 [hsbt]
|
7
|
+
|
1
8
|
== 0.8.0
|
2
9
|
|
3
10
|
* using HTML5 <nav> tag rather than <div> for the container tag
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.0
|
@@ -1 +1,9 @@
|
|
1
|
+
<%# available local variables:
|
2
|
+
page: the page number of this page
|
3
|
+
page_url: url to this page
|
4
|
+
current_page: the page number of currently displayed page
|
5
|
+
num_pages: total number of pages
|
6
|
+
per_page: number of items to fetch per page
|
7
|
+
remote: data-remote
|
8
|
+
-%>
|
1
9
|
<span class="page current"><%= page %></span>
|
@@ -1,2 +1,9 @@
|
|
1
|
+
-# available local variables:
|
2
|
+
page: the page number of this page
|
3
|
+
page_url: url to this page
|
4
|
+
current_page: the page number of currently displayed page
|
5
|
+
num_pages: total number of pages
|
6
|
+
per_page: number of items to fetch per page
|
7
|
+
remote: data-remote
|
1
8
|
%span.page.current
|
2
9
|
= page
|
@@ -1,3 +1,11 @@
|
|
1
|
+
<%# available local variables:
|
2
|
+
page: the page number of this page
|
3
|
+
page_url: url to this page
|
4
|
+
current_page: the page number of currently displayed page
|
5
|
+
num_pages: total number of pages
|
6
|
+
per_page: number of items to fetch per page
|
7
|
+
remote: data-remote
|
8
|
+
-%>
|
1
9
|
<span class="page first">
|
2
10
|
<%= link_to page, page_url, :remote => remote %>
|
3
11
|
</span>
|
@@ -1,2 +1,9 @@
|
|
1
|
+
-# available local variables:
|
2
|
+
page: the page number of this page
|
3
|
+
page_url: url to this page
|
4
|
+
current_page: the page number of currently displayed page
|
5
|
+
num_pages: total number of pages
|
6
|
+
per_page: number of items to fetch per page
|
7
|
+
remote: data-remote
|
1
8
|
%span.page.first
|
2
9
|
= link_to page, page_url, :remote => remote
|
@@ -1,3 +1,11 @@
|
|
1
|
+
<%# available local variables:
|
2
|
+
page: the page number of this page
|
3
|
+
page_url: url to this page
|
4
|
+
current_page: the page number of currently displayed page
|
5
|
+
num_pages: total number of pages
|
6
|
+
per_page: number of items to fetch per page
|
7
|
+
remote: data-remote
|
8
|
+
-%>
|
1
9
|
<span class="page last">
|
2
10
|
<%= link_to page, page_url, :remote => remote %>
|
3
11
|
</span>
|
@@ -1,2 +1,9 @@
|
|
1
|
+
-# available local variables:
|
2
|
+
page: the page number of this page
|
3
|
+
page_url: url to this page
|
4
|
+
current_page: the page number of currently displayed page
|
5
|
+
num_pages: total number of pages
|
6
|
+
per_page: number of items to fetch per page
|
7
|
+
remote: data-remote
|
1
8
|
%span.page.last
|
2
9
|
= link_to page, page_url, :remote => remote
|
@@ -1,3 +1,10 @@
|
|
1
|
+
<%# available local variables:
|
2
|
+
next_url: url to the next page
|
3
|
+
current_page: the page number of currently displayed page
|
4
|
+
num_pages: total number of pages
|
5
|
+
per_page: number of items to fetch per page
|
6
|
+
remote: data-remote
|
7
|
+
-%>
|
1
8
|
<span class="next">
|
2
9
|
<%= link_to_if (current_page < num_pages), raw('Next »'), next_url, :class => 'next', :rel => 'next', :remote => remote %>
|
3
10
|
</span>
|
@@ -1,2 +1,8 @@
|
|
1
|
+
-# available local variables:
|
2
|
+
next_url: url to the next page
|
3
|
+
current_page: the page number of currently displayed page
|
4
|
+
num_pages: total number of pages
|
5
|
+
per_page: number of items to fetch per page
|
6
|
+
remote: data-remote
|
1
7
|
%span.next
|
2
8
|
= link_to_if (current_page < num_pages), raw('Next »'), next_url, :class => 'next', :rel => 'next', :remote => remote
|
@@ -1,3 +1,11 @@
|
|
1
|
+
<%# available local variables:
|
2
|
+
page: the page number of this page
|
3
|
+
page_url: url to this page
|
4
|
+
current_page: the page number of currently displayed page
|
5
|
+
num_pages: total number of pages
|
6
|
+
per_page: number of items to fetch per page
|
7
|
+
remote: data-remote
|
8
|
+
-%>
|
1
9
|
<span class="page">
|
2
10
|
<%= link_to page, page_url, :remote => remote %>
|
3
11
|
</span>
|
@@ -1,2 +1,9 @@
|
|
1
|
+
-# available local variables:
|
2
|
+
page: the page number of this page
|
3
|
+
page_url: url to this page
|
4
|
+
current_page: the page number of currently displayed page
|
5
|
+
num_pages: total number of pages
|
6
|
+
per_page: number of items to fetch per page
|
7
|
+
remote: data-remote
|
1
8
|
%span.page
|
2
9
|
= link_to page, page_url, :remote => remote
|
@@ -1,3 +1,9 @@
|
|
1
|
+
<%# available local variables:
|
2
|
+
current_page: the page number of currently displayed page
|
3
|
+
num_pages: total number of pages
|
4
|
+
per_page: number of items to fetch per page
|
5
|
+
remote: data-remote
|
6
|
+
-%>
|
1
7
|
<nav class='pagination'>
|
2
8
|
<%= content_for :kaminari_paginator_tags %>
|
3
9
|
</nav>
|
@@ -1,3 +1,10 @@
|
|
1
|
+
<%# available local variables:
|
2
|
+
prev_url: url to the previous page
|
3
|
+
current_page: the page number of currently displayed page
|
4
|
+
num_pages: total number of pages
|
5
|
+
per_page: number of items to fetch per page
|
6
|
+
remote: data-remote
|
7
|
+
-%>
|
1
8
|
<span class="prev">
|
2
9
|
<%= link_to_if (current_page > 1), raw('« Prev'), prev_url, :class => 'prev', :rel => 'prev', :remote => remote %>
|
3
10
|
</span>
|
@@ -1,2 +1,8 @@
|
|
1
|
+
-# available local variables:
|
2
|
+
prev_url: url to the previous page
|
3
|
+
current_page: the page number of currently displayed page
|
4
|
+
num_pages: total number of pages
|
5
|
+
per_page: number of items to fetch per page
|
6
|
+
remote: data-remote
|
1
7
|
%span.prev
|
2
8
|
= link_to_if (current_page > 1), raw('« Prev'), prev_url, :class => 'prev', :rel => 'prev', :remote => remote
|
data/kaminari.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{kaminari}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.9.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Akira Matsuda"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-09}
|
13
13
|
s.description = %q{Kaminari is a Scope & Engine based clean and powerful and customizable and sophisticated paginator for Rails 3}
|
14
14
|
s.email = %q{ronnie@dio.jp}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/kaminari/helpers.rb
CHANGED
@@ -67,6 +67,7 @@ module Kaminari
|
|
67
67
|
|
68
68
|
def tagify_links
|
69
69
|
num_pages, current_page, left, window, right = @options[:num_pages], @options[:current_page], @left, @window, @right
|
70
|
+
return [] if num_pages <= 1
|
70
71
|
|
71
72
|
tags = []
|
72
73
|
tags << (current_page > 1 ? PrevLink.new(self) : PrevSpan.new(self))
|
@@ -129,7 +130,7 @@ module Kaminari
|
|
129
130
|
end
|
130
131
|
|
131
132
|
def paginate(scope, options = {}, &block)
|
132
|
-
PaginationRenderer.new self, options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :remote => false)
|
133
|
+
PaginationRenderer.new self, options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :per_page => scope.limit_value, :remote => false)
|
133
134
|
end
|
134
135
|
end
|
135
136
|
end
|
@@ -15,95 +15,102 @@ describe 'Kaminari::Helpers::PaginationRenderer' do
|
|
15
15
|
PaginationRenderer.new(renderer, options).tagify_links
|
16
16
|
end
|
17
17
|
|
18
|
-
context '
|
19
|
-
subject { tags_with :num_pages =>
|
20
|
-
it {
|
21
|
-
it { should contain_tag PrevSpan }
|
22
|
-
it { should contain_tag CurrentPage }
|
23
|
-
it { should_not contain_tag FirstPageLink }
|
24
|
-
it { should contain_tag LastPageLink }
|
25
|
-
it { should contain_tag PageLink }
|
26
|
-
it { should contain_tag NextLink }
|
27
|
-
it { should_not contain_tag NextSpan }
|
28
|
-
it { should contain_tag TruncatedSpan }
|
18
|
+
context '1 page in total' do
|
19
|
+
subject { tags_with :num_pages => 1, :current_page => 1 }
|
20
|
+
it { should have(0).tags }
|
29
21
|
end
|
30
22
|
|
31
|
-
context '
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
23
|
+
context '10 pages in total' do
|
24
|
+
context 'first page' do
|
25
|
+
subject { tags_with :num_pages => 10, :current_page => 1 }
|
26
|
+
it { should_not contain_tag PrevLink }
|
27
|
+
it { should contain_tag PrevSpan }
|
28
|
+
it { should contain_tag CurrentPage }
|
29
|
+
it { should_not contain_tag FirstPageLink }
|
30
|
+
it { should contain_tag LastPageLink }
|
31
|
+
it { should contain_tag PageLink }
|
32
|
+
it { should contain_tag NextLink }
|
33
|
+
it { should_not contain_tag NextSpan }
|
34
|
+
it { should contain_tag TruncatedSpan }
|
35
|
+
end
|
43
36
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
37
|
+
context 'second page' do
|
38
|
+
subject { tags_with :num_pages => 10, :current_page => 2 }
|
39
|
+
it { should contain_tag PrevLink }
|
40
|
+
it { should_not contain_tag PrevSpan }
|
41
|
+
it { should contain_tag CurrentPage }
|
42
|
+
it { should contain_tag FirstPageLink }
|
43
|
+
it { should contain_tag LastPageLink }
|
44
|
+
it { should contain_tag PageLink }
|
45
|
+
it { should contain_tag NextLink }
|
46
|
+
it { should_not contain_tag NextSpan }
|
47
|
+
it { should contain_tag TruncatedSpan }
|
48
|
+
end
|
56
49
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
50
|
+
context 'third page' do
|
51
|
+
subject { tags_with :num_pages => 10, :current_page => 3 }
|
52
|
+
it { should contain_tag PrevLink }
|
53
|
+
it { should_not contain_tag PrevSpan }
|
54
|
+
it { should contain_tag CurrentPage }
|
55
|
+
it { should contain_tag FirstPageLink }
|
56
|
+
it { should contain_tag LastPageLink }
|
57
|
+
it { should contain_tag PageLink }
|
58
|
+
it { should contain_tag NextLink }
|
59
|
+
it { should_not contain_tag NextSpan }
|
60
|
+
it { should contain_tag TruncatedSpan }
|
61
|
+
end
|
69
62
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
63
|
+
context 'fourth page(no truncation)' do
|
64
|
+
subject { tags_with :num_pages => 10, :current_page => 4 }
|
65
|
+
it { should contain_tag PrevLink }
|
66
|
+
it { should_not contain_tag PrevSpan }
|
67
|
+
it { should contain_tag CurrentPage }
|
68
|
+
it { should contain_tag FirstPageLink }
|
69
|
+
it { should contain_tag LastPageLink }
|
70
|
+
it { should contain_tag PageLink }
|
71
|
+
it { should contain_tag NextLink }
|
72
|
+
it { should_not contain_tag NextSpan }
|
73
|
+
it { should_not contain_tag TruncatedSpan }
|
74
|
+
end
|
82
75
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
76
|
+
context 'seventh page(no truncation)' do
|
77
|
+
subject { tags_with :num_pages => 10, :current_page => 7 }
|
78
|
+
it { should contain_tag PrevLink }
|
79
|
+
it { should_not contain_tag PrevSpan }
|
80
|
+
it { should contain_tag CurrentPage }
|
81
|
+
it { should contain_tag FirstPageLink }
|
82
|
+
it { should contain_tag LastPageLink }
|
83
|
+
it { should contain_tag PageLink }
|
84
|
+
it { should contain_tag NextLink }
|
85
|
+
it { should_not contain_tag NextSpan }
|
86
|
+
it { should_not contain_tag TruncatedSpan }
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'eighth page' do
|
90
|
+
subject { tags_with :num_pages => 10, :current_page => 8 }
|
91
|
+
it { should contain_tag PrevLink }
|
92
|
+
it { should_not contain_tag PrevSpan }
|
93
|
+
it { should contain_tag CurrentPage }
|
94
|
+
it { should contain_tag FirstPageLink }
|
95
|
+
it { should contain_tag LastPageLink }
|
96
|
+
it { should contain_tag PageLink }
|
97
|
+
it { should contain_tag NextLink }
|
98
|
+
it { should_not contain_tag NextSpan }
|
99
|
+
it { should contain_tag TruncatedSpan }
|
100
|
+
end
|
95
101
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
102
|
+
context 'last page' do
|
103
|
+
subject { tags_with :num_pages => 10, :current_page => 10 }
|
104
|
+
it { should contain_tag PrevLink }
|
105
|
+
it { should_not contain_tag PrevSpan }
|
106
|
+
it { should contain_tag CurrentPage }
|
107
|
+
it { should contain_tag FirstPageLink }
|
108
|
+
it { should_not contain_tag LastPageLink }
|
109
|
+
it { should contain_tag PageLink }
|
110
|
+
it { should_not contain_tag NextLink }
|
111
|
+
it { should contain_tag NextSpan }
|
112
|
+
it { should contain_tag TruncatedSpan }
|
113
|
+
end
|
107
114
|
end
|
108
115
|
end
|
109
116
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaminari
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 9
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Akira Matsuda
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-09 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|