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 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
+ '
@@ -4,4 +4,5 @@ Kaminari.configure do |config|
4
4
  # config.outer_window = 0
5
5
  # config.left = 0
6
6
  # config.right = 0
7
+ # config.param_name = :page
7
8
  end
@@ -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 => :page, :remote => false)
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
- suppress_logging_render_partial do
51
- super @window_options.merge(@options).merge :paginator => self
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
- private
56
- # dirty hack
57
- def suppress_logging_render_partial(&blk)
58
- if subscriber = ActionView::LogSubscriber.log_subscribers.detect {|ls| ls.is_a? ActionView::LogSubscriber}
59
- class << subscriber
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 (original_array[offset_val, limit_val] || [])
10
+ super(original_array[offset_val, limit_val] || [])
11
11
  end
12
12
 
13
13
  # items at the specified "page"
@@ -1,3 +1,3 @@
1
1
  module Kaminari
2
- VERSION = '0.12.0'
2
+ VERSION = '0.12.1'
3
3
  end
@@ -40,4 +40,10 @@ describe Kaminari::Configuration do
40
40
  its(:right) { should == 0 }
41
41
  end
42
42
  end
43
+
44
+ describe 'param_name' do
45
+ context 'by default' do
46
+ its(:param_name) { should == :page }
47
+ end
48
+ end
43
49
  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: 47
4
+ hash: 45
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 12
9
- - 0
10
- version: 0.12.0
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-22 00:00:00 Z
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