kaminari 0.10.4 → 0.11.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.

Files changed (55) hide show
  1. data/CHANGELOG +31 -0
  2. data/Gemfile +1 -30
  3. data/Gemfile.lock +66 -82
  4. data/README.rdoc +16 -0
  5. data/Rakefile +12 -2
  6. data/VERSION +1 -1
  7. data/app/views/kaminari/_first_page.html.erb +11 -0
  8. data/app/views/kaminari/_first_page.html.haml +9 -0
  9. data/app/views/kaminari/{_truncated_span.html.erb → _gap.html.erb} +2 -2
  10. data/app/views/kaminari/{_truncated_span.html.haml → _gap.html.haml} +2 -2
  11. data/app/views/kaminari/_last_page.html.erb +11 -0
  12. data/app/views/kaminari/_last_page.html.haml +9 -0
  13. data/app/views/kaminari/{_next_link.html.erb → _next_page.html.erb} +3 -3
  14. data/app/views/kaminari/{_next_link.html.haml → _next_page.html.haml} +3 -3
  15. data/app/views/kaminari/_page.html.erb +12 -0
  16. data/app/views/kaminari/_page.html.haml +10 -0
  17. data/app/views/kaminari/_paginator.html.erb +8 -14
  18. data/app/views/kaminari/_paginator.html.haml +8 -13
  19. data/app/views/kaminari/{_prev_link.html.erb → _prev_page.html.erb} +3 -3
  20. data/app/views/kaminari/_prev_page.html.haml +9 -0
  21. data/config/locales/kaminari.yml +4 -2
  22. data/kaminari.gemspec +88 -59
  23. data/lib/generators/kaminari/views_generator.rb +13 -9
  24. data/lib/kaminari.rb +1 -0
  25. data/lib/kaminari/helpers/action_view_extension.rb +5 -5
  26. data/lib/kaminari/helpers/paginator.rb +153 -0
  27. data/lib/kaminari/helpers/tags.rb +32 -200
  28. data/lib/kaminari/models/active_record_extension.rb +1 -8
  29. data/lib/kaminari/models/active_record_relation_methods.rb +8 -1
  30. data/lib/kaminari/models/mongoid_extension.rb +1 -0
  31. data/lib/kaminari/railtie.rb +1 -1
  32. data/lib/kaminari/version.rb +3 -0
  33. data/spec/acceptance/users_spec.rb +13 -4
  34. data/spec/fake_app.rb +34 -2
  35. data/spec/helpers/helpers_spec.rb +13 -4
  36. data/spec/helpers/tags_spec.rb +32 -50
  37. data/spec/models/active_record_relation_methods_spec.rb +18 -0
  38. data/spec/models/scopes_spec.rb +12 -1
  39. data/spec/spec_helper.rb +1 -0
  40. data/spec/support/database_cleaner.rb +13 -0
  41. metadata +248 -127
  42. data/app/views/kaminari/_current_page.html.erb +0 -9
  43. data/app/views/kaminari/_current_page.html.haml +0 -9
  44. data/app/views/kaminari/_first_page_link.html.erb +0 -12
  45. data/app/views/kaminari/_first_page_link.html.haml +0 -10
  46. data/app/views/kaminari/_last_page_link.html.erb +0 -12
  47. data/app/views/kaminari/_last_page_link.html.haml +0 -10
  48. data/app/views/kaminari/_next_span.html.erb +0 -8
  49. data/app/views/kaminari/_next_span.html.haml +0 -7
  50. data/app/views/kaminari/_page_link.html.erb +0 -12
  51. data/app/views/kaminari/_page_link.html.haml +0 -10
  52. data/app/views/kaminari/_prev_link.html.haml +0 -9
  53. data/app/views/kaminari/_prev_span.html.erb +0 -8
  54. data/app/views/kaminari/_prev_span.html.haml +0 -7
  55. data/lib/kaminari/helpers/helpers.rb +0 -75
