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 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.8.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 &raquo;'), 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 &raquo;'), next_url, :class => 'next', :rel => 'next', :remote => remote
@@ -1 +1,7 @@
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
  <span class="next"></span>
@@ -1 +1,6 @@
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
1
6
  %span.next
@@ -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,2 +1,7 @@
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
1
6
  %nav.pagination
2
7
  = content_for :kaminari_paginator_tags
@@ -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('&laquo; 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('&laquo; Prev'), prev_url, :class => 'prev', :rel => 'prev', :remote => remote
@@ -1 +1,7 @@
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
  <span class="prev"></span>
@@ -1 +1,6 @@
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
1
6
  %span.prev
@@ -1 +1,7 @@
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
  <span class="page">...</span>
@@ -1,2 +1,7 @@
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
1
6
  %span.page
2
7
  \...
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.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-08}
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 = [
@@ -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 'first page' do
19
- subject { tags_with :num_pages => 10, :current_page => 1 }
20
- it { should_not contain_tag PrevLink }
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 'second page' do
32
- subject { tags_with :num_pages => 10, :current_page => 2 }
33
- it { should contain_tag PrevLink }
34
- it { should_not contain_tag PrevSpan }
35
- it { should contain_tag CurrentPage }
36
- it { should contain_tag FirstPageLink }
37
- it { should contain_tag LastPageLink }
38
- it { should contain_tag PageLink }
39
- it { should contain_tag NextLink }
40
- it { should_not contain_tag NextSpan }
41
- it { should contain_tag TruncatedSpan }
42
- end
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
- context 'third page' do
45
- subject { tags_with :num_pages => 10, :current_page => 3 }
46
- it { should contain_tag PrevLink }
47
- it { should_not contain_tag PrevSpan }
48
- it { should contain_tag CurrentPage }
49
- it { should contain_tag FirstPageLink }
50
- it { should contain_tag LastPageLink }
51
- it { should contain_tag PageLink }
52
- it { should contain_tag NextLink }
53
- it { should_not contain_tag NextSpan }
54
- it { should contain_tag TruncatedSpan }
55
- end
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
- context 'fourth page(no truncation)' do
58
- subject { tags_with :num_pages => 10, :current_page => 4 }
59
- it { should contain_tag PrevLink }
60
- it { should_not contain_tag PrevSpan }
61
- it { should contain_tag CurrentPage }
62
- it { should contain_tag FirstPageLink }
63
- it { should contain_tag LastPageLink }
64
- it { should contain_tag PageLink }
65
- it { should contain_tag NextLink }
66
- it { should_not contain_tag NextSpan }
67
- it { should_not contain_tag TruncatedSpan }
68
- end
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
- context 'seventh page(no truncation)' do
71
- subject { tags_with :num_pages => 10, :current_page => 7 }
72
- it { should contain_tag PrevLink }
73
- it { should_not contain_tag PrevSpan }
74
- it { should contain_tag CurrentPage }
75
- it { should contain_tag FirstPageLink }
76
- it { should contain_tag LastPageLink }
77
- it { should contain_tag PageLink }
78
- it { should contain_tag NextLink }
79
- it { should_not contain_tag NextSpan }
80
- it { should_not contain_tag TruncatedSpan }
81
- end
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
- context 'eighth page' do
84
- subject { tags_with :num_pages => 10, :current_page => 8 }
85
- it { should contain_tag PrevLink }
86
- it { should_not contain_tag PrevSpan }
87
- it { should contain_tag CurrentPage }
88
- it { should contain_tag FirstPageLink }
89
- it { should contain_tag LastPageLink }
90
- it { should contain_tag PageLink }
91
- it { should contain_tag NextLink }
92
- it { should_not contain_tag NextSpan }
93
- it { should contain_tag TruncatedSpan }
94
- end
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
- context 'last page' do
97
- subject { tags_with :num_pages => 10, :current_page => 10 }
98
- it { should contain_tag PrevLink }
99
- it { should_not contain_tag PrevSpan }
100
- it { should contain_tag CurrentPage }
101
- it { should contain_tag FirstPageLink }
102
- it { should_not contain_tag LastPageLink }
103
- it { should contain_tag PageLink }
104
- it { should_not contain_tag NextLink }
105
- it { should contain_tag NextSpan }
106
- it { should contain_tag TruncatedSpan }
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: 63
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 8
8
+ - 9
9
9
  - 0
10
- version: 0.8.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-08 00:00:00 +09:00
18
+ date: 2011-02-09 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency