kaminari 0.13.0 → 0.14.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/.gitignore +2 -0
- data/.travis.yml +8 -1
- data/CHANGELOG +46 -10
- data/README.rdoc +14 -3
- data/Rakefile +22 -2
- data/app/views/kaminari/_first_page.html.erb +1 -1
- data/app/views/kaminari/_first_page.html.haml +1 -1
- data/app/views/kaminari/_first_page.html.slim +1 -1
- data/app/views/kaminari/_gap.html.erb +1 -1
- data/app/views/kaminari/_gap.html.haml +1 -1
- data/app/views/kaminari/_gap.html.slim +1 -1
- data/app/views/kaminari/_last_page.html.erb +1 -1
- data/app/views/kaminari/_last_page.html.haml +1 -1
- data/app/views/kaminari/_last_page.html.slim +1 -1
- data/app/views/kaminari/_next_page.html.erb +1 -1
- data/app/views/kaminari/_next_page.html.haml +1 -1
- data/app/views/kaminari/_next_page.html.slim +1 -1
- data/app/views/kaminari/_page.html.erb +2 -2
- data/app/views/kaminari/_page.html.haml +1 -1
- data/app/views/kaminari/_page.html.slim +1 -1
- data/app/views/kaminari/_paginator.html.erb +1 -1
- data/app/views/kaminari/_paginator.html.haml +1 -1
- data/app/views/kaminari/_paginator.html.slim +1 -1
- data/app/views/kaminari/_prev_page.html.erb +1 -1
- data/app/views/kaminari/_prev_page.html.haml +1 -1
- data/app/views/kaminari/_prev_page.html.slim +1 -1
- data/config/locales/kaminari.yml +9 -0
- data/gemfiles/active_record_30.gemfile +7 -0
- data/gemfiles/active_record_31.gemfile +7 -0
- data/gemfiles/active_record_32.gemfile +7 -0
- data/gemfiles/data_mapper_12.gemfile +12 -0
- data/gemfiles/mongo_mapper.gemfile +7 -0
- data/gemfiles/mongoid_24.gemfile +7 -0
- data/gemfiles/mongoid_30.gemfile +7 -0
- data/gemfiles/sinatra.gemfile +10 -0
- data/kaminari.gemspec +6 -18
- data/lib/generators/kaminari/templates/kaminari_config.rb +1 -0
- data/lib/kaminari.rb +22 -57
- data/lib/kaminari/config.rb +7 -1
- data/lib/kaminari/grape.rb +4 -0
- data/lib/kaminari/helpers/action_view_extension.rb +84 -13
- data/lib/kaminari/helpers/paginator.rb +8 -5
- data/lib/kaminari/helpers/sinatra_helpers.rb +25 -6
- data/lib/kaminari/helpers/tags.rb +1 -1
- data/lib/kaminari/hooks.rb +12 -10
- data/lib/kaminari/models/active_record_relation_methods.rb +0 -3
- data/lib/kaminari/models/configuration_methods.rb +15 -1
- data/lib/kaminari/models/page_scope_methods.rb +6 -2
- data/lib/kaminari/models/plucky_criteria_methods.rb +3 -0
- data/lib/kaminari/railtie.rb +2 -2
- data/lib/kaminari/sinatra.rb +2 -10
- data/lib/kaminari/version.rb +1 -1
- data/spec/config/config_spec.rb +15 -0
- data/spec/fake_app/active_record/config.rb +3 -0
- data/spec/{fake_app.rb → fake_app/active_record/models.rb} +7 -34
- data/spec/fake_app/data_mapper/config.rb +1 -0
- data/spec/fake_app/data_mapper/models.rb +27 -0
- data/spec/fake_app/mongo_mapper/config.rb +2 -0
- data/spec/fake_app/mongo_mapper/models.rb +9 -0
- data/spec/fake_app/mongoid/config.rb +16 -0
- data/spec/fake_app/mongoid/models.rb +22 -0
- data/spec/fake_app/rails_app.rb +55 -0
- data/spec/fake_app/sinatra_app.rb +22 -0
- data/spec/fake_gem.rb +0 -2
- data/spec/helpers/action_view_extension_spec.rb +192 -45
- data/spec/helpers/helpers_spec.rb +8 -8
- data/spec/helpers/sinatra_helpers_spec.rb +129 -133
- data/spec/helpers/tags_spec.rb +8 -8
- data/spec/models/active_record/active_record_relation_methods_spec.rb +30 -0
- data/spec/models/active_record/default_per_page_spec.rb +32 -0
- data/spec/models/active_record/max_per_page_spec.rb +32 -0
- data/spec/models/active_record/scopes_spec.rb +166 -0
- data/spec/models/array_spec.rb +7 -7
- data/spec/models/data_mapper/data_mapper_spec.rb +155 -0
- data/spec/models/mongo_mapper/mongo_mapper_spec.rb +72 -0
- data/spec/models/mongoid/mongoid_spec.rb +110 -0
- data/spec/requests/users_spec.rb +0 -1
- data/spec/spec_helper.rb +20 -18
- data/spec/spec_helper_for_sinatra.rb +22 -0
- data/spec/support/database_cleaner.rb +4 -1
- metadata +93 -141
- data/spec/models/active_record_relation_methods_spec.rb +0 -28
- data/spec/models/data_mapper_spec.rb +0 -181
- data/spec/models/default_per_page_spec.rb +0 -29
- data/spec/models/mongo_mapper_spec.rb +0 -82
- data/spec/models/mongoid_spec.rb +0 -129
- data/spec/models/scopes_spec.rb +0 -163
@@ -0,0 +1,12 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'railties', '>= 3.2.3'
|
4
|
+
gem 'dm-core', '>= 1.2.0'
|
5
|
+
gem 'dm-migrations', '>= 1.2.0'
|
6
|
+
gem 'dm-aggregates', '>= 1.2.0'
|
7
|
+
gem 'dm-transactions', '>= 1.2.0'
|
8
|
+
gem 'dm-active_model', '>= 1.2.0'
|
9
|
+
gem 'dm-sqlite-adapter', '>= 1.2.0'
|
10
|
+
gem 'rspec-rails', '>= 2.0'
|
11
|
+
|
12
|
+
gemspec :path => '../'
|
data/kaminari.gemspec
CHANGED
@@ -21,28 +21,16 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.licenses = ['MIT']
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
s.add_dependency 'activesupport', ['>= 3.0.0']
|
25
|
+
s.add_dependency 'actionpack', ['>= 3.0.0']
|
26
|
+
|
27
27
|
s.add_development_dependency 'bundler', ['>= 1.0.0']
|
28
|
+
s.add_development_dependency 'rake', ['>= 0']
|
28
29
|
s.add_development_dependency 'sqlite3', ['>= 0']
|
29
|
-
|
30
|
-
s.add_development_dependency gem, ['>= 3.0.0']
|
31
|
-
end
|
32
|
-
s.add_development_dependency 'sinatra', ['>= 1.3']
|
33
|
-
s.add_development_dependency 'mongoid', ['>= 2']
|
34
|
-
s.add_development_dependency 'mongo_mapper', ['>= 0.9']
|
35
|
-
s.add_development_dependency 'dm-core', ['>= 1.1.0']
|
36
|
-
s.add_development_dependency 'dm-migrations', ['>= 1.1.0']
|
37
|
-
s.add_development_dependency 'dm-aggregates', ['>= 1.1.0']
|
38
|
-
s.add_development_dependency 'dm-sqlite-adapter', ['>= 1.1.0']
|
30
|
+
s.add_development_dependency 'tzinfo', ['>= 0']
|
39
31
|
s.add_development_dependency 'rspec', ['>= 0']
|
40
|
-
s.add_development_dependency 'rspec-rails', ['>= 0']
|
41
32
|
s.add_development_dependency 'rr', ['>= 0']
|
42
33
|
s.add_development_dependency 'capybara', ['>= 1.0']
|
43
34
|
s.add_development_dependency 'database_cleaner', ['>= 0']
|
44
|
-
s.add_development_dependency '
|
45
|
-
s.add_development_dependency 'rack-test', ['>= 0']
|
46
|
-
s.add_development_dependency 'sinatra-contrib', ['~> 1.3']
|
47
|
-
s.add_development_dependency 'nokogiri', ['>= 0']
|
35
|
+
s.add_development_dependency 'rdoc', ['>= 0']
|
48
36
|
end
|
data/lib/kaminari.rb
CHANGED
@@ -1,73 +1,38 @@
|
|
1
1
|
module Kaminari
|
2
|
-
|
3
|
-
frameworks = []
|
4
|
-
case
|
5
|
-
when rails? then frameworks << 'rails'
|
6
|
-
when sinatra? then frameworks << 'sinatra/base'
|
7
|
-
end
|
8
|
-
frameworks
|
9
|
-
end
|
2
|
+
end
|
10
3
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
raise "Failed to load framework #{framework.inspect}. Have you added it to Gemfile?"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
4
|
+
# load Rails/Railtie
|
5
|
+
begin
|
6
|
+
require 'rails'
|
7
|
+
rescue LoadError
|
8
|
+
#do nothing
|
9
|
+
end
|
21
10
|
|
22
|
-
|
23
|
-
$stderr.puts <<-EOC
|
11
|
+
$stderr.puts <<-EOC if !defined?(Rails) && !defined?(Sinatra) && !defined?(Grape)
|
24
12
|
warning: no framework detected.
|
25
13
|
would you check out if your Gemfile appropriately configured?
|
26
14
|
---- e.g. ----
|
27
15
|
when Rails:
|
28
|
-
gem 'rails'
|
29
16
|
gem 'kaminari'
|
30
17
|
|
31
18
|
when Sinatra/Padrino:
|
32
19
|
gem 'kaminari', :require => 'kaminari/sinatra'
|
33
20
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
def self.load_kaminari!
|
38
|
-
require 'kaminari/config'
|
39
|
-
require 'kaminari/helpers/action_view_extension'
|
40
|
-
require 'kaminari/helpers/paginator'
|
41
|
-
require 'kaminari/models/page_scope_methods'
|
42
|
-
require 'kaminari/models/configuration_methods'
|
43
|
-
end
|
21
|
+
when Grape:
|
22
|
+
gem 'kaminari', :require => 'kaminari/grape'
|
44
23
|
|
45
|
-
|
46
|
-
load_framework!
|
47
|
-
load_kaminari!
|
48
|
-
require 'kaminari/hooks'
|
49
|
-
if rails?
|
50
|
-
require 'kaminari/railtie'
|
51
|
-
require 'kaminari/engine'
|
52
|
-
elsif sinatra?
|
53
|
-
require 'kaminari/sinatra'
|
54
|
-
else
|
55
|
-
Kaminari::Hooks.init!
|
56
|
-
end
|
57
|
-
end
|
24
|
+
EOC
|
58
25
|
|
59
|
-
|
60
|
-
|
61
|
-
|
26
|
+
# load Kaminari components
|
27
|
+
require 'kaminari/config'
|
28
|
+
require 'kaminari/helpers/action_view_extension'
|
29
|
+
require 'kaminari/helpers/paginator'
|
30
|
+
require 'kaminari/models/page_scope_methods'
|
31
|
+
require 'kaminari/models/configuration_methods'
|
32
|
+
require 'kaminari/hooks'
|
62
33
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
def self.sinatra?
|
69
|
-
defined?(::Sinatra)
|
70
|
-
end
|
34
|
+
# if not using Railtie, call `Kaminari::Hooks.init` directly
|
35
|
+
if defined? Rails
|
36
|
+
require 'kaminari/railtie'
|
37
|
+
require 'kaminari/engine'
|
71
38
|
end
|
72
|
-
|
73
|
-
Kaminari.load!
|
data/lib/kaminari/config.rb
CHANGED
@@ -18,21 +18,27 @@ module Kaminari
|
|
18
18
|
class Configuration #:nodoc:
|
19
19
|
include ActiveSupport::Configurable
|
20
20
|
config_accessor :default_per_page
|
21
|
+
config_accessor :max_per_page
|
21
22
|
config_accessor :window
|
22
23
|
config_accessor :outer_window
|
23
24
|
config_accessor :left
|
24
25
|
config_accessor :right
|
25
26
|
config_accessor :page_method_name
|
26
|
-
config_accessor :param_name
|
27
27
|
|
28
28
|
def param_name
|
29
29
|
config.param_name.respond_to?(:call) ? config.param_name.call : config.param_name
|
30
30
|
end
|
31
|
+
|
32
|
+
# define param_name writer (copied from AS::Configurable)
|
33
|
+
writer, line = 'def param_name=(value); config.param_name = value; end', __LINE__
|
34
|
+
singleton_class.class_eval writer, __FILE__, line
|
35
|
+
class_eval writer, __FILE__, line
|
31
36
|
end
|
32
37
|
|
33
38
|
# this is ugly. why can't we pass the default value to config_accessor...?
|
34
39
|
configure do |config|
|
35
40
|
config.default_per_page = 25
|
41
|
+
config.max_per_page = nil
|
36
42
|
config.window = 4
|
37
43
|
config.outer_window = 0
|
38
44
|
config.left = 0
|
@@ -15,10 +15,35 @@ module Kaminari
|
|
15
15
|
# * <tt>:remote</tt> - Ajax? (false by default)
|
16
16
|
# * <tt>:ANY_OTHER_VALUES</tt> - Any other hash key & values would be directly passed into each tag as :locals value.
|
17
17
|
def paginate(scope, options = {}, &block)
|
18
|
-
paginator = Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :
|
18
|
+
paginator = Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false)
|
19
19
|
paginator.to_s
|
20
20
|
end
|
21
21
|
|
22
|
+
# A simple "Twitter like" pagination link that creates a link to the previous page.
|
23
|
+
#
|
24
|
+
# ==== Examples
|
25
|
+
# Basic usage:
|
26
|
+
#
|
27
|
+
# <%= link_to_previous_page @items, 'Previous Page' %>
|
28
|
+
#
|
29
|
+
# Ajax:
|
30
|
+
#
|
31
|
+
# <%= link_to_previous_page @items, 'Previous Page', :remote => true %>
|
32
|
+
#
|
33
|
+
# By default, it renders nothing if there are no more results on the previous page.
|
34
|
+
# You can customize this output by passing a block.
|
35
|
+
#
|
36
|
+
# <%= link_to_previous_page @users, 'Previous Page' do %>
|
37
|
+
# <span>At the Beginning</span>
|
38
|
+
# <% end %>
|
39
|
+
def link_to_previous_page(scope, name, options = {}, &block)
|
40
|
+
params = options.delete(:params) || {}
|
41
|
+
param_name = options.delete(:param_name) || Kaminari.config.param_name
|
42
|
+
link_to_unless scope.first_page?, name, params.merge(param_name => (scope.current_page - 1)), options.reverse_merge(:rel => 'previous') do
|
43
|
+
block.call if block
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
22
47
|
# A simple "Twitter like" pagination link that creates a link to the next page.
|
23
48
|
#
|
24
49
|
# ==== Examples
|
@@ -55,26 +80,72 @@ module Kaminari
|
|
55
80
|
#
|
56
81
|
# By default, the message will use the humanized class name of objects
|
57
82
|
# in collection: for instance, "project types" for ProjectType models.
|
83
|
+
# The namespace will be cutted out and only the last name will be used.
|
58
84
|
# Override this with the <tt>:entry_name</tt> parameter:
|
59
85
|
#
|
60
86
|
# <%= page_entries_info @posts, :entry_name => 'item' %>
|
61
87
|
# #-> Displaying items 6 - 10 of 26 in total
|
62
88
|
def page_entries_info(collection, options = {})
|
63
|
-
entry_name = options[:entry_name]
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
89
|
+
entry_name = if options[:entry_name]
|
90
|
+
options[:entry_name]
|
91
|
+
elsif collection.empty? || collection.is_a?(PaginatableArray)
|
92
|
+
'entry'
|
93
|
+
else
|
94
|
+
if collection.respond_to? :model # DataMapper
|
95
|
+
collection.model.model_name.human.downcase
|
96
|
+
else # AR
|
97
|
+
collection.model_name.human.downcase
|
69
98
|
end
|
99
|
+
end
|
100
|
+
entry_name = entry_name.pluralize unless collection.total_count == 1
|
101
|
+
|
102
|
+
if collection.total_pages < 2
|
103
|
+
t('helpers.page_entries_info.one_page.display_entries', :entry_name => entry_name, :count => collection.total_count)
|
104
|
+
else
|
105
|
+
first = collection.offset_value + 1
|
106
|
+
last = collection.last_page? ? collection.total_count : collection.offset_value + collection.limit_value
|
107
|
+
t('helpers.page_entries_info.more_pages.display_entries', :entry_name => entry_name, :first => first, :last => last, :total => collection.total_count)
|
108
|
+
end.html_safe
|
109
|
+
end
|
110
|
+
|
111
|
+
# Renders rel="next" and rel="prev" links to be used in the head.
|
112
|
+
#
|
113
|
+
# ==== Examples
|
114
|
+
# Basic usage:
|
115
|
+
#
|
116
|
+
# In head:
|
117
|
+
# <head>
|
118
|
+
# <title>My Website</title>
|
119
|
+
# <%= yield :head %>
|
120
|
+
# </head>
|
121
|
+
#
|
122
|
+
# Somewhere in body:
|
123
|
+
# <% content_for :head do %>
|
124
|
+
# <%= rel_next_prev_link_tags @items %>
|
125
|
+
# <% end %>
|
126
|
+
#
|
127
|
+
# #-> <link rel="next" href="/items/page/3" /><link rel="prev" href="/items/page/1" />
|
128
|
+
#
|
129
|
+
def rel_next_prev_link_tags(scope, options = {})
|
130
|
+
params = options.delete(:params) || {}
|
131
|
+
param_name = options.delete(:param_name) || Kaminari.config.param_name
|
132
|
+
|
133
|
+
output = ""
|
134
|
+
|
135
|
+
if !scope.first_page? && !scope.last_page?
|
136
|
+
# If not first and not last, then output both links.
|
137
|
+
output << '<link rel="next" href="' + url_for(params.merge(param_name => (scope.current_page + 1))) + '"/>'
|
138
|
+
output << '<link rel="prev" href="' + url_for(params.merge(param_name => (scope.current_page - 1))) + '"/>'
|
139
|
+
elsif scope.first_page?
|
140
|
+
# If first page, add next link unless last page.
|
141
|
+
output << '<link rel="next" href="' + url_for(params.merge(param_name => (scope.current_page + 1))) + '"/>' unless scope.last_page?
|
70
142
|
else
|
71
|
-
|
72
|
-
|
73
|
-
offset + 1,
|
74
|
-
offset + collection.count,
|
75
|
-
collection.total_count
|
76
|
-
]
|
143
|
+
# If last page, add prev link unless first page.
|
144
|
+
output << '<link rel="prev" href="' + url_for(params.merge(param_name => (scope.current_page - 1))) + '"/>' unless scope.first_page?
|
77
145
|
end
|
146
|
+
|
147
|
+
output.html_safe
|
78
148
|
end
|
149
|
+
|
79
150
|
end
|
80
151
|
end
|
@@ -23,13 +23,16 @@ module Kaminari
|
|
23
23
|
@template, @options = template, options
|
24
24
|
@theme = @options[:theme] ? "#{@options[:theme]}/" : ''
|
25
25
|
@options[:current_page] = PageProxy.new @window_options.merge(@options), @options[:current_page], nil
|
26
|
+
#FIXME for compatibility. remove num_pages at some time in the future
|
27
|
+
@options[:total_pages] ||= @options[:num_pages]
|
28
|
+
@last = nil
|
26
29
|
# initialize the output_buffer for Context
|
27
30
|
@output_buffer = ActionView::OutputBuffer.new
|
28
31
|
end
|
29
32
|
|
30
33
|
# render given block as a view template
|
31
34
|
def render(&block)
|
32
|
-
instance_eval
|
35
|
+
instance_eval(&block) if @options[:total_pages] > 1
|
33
36
|
@output_buffer
|
34
37
|
end
|
35
38
|
|
@@ -50,10 +53,10 @@ module Kaminari
|
|
50
53
|
|
51
54
|
def relevant_pages(options)
|
52
55
|
left_window_plus_one = 1.upto(options[:left] + 1).to_a
|
53
|
-
right_window_plus_one = (options[:
|
56
|
+
right_window_plus_one = (options[:total_pages] - options[:right]).upto(options[:total_pages]).to_a
|
54
57
|
inside_window_plus_each_sides = (options[:current_page] - options[:window] - 1).upto(options[:current_page] + options[:window] + 1).to_a
|
55
58
|
|
56
|
-
(left_window_plus_one + inside_window_plus_each_sides + right_window_plus_one).uniq.sort.reject {|x| (x < 1) || (x > options[:
|
59
|
+
(left_window_plus_one + inside_window_plus_each_sides + right_window_plus_one).uniq.sort.reject {|x| (x < 1) || (x > options[:total_pages])}
|
57
60
|
end
|
58
61
|
private :relevant_pages
|
59
62
|
|
@@ -114,7 +117,7 @@ module Kaminari
|
|
114
117
|
|
115
118
|
# the last page or not
|
116
119
|
def last?
|
117
|
-
@page == @options[:
|
120
|
+
@page == @options[:total_pages]
|
118
121
|
end
|
119
122
|
|
120
123
|
# the previous page or not
|
@@ -134,7 +137,7 @@ module Kaminari
|
|
134
137
|
|
135
138
|
# within the right outer window or not
|
136
139
|
def right_outer?
|
137
|
-
@options[:
|
140
|
+
@options[:total_pages] - @page < @options[:right]
|
138
141
|
end
|
139
142
|
|
140
143
|
# inside the inner window or not
|
@@ -14,8 +14,14 @@ module Kaminari::Helpers
|
|
14
14
|
|
15
15
|
alias included registered
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
class ActionViewTemplateProxy
|
19
|
+
include Padrino::Helpers::OutputHelpers
|
20
|
+
include Padrino::Helpers::TagHelpers
|
21
|
+
include Padrino::Helpers::AssetTagHelpers
|
22
|
+
include Padrino::Helpers::FormatHelpers
|
23
|
+
include Padrino::Helpers::TranslationHelpers
|
24
|
+
|
19
25
|
def initialize(opts={})
|
20
26
|
@current_path = opts[:current_path]
|
21
27
|
@param_name = (opts[:param_name] || :page).to_sym
|
@@ -38,12 +44,25 @@ module Kaminari::Helpers
|
|
38
44
|
query = @current_params.merge(extra_params)
|
39
45
|
@current_path + (query.empty? ? '' : "?#{query.to_query}")
|
40
46
|
end
|
41
|
-
|
47
|
+
|
48
|
+
def link_to_unless(condition, name, options = {}, html_options = {}, &block)
|
49
|
+
options = url_for(options) if options.is_a? Hash
|
50
|
+
if condition
|
51
|
+
if block_given?
|
52
|
+
block.arity <= 1 ? capture(name, &block) : capture(name, options, html_options, &block)
|
53
|
+
else
|
54
|
+
name
|
55
|
+
end
|
56
|
+
else
|
57
|
+
link_to(name, options, html_options)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
42
61
|
def params
|
43
62
|
@current_params
|
44
63
|
end
|
45
64
|
end
|
46
|
-
|
65
|
+
|
47
66
|
module HelperMethods
|
48
67
|
# A helper that renders the pagination links - for Sinatra.
|
49
68
|
#
|
@@ -63,7 +82,7 @@ module Kaminari::Helpers
|
|
63
82
|
current_params = Rack::Utils.parse_query(env['QUERY_STRING']).symbolize_keys rescue {}
|
64
83
|
paginator = Kaminari::Helpers::Paginator.new(
|
65
84
|
ActionViewTemplateProxy.new(:current_params => current_params, :current_path => current_path, :param_name => options[:param_name] || Kaminari.config.param_name),
|
66
|
-
options.reverse_merge(:current_page => scope.current_page, :
|
85
|
+
options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false)
|
67
86
|
)
|
68
87
|
paginator.to_s
|
69
88
|
end
|
@@ -88,10 +107,10 @@ module Kaminari::Helpers
|
|
88
107
|
def link_to_next_page(scope, name, options = {})
|
89
108
|
params = options.delete(:params) || (Rack::Utils.parse_query(env['QUERY_STRING']).symbolize_keys rescue {})
|
90
109
|
param_name = options.delete(:param_name) || Kaminari.config.param_name
|
91
|
-
placeholder = options.delete(:placeholder)
|
110
|
+
placeholder = options.delete(:placeholder)
|
92
111
|
query = params.merge(param_name => (scope.current_page + 1))
|
93
112
|
unless scope.last_page?
|
94
|
-
link_to name, env['PATH_INFO'] + (query.empty? ? '' : "?#{query.to_query}"), options.
|
113
|
+
link_to name, env['PATH_INFO'] + (query.empty? ? '' : "?#{query.to_query}"), options.reverse_merge(:rel => 'next')
|
95
114
|
else
|
96
115
|
placeholder
|
97
116
|
end
|