data/CHANGELOG CHANGED
@@ -1,3 +1,34 @@
1
+ == 0.11.0
2
+
3
+ This release contains several backward incompatibilities on template API.
4
+ You probably need to update your existing templates if you're already using
5
+ your own custom theme.
6
+
7
+ * Merge _current_page, _first_page_link, _last_page_link and _page_link into
8
+ one _page partial #28 [GarthSnyder]
9
+
10
+ * Add real first/last page links, and use them by default instead of outer
11
+ window #30 [GarthSnyder]
12
+
13
+ * The disabled items should simply not be emitted, even as an empty span #30
14
+ [GarthSnyder]
15
+
16
+ * Skip :order in #count_all so complex groups with generated columns don't
17
+ blow up in SQL-land #61 [keeran, Empact]
18
+
19
+ * Ignore :include in #count_all to make it work better with polymorphic eager
20
+ loading #80 [njakobsen]
21
+
22
+ * Quick fix on #count to return the actual number of records on AR 3.0 #45 #50
23
+
24
+ * Removed "TERRIBLE HORRIBLE NO GOOD VERY BAD HACK" #82 [janx, flop, pda]
25
+
26
+ * Allow for Multiple Themes #64 [tmilewski]
27
+
28
+ * Themes can contain the whole application directory structure now
29
+
30
+ * Use gemspec method in Gemfile [p_elliott]
31
+
1
32
  == 0.10.4
2
33
 
3
34
  * Do not break ActiveRecord::Base.descendants, by making sure to call super
data/Gemfile CHANGED
@@ -1,30 +1 @@
1
- source 'http://rubygems.org'
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
-
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
- group :development do
9
- gem 'rspec', '>= 2.5.0'
10
- gem 'rr', '>= 1.0.2'
11
- gem 'steak', '>= 1.1.0'
12
- gem 'capybara', '>= 0.4.1.1'
13
- gem 'bundler', '>= 1.0.0'
14
- gem 'jeweler', '>= 1.5.2'
15
- gem 'rcov', '>= 0'
16
- gem 'rails', :git => 'git://github.com/rails/rails.git'
17
- # gem 'rails', '>= 3.0.3'
18
- gem 'rack', :git => 'git://github.com/rack/rack.git'
19
- gem 'arel', :git => 'git://github.com/rails/arel.git'
20
- gem 'rspec-rails', '>= 2.5.0'
21
- gem 'sqlite3', '>= 1.3.3'
22
- gem 'mongoid', '2.0.0.rc.7'
23
- gem 'bson_ext', '~> 1.2'
24
- # platforms :mri_18 do
25
- # gem 'ruby-debug'
26
- # end
27
- # platforms :mri_19 do
28
- # gem 'ruby-debug19'
29
- # end
30
- end
1
+ gemspec
@@ -1,69 +1,41 @@
1
- GIT
2
- remote: git://github.com/rack/rack.git
3
- revision: e3ffeac0dc04bb8d5994b7923bf12e55d549a279
1
+ PATH
2
+ remote: .
4
3
  specs:
5
- rack (1.2.1)
4
+ kaminari (0.11.0)
5
+ kaminari
6
6
 
7
- GIT
8
- remote: git://github.com/rails/arel.git
9
- revision: dbc86c0f2c2fc3c8bacf35c67fb8e0967b0a8980
10
- specs:
11
- arel (2.0.7.beta.20110121165657)
12
-
13
- GIT
14
- remote: git://github.com/rails/rails.git
15
- revision: 289cc15f1a89a179116f67e5f666f4ff6d645f03
7
+ GEM
16
8
  specs:
17
- actionmailer (3.1.0.beta)
18
- actionpack (= 3.1.0.beta)
9
+ abstract (1.0.0)
10
+ actionmailer (3.0.7)
11
+ actionpack (= 3.0.7)
19
12
  mail (~> 2.2.15)
20
- actionpack (3.1.0.beta)
21
- activemodel (= 3.1.0.beta)
22
- activesupport (= 3.1.0.beta)
23
- builder (~> 3.0.0)
13
+ actionpack (3.0.7)
14
+ activemodel (= 3.0.7)
15
+ activesupport (= 3.0.7)
16
+ builder (~> 2.1.2)
24
17
  erubis (~> 2.6.6)
25
18
  i18n (~> 0.5.0)
26
19
  rack (~> 1.2.1)
27
- rack-cache (~> 1.0.0)
28
- rack-mount (~> 0.6.13)
20
+ rack-mount (~> 0.6.14)
29
21
  rack-test (~> 0.5.7)
30
22
  tzinfo (~> 0.3.23)
