kaminari 0.12.0 → 0.12.1
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 +15 -1
- data/app/views/kaminari/_first_page.html.slim +10 -0
- data/app/views/kaminari/_gap.html.slim +9 -0
- data/app/views/kaminari/_last_page.html.slim +10 -0
- data/app/views/kaminari/_next_page.html.slim +10 -0
- data/app/views/kaminari/_page.html.slim +11 -0
- data/app/views/kaminari/_paginator.html.slim +19 -0
- data/app/views/kaminari/_prev_page.html.slim +10 -0
- data/lib/generators/kaminari/templates/kaminari_config.rb +1 -0
- data/lib/kaminari/config.rb +2 -0
- data/lib/kaminari/helpers/action_view_extension.rb +1 -1
- data/lib/kaminari/helpers/paginator.rb +15 -20
- data/lib/kaminari/models/array_extension.rb +1 -1
- data/lib/kaminari/version.rb +1 -1
- data/spec/config/config_spec.rb +6 -0
- metadata +11 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
== 0.12.1
|
2
|
+
|
3
|
+
* Slim template support #93 [detrain]
|
4
|
+
|
5
|
+
* Use Kaminari.config to specify default value for param_name #94 [avsej]
|
6
|
+
|
7
|
+
* Fixed "super called outside of method" error happened in particular versions
|
8
|
+
of Ruby 1.8.7 #91 [Skulli]
|
9
|
+
|
10
|
+
* _paginate.html.erb isn't rendered with custom theme #97 [danlunde]
|
11
|
+
|
12
|
+
* I don't know why but this version seems like working with Haml 3.1.0 #96
|
13
|
+
[FlyboyArt]
|
14
|
+
|
1
15
|
== 0.12.0
|
2
16
|
|
3
17
|
* General configuration options #41 #62 [javierv, iain]
|
@@ -6,7 +20,7 @@
|
|
6
20
|
Also, here comes a generator command that generates the default
|
7
21
|
configuration file into your app's config/initilizers directory.
|
8
22
|
|
9
|
-
* Generic pagination support for Array object #47 #68 #74 [lda ened jianlin]
|
23
|
+
* Generic pagination support for Array object #47 #68 #74 [lda, ened, jianlin]
|
10
24
|
You can now paginate through any kind of Arrayish object in this way:
|
11
25
|
Kaminari.paginate_array(my_array_object).page(params[:page]).per(10)
|
12
26
|
|
@@ -0,0 +1,10 @@
|
|
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
|
10
|
+
'
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/ Non-link tag that stands for skipped pages...
|
2
|
+
- available local variables
|
3
|
+
current_page : a page object for the 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
|
+
span.page.gap
|
8
|
+
== raw(t 'views.pagination.truncate')
|
9
|
+
'
|
@@ -0,0 +1,10 @@
|
|
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}
|
10
|
+
'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/ Link to the "Next" page
|
2
|
+
- available local variables
|
3
|
+
url : url to the next 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.next
|
9
|
+
== link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote
|
10
|
+
'
|
@@ -0,0 +1,11 @@
|
|
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}
|
11
|
+
'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/ The container tag
|
2
|
+
- available local variables
|
3
|
+
current_page : a page object for the 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
|
+
paginator : the paginator that renders the pagination tags inside
|
8
|
+
|
9
|
+
== paginator.render do
|
10
|
+
nav.pagination
|
11
|
+
== first_page_tag unless current_page.first?
|
12
|
+
== prev_page_tag unless current_page.first?
|
13
|
+
- each_page do |page|
|
14
|
+
- if page.left_outer? || page.right_outer? || page.inside_window?
|
15
|
+
== page_tag page
|
16
|
+
- elsif !page.was_truncated?
|
17
|
+
== gap_tag
|
18
|
+
== next_page_tag unless current_page.last?
|
19
|
+
== last_page_tag unless current_page.last?
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/ Link to the "Previous" page
|
2
|
+
- available local variables
|
3
|
+
url : url to the previous 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.prev
|
9
|
+
== link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote
|
10
|
+
'
|
data/lib/kaminari/config.rb
CHANGED
@@ -22,6 +22,7 @@ module Kaminari
|
|
22
22
|
config_accessor :outer_window
|
23
23
|
config_accessor :left
|
24
24
|
config_accessor :right
|
25
|
+
config_accessor :param_name
|
25
26
|
end
|
26
27
|
|
27
28
|
# this is ugly. why can't we pass the default value to config_accessor...?
|
@@ -31,5 +32,6 @@ module Kaminari
|
|
31
32
|
config.outer_window = 0
|
32
33
|
config.left = 0
|
33
34
|
config.right = 0
|
35
|
+
config.param_name = :page
|
34
36
|
end
|
35
37
|
end
|
@@ -18,7 +18,7 @@ module Kaminari
|
|
18
18
|
# * <tt>:remote</tt> - Ajax? (false by default)
|
19
19
|
# * <tt>:ANY_OTHER_VALUES</tt> - Any other hash key & values would be directly passed into each tag as :locals value.
|
20
20
|
def paginate(scope, options = {}, &block)
|
21
|
-
Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :per_page => scope.limit_value, :param_name =>
|
21
|
+
Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -14,6 +14,7 @@ module Kaminari
|
|
14
14
|
h[:right] = outer_window if h[:right] == 0
|
15
15
|
end
|
16
16
|
@template, @options = template, options
|
17
|
+
@theme = @options[:theme] ? "#{@options[:theme]}/" : ''
|
17
18
|
@options[:current_page] = PageProxy.new @window_options.merge(@options), @options[:current_page], nil
|
18
19
|
# so that this instance can actually "render". Black magic?
|
19
20
|
@output_buffer = ActionView::OutputBuffer.new
|
@@ -47,29 +48,23 @@ module Kaminari
|
|
47
48
|
end
|
48
49
|
|
49
50
|
def to_s #:nodoc:
|
50
|
-
|
51
|
-
|
51
|
+
subscriber = ActionView::LogSubscriber.log_subscribers.detect {|ls| ls.is_a? ActionView::LogSubscriber}
|
52
|
+
return super @window_options.merge(@options).merge :paginator => self unless subscriber
|
53
|
+
|
54
|
+
# dirty hack to suppress logging render_partial
|
55
|
+
class << subscriber
|
56
|
+
alias_method :render_partial_with_logging, :render_partial
|
57
|
+
# do nothing
|
58
|
+
def render_partial(event); end
|
52
59
|
end
|
53
|
-
end
|
54
60
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
alias_method :render_partial_with_logging, :render_partial
|
61
|
-
# do nothing
|
62
|
-
def render_partial(event); end
|
63
|
-
end
|
64
|
-
ret = blk.call
|
65
|
-
class << subscriber
|
66
|
-
alias_method :render_partial, :render_partial_with_logging
|
67
|
-
undef :render_partial_with_logging
|
68
|
-
end
|
69
|
-
ret
|
70
|
-
else
|
71
|
-
blk.call
|
61
|
+
ret = super @window_options.merge(@options).merge :paginator => self
|
62
|
+
|
63
|
+
class << subscriber
|
64
|
+
alias_method :render_partial, :render_partial_with_logging
|
65
|
+
undef :render_partial_with_logging
|
72
66
|
end
|
67
|
+
ret
|
73
68
|
end
|
74
69
|
|
75
70
|
# Wraps a "page number" and provides some utility methods
|
@@ -7,7 +7,7 @@ module Kaminari
|
|
7
7
|
|
8
8
|
def initialize(original_array, limit_val = default_per_page, offset_val = 0) #:nodoc:
|
9
9
|
@_original_array, @_limit_value, @_offset_value = original_array, limit_val, offset_val
|
10
|
-
super
|
10
|
+
super(original_array[offset_val, limit_val] || [])
|
11
11
|
end
|
12
12
|
|
13
13
|
# items at the specified "page"
|
data/lib/kaminari/version.rb
CHANGED
data/spec/config/config_spec.rb
CHANGED
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: 45
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 12
|
9
|
-
-
|
10
|
-
version: 0.12.
|
9
|
+
- 1
|
10
|
+
version: 0.12.1
|
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-04-
|
18
|
+
date: 2011-04-25 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rails
|
@@ -182,18 +182,25 @@ files:
|
|
182
182
|
- Rakefile
|
183
183
|
- app/views/kaminari/_first_page.html.erb
|
184
184
|
- app/views/kaminari/_first_page.html.haml
|
185
|
+
- app/views/kaminari/_first_page.html.slim
|
185
186
|
- app/views/kaminari/_gap.html.erb
|
186
187
|
- app/views/kaminari/_gap.html.haml
|
188
|
+
- app/views/kaminari/_gap.html.slim
|
187
189
|
- app/views/kaminari/_last_page.html.erb
|
188
190
|
- app/views/kaminari/_last_page.html.haml
|
191
|
+
- app/views/kaminari/_last_page.html.slim
|
189
192
|
- app/views/kaminari/_next_page.html.erb
|
190
193
|
- app/views/kaminari/_next_page.html.haml
|
194
|
+
- app/views/kaminari/_next_page.html.slim
|
191
195
|
- app/views/kaminari/_page.html.erb
|
192
196
|
- app/views/kaminari/_page.html.haml
|
197
|
+
- app/views/kaminari/_page.html.slim
|
193
198
|
- app/views/kaminari/_paginator.html.erb
|
194
199
|
- app/views/kaminari/_paginator.html.haml
|
200
|
+
- app/views/kaminari/_paginator.html.slim
|
195
201
|
- app/views/kaminari/_prev_page.html.erb
|
196
202
|
- app/views/kaminari/_prev_page.html.haml
|
203
|
+
- app/views/kaminari/_prev_page.html.slim
|
197
204
|
- config/locales/kaminari.yml
|
198
205
|
- kaminari.gemspec
|
199
206
|
- lib/generators/kaminari/config_generator.rb
|