31
- activemodel (3.1.0.beta)
32
- activesupport (= 3.1.0.beta)
33
- bcrypt-ruby (~> 2.1.4)
34
- builder (~> 3.0.0)
23
+ activemodel (3.0.7)
24
+ activesupport (= 3.0.7)
25
+ builder (~> 2.1.2)
35
26
  i18n (~> 0.5.0)
36
- activerecord (3.1.0.beta)
37
- activemodel (= 3.1.0.beta)
38
- activesupport (= 3.1.0.beta)
27
+ activerecord (3.0.7)
28
+ activemodel (= 3.0.7)
29
+ activesupport (= 3.0.7)
39
30
  arel (~> 2.0.2)
40
31
  tzinfo (~> 0.3.23)
41
- activeresource (3.1.0.beta)
42
- activemodel (= 3.1.0.beta)
43
- activesupport (= 3.1.0.beta)
44
- activesupport (3.1.0.beta)
45
- rails (3.1.0.beta)
46
- actionmailer (= 3.1.0.beta)
47
- actionpack (= 3.1.0.beta)
48
- activerecord (= 3.1.0.beta)
49
- activeresource (= 3.1.0.beta)
50
- activesupport (= 3.1.0.beta)
51
- bundler (~> 1.0)
52
- railties (= 3.1.0.beta)
53
- railties (3.1.0.beta)
54
- actionpack (= 3.1.0.beta)
55
- activesupport (= 3.1.0.beta)
56
- rake (>= 0.8.7)
57
- thor (~> 0.14.4)
58
-
59
- GEM
60
- remote: http://rubygems.org/
61
- specs:
62
- abstract (1.0.0)
63
- bcrypt-ruby (2.1.4)
64
- bson (1.2.2)
65
- bson_ext (1.2.2)
66
- builder (3.0.0)
32
+ activeresource (3.0.7)
33
+ activemodel (= 3.0.7)
34
+ activesupport (= 3.0.7)
35
+ activesupport (3.0.7)
36
+ arel (2.0.9)
37
+ bson (1.3.0)
38
+ builder (2.1.2)
67
39
  capybara (0.4.1.2)
68
40
  celerity (>= 0.7.9)
69
41
  culerity (>= 0.2.4)
@@ -73,14 +45,15 @@ GEM
73
45
  rack-test (>= 0.5.4)
74
46
  selenium-webdriver (>= 0.0.27)
75
47
  xpath (~> 0.1.3)
76
- celerity (0.8.8)
77
- childprocess (0.1.7)
78
- ffi (~> 0.6.3)
48
+ celerity (0.8.9)
49
+ childprocess (0.1.8)
50
+ ffi (~> 1.0.6)
79
51
  culerity (0.2.15)
52
+ database_cleaner (0.6.6)
80
53
  diff-lcs (1.1.2)
81
54
  erubis (2.6.6)
82
55
  abstract (>= 1.0.0)
83
- ffi (0.6.3)
56
+ ffi (1.0.7)
84
57
  rake (>= 0.8.7)
85
58
  git (1.2.5)
86
59
  i18n (0.5.0)
@@ -89,27 +62,39 @@ GEM
89
62
  git (>= 1.2.5)
90
63
  rake
91
64
  json_pure (1.5.1)
92
- mail (2.2.15)
65
+ mail (2.2.17)
93
66
  activesupport (>= 2.3.6)
94
67
  i18n (>= 0.4.0)
95
68
  mime-types (~> 1.16)
96
69
  treetop (~> 1.4.8)
97
70
  mime-types (1.16)
98
- mongo (1.2.2)
99
- bson (>= 1.2.2)
100
- mongoid (2.0.0.rc.7)
71
+ mongo (1.3.0)
72
+ bson (>= 1.3.0)
73
+ mongoid (2.0.1)
101
74
  activemodel (~> 3.0)
102
- mongo (~> 1.2)
75
+ mongo (~> 1.3)
103
76
  tzinfo (~> 0.3.22)
104
77
  will_paginate (~> 3.0.pre)
105
78
  nokogiri (1.4.4)
106
79
  polyglot (0.3.1)
107
- rack-cache (1.0)
108
- rack (>= 0.4)
109
- rack-mount (0.6.13)
80
+ rack (1.2.2)
81
+ rack-mount (0.6.14)
110
82
  rack (>= 1.0.0)
111
83
  rack-test (0.5.7)
112
84
  rack (>= 1.0)
85
+ rails (3.0.7)
86
+ actionmailer (= 3.0.7)
87
+ actionpack (= 3.0.7)
88
+ activerecord (= 3.0.7)
89
+ activeresource (= 3.0.7)
90
+ activesupport (= 3.0.7)
91
+ bundler (~> 1.0)
92
+ railties (= 3.0.7)
93
+ railties (3.0.7)
94
+ actionpack (= 3.0.7)
95
+ activesupport (= 3.0.7)
96
+ rake (>= 0.8.7)
97
+ thor (~> 0.14.4)
113
98
  rake (0.8.7)
114
99
  rcov (0.9.9)
115
100
  rr (1.0.2)
@@ -127,9 +112,9 @@ GEM
127
112
  railties (~> 3.0)
128
113
  rspec (~> 2.5.0)
129
114
  rubyzip (0.9.4)
130
- selenium-webdriver (0.1.3)
131
- childprocess (~> 0.1.5)
132
- ffi (~> 0.6.3)
115
+ selenium-webdriver (0.1.4)
116
+ childprocess (>= 0.1.7)
117
+ ffi (>= 1.0.7)
133
118
  json_pure
134
119
  rubyzip
135
120
  sqlite3 (1.3.3)
@@ -138,7 +123,7 @@ GEM
138
123
  thor (0.14.6)
139
124
  treetop (1.4.9)
140
125
  polyglot (>= 0.3.1)
141
- tzinfo (0.3.24)
126
+ tzinfo (0.3.26)
142
127
  will_paginate (3.0.pre2)
143
128
  xpath (0.1.3)
144
129
  nokogiri (~> 1.3)
@@ -147,17 +132,16 @@ PLATFORMS
147
132
  ruby
148
133
 
149
134
  DEPENDENCIES
150
- arel!
151
- bson_ext (~> 1.2)
152
135
  bundler (>= 1.0.0)
153
- capybara (>= 0.4.1.1)
154
- jeweler (>= 1.5.2)
155
- mongoid (= 2.0.0.rc.7)
156
- rack!
157
- rails!
136
+ capybara
137
+ database_cleaner
138
+ jeweler
139
+ kaminari!
140
+ mongoid (>= 2)
141
+ rails (>= 3.0.0)
158
142
  rcov
159
- rr (>= 1.0.2)
160
- rspec (>= 2.5.0)
161
- rspec-rails (>= 2.5.0)
162
- sqlite3 (>= 1.3.3)
163
- steak (>= 1.1.0)
143
+ rr
144
+ rspec
145
+ rspec-rails
146
+ sqlite3
147
+ steak
@@ -156,6 +156,22 @@ Kaminari includes a handy template generator.
156
156
  or just hit the generator without specifying +THEME+ argument.
157
157
  % rails g kaminari:views
158
158
 
159
+ * multiple themes
160
+
161
+ To utilize multiple themes from within a single application, create a directory within the app/views/kaminari/ and move your custom template files into that directory.
162
+ rails g kaminari:views default (skip if you have existing kaminari views)
163
+ cd app/views/kaminari
164
+ mkdir my_custom_theme
165
+ cp _*.html.* my_custom_theme/
166
+
167
+ Next reference that directory when calling the paginate method:
168
+
169
+ % paginate @users, :theme => 'my_custom_theme'
170
+
171
+ Customize away!
172
+
173
+ Note: if the theme isn't present or none is specified, kaminari will default back to the views included within the gem.
174
+
159
175
 
160
176
  == For more information
161
177
 
data/Rakefile CHANGED
@@ -23,8 +23,18 @@ Jeweler::Tasks.new do |gem|
23
23
  gem.authors = ["Akira Matsuda"]
24
24
  # Include your dependencies below. Runtime dependencies are required when using your gem,
25
25
  # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
26
- gem.add_runtime_dependency 'rails', '>= 3.0.0'
27
- # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ gem.add_development_dependency 'rails', '>= 3.0.0'
27
+ gem.add_development_dependency 'bundler', '>= 1.0.0'
28
+ gem.add_development_dependency 'sqlite3'
29
+ gem.add_development_dependency 'mongoid', '>= 2'
30
+ gem.add_development_dependency 'rspec'
31
+ gem.add_development_dependency 'rspec-rails'
32
+ gem.add_development_dependency 'rr'
33
+ gem.add_development_dependency 'steak'
34
+ gem.add_development_dependency 'capybara'
35
+ gem.add_development_dependency 'database_cleaner'
36
+ gem.add_development_dependency 'rcov'
37
+ gem.add_development_dependency 'jeweler'
28
38
  end
29
39
  Jeweler::RubygemsDotOrgTasks.new
30
40
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.4
1
+ 0.11.0
@@ -0,0 +1,11 @@
1
+ <%# Link to the "First" page
2
+ - available local variables
3
+ url: url to the first page
4
+ current_page: a page object for the 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
+ -%>
9
+ <span class="first">
10
+ <%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote %>
11
+ </span>
@@ -0,0 +1,9 @@
1
+ -# Link to the "First" page
2
+ - available local variables
3
+ url: url to the first page
4
+ current_page: a page object for the 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
+ %span.first
9
+ = link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote
@@ -1,8 +1,8 @@
1
1
  <%# Non-link tag that stands for skipped pages...
2
2
  - available local variables
3
- current_page: the page number of currently displayed page
3
+ current_page: a page object for the currently displayed page
4
4
  num_pages: total number of pages
5
5
  per_page: number of items to fetch per page
6
6
  remote: data-remote
7
7
  -%>
8
- <span class="page"><%= raw(t 'views.pagination.truncate') %></span>
8
+ <span class="page gap"><%= raw(t 'views.pagination.truncate') %></span>
@@ -1,8 +1,8 @@
1
1
  -# Non-link tag that stands for skipped pages...
2
2
  - available local variables
3
- current_page: the page number of currently displayed page
3
+ current_page: a page object for the currently displayed page
4
4
  num_pages: total number of pages
5
5
  per_page: number of items to fetch per page
6
6
  remote: data-remote
7
- %span.page
7
+ %span.page.gap
8
8
  = raw(t 'views.pagination.truncate')
@@ -0,0 +1,11 @@
1
+ <%# Link to the "Last" page
2
+ - available local variables
3
+ url: url to the last page
4
+ current_page: a page object for the 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
+ -%>
9
+ <span class="last">
10
+ <%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote} %>
11
+ </span>
@@ -0,0 +1,9 @@
1
+ -# Link to the "Last" page
2
+ - available local variables
3
+ url: url to the last page
4
+ current_page: a page object for the 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
+ %span.last
9
+ = link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote}
@@ -1,11 +1,11 @@
1
- <%# "Next" with link
1
+ <%# Link to the "Next" page
2
2
  - available local variables
3
3
  url: url to the next page
4
- current_page: the page number of currently displayed page
4
+ current_page: a page object for the currently displayed page
5
5
  num_pages: total number of pages
6
6
  per_page: number of items to fetch per page
7
7
  remote: data-remote
8
8
  -%>
9
9
  <span class="next">
10
- <%= link_to raw(t 'views.pagination.next'), url, :class => 'next', :rel => 'next', :remote => remote %>
10
+ <%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote %>
11
11
  </span>
@@ -1,9 +1,9 @@
1
- -# "Next" with link
1
+ -# Link to the "Next" page
2
2
  - available local variables
3
3
  url: url to the next page
4
- current_page: the page number of currently displayed page
4
+ current_page: a page object for the currently displayed page
5
5
  num_pages: total number of pages
6
6
  per_page: number of items to fetch per page
7
7
  remote: data-remote
8
8
  %span.next
9
- = link_to raw(t 'views.pagination.next'), url, :class => 'next', :rel => 'next', :remote => remote
9
+ = link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote
@@ -0,0 +1,12 @@
1
+ <%# Link showing page number
2
+ - available local variables
3
+ page: a page object for "this" page
4
+ url: url to this page
5
+ current_page: a page object for the currently displayed page
6
+ num_pages: total number of pages
7
+ per_page: number of items to fetch per page
8
+ remote: data-remote
9
+ -%>
10
+ <span class="page<%= ' current' if page.current? %>">
11
+ <%= link_to_unless page.current?, page, url, opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
12
+ </span>
@@ -0,0 +1,10 @@
1
+ -# Link showing page number
2
+ - available local variables
3
+ page: a page object for "this" page
4
+ url: url to this page
5
+ current_page: a page object for the currently displayed page
6
+ num_pages: total number of pages
7
+ per_page: number of items to fetch per page
8
+ remote: data-remote
9
+ %span{:class => "page#{' current' if page.current?}"}
10
+ = link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}