kaminari 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +200 -0
- data/.gitignore +1 -1
- data/CHANGELOG.md +68 -3
- data/Gemfile +71 -0
- data/README.md +58 -27
- data/Rakefile +0 -31
- data/kaminari.gemspec +6 -1
- data/lib/kaminari/version.rb +1 -1
- data/lib/kaminari.rb +1 -0
- metadata +165 -170
- data/.codeclimate.yml +0 -19
- data/.travis.yml +0 -98
- data/gemfiles/active_record_41.gemfile +0 -28
- data/gemfiles/active_record_42.gemfile +0 -28
- data/gemfiles/active_record_50.gemfile +0 -24
- data/gemfiles/active_record_51.gemfile +0 -24
- data/gemfiles/active_record_52.gemfile +0 -24
- data/gemfiles/active_record_60.gemfile +0 -26
- data/gemfiles/active_record_edge.gemfile +0 -33
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 895d56c9232b2e3c837d8edd7b6bd47f8b40ee2354140154e92f28053b668046
|
|
4
|
+
data.tar.gz: 9ec5452a55a686301d9eb3240a2d88f7ec4f7a60ecfad550f6b488b9a1c56c50
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d35ab8abbc7bd93434e1dba5a25bc7f17f7ee6b316d641d76dd6c2c8113fda32ed3cd257412d3c2c7c52d8f1cab9ce822f8c6a70b0daf773dce6574630046a8
|
|
7
|
+
data.tar.gz: 4998461f09d935cebb97ab8024deb5fb43b873622350e5d3ac5fc4a74d12620c0162d485ab229e029a153fb92d9851ee739d573fbd4b008c21ac43cbf0b68fb3
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
name: build
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
schedule:
|
|
7
|
+
- cron: '58 23 * * *'
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
services:
|
|
12
|
+
postgresql:
|
|
13
|
+
image: postgres:10
|
|
14
|
+
ports:
|
|
15
|
+
- 5432:5432
|
|
16
|
+
env:
|
|
17
|
+
POSTGRES_PASSWORD: postgres
|
|
18
|
+
mysql:
|
|
19
|
+
image: mysql:5.7
|
|
20
|
+
env:
|
|
21
|
+
MYSQL_ROOT_PASSWORD: root
|
|
22
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
|
|
23
|
+
ports:
|
|
24
|
+
- 3306:3306
|
|
25
|
+
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10
|
|
26
|
+
strategy:
|
|
27
|
+
fail-fast: true
|
|
28
|
+
|
|
29
|
+
matrix:
|
|
30
|
+
ruby_version: [ruby-head, '4.0', '3.4', '3.3', '3.2', '3.1']
|
|
31
|
+
rails_version: [edge, '8.1', '8.0', '7.2', '7.1', '7.0', '6.1']
|
|
32
|
+
db: ['sqlite3', 'postgresql', 'mysql']
|
|
33
|
+
|
|
34
|
+
exclude:
|
|
35
|
+
- ruby_version: '3.1'
|
|
36
|
+
rails_version: 'edge'
|
|
37
|
+
- ruby_version: '3.1'
|
|
38
|
+
rails_version: '8.1'
|
|
39
|
+
- ruby_version: '3.1'
|
|
40
|
+
rails_version: '8.0'
|
|
41
|
+
|
|
42
|
+
include:
|
|
43
|
+
- ruby_version: 'truffleruby-head'
|
|
44
|
+
rails_version: 'edge'
|
|
45
|
+
db: sqlite3
|
|
46
|
+
- ruby_version: 'truffleruby-head'
|
|
47
|
+
rails_version: 'edge'
|
|
48
|
+
db: postgresql
|
|
49
|
+
- ruby_version: 'truffleruby-head'
|
|
50
|
+
rails_version: 'edge'
|
|
51
|
+
db: mysql
|
|
52
|
+
|
|
53
|
+
- ruby_version: 'jruby'
|
|
54
|
+
rails_version: '6.1'
|
|
55
|
+
db: sqlite3
|
|
56
|
+
- ruby_version: 'jruby'
|
|
57
|
+
rails_version: '6.1'
|
|
58
|
+
db: postgresql
|
|
59
|
+
- ruby_version: 'jruby'
|
|
60
|
+
rails_version: '6.1'
|
|
61
|
+
db: mysql
|
|
62
|
+
|
|
63
|
+
- ruby_version: '3.0'
|
|
64
|
+
rails_version: '7.1'
|
|
65
|
+
db: sqlite3
|
|
66
|
+
- ruby_version: '3.0'
|
|
67
|
+
rails_version: '7.1'
|
|
68
|
+
db: postgresql
|
|
69
|
+
- ruby_version: '3.0'
|
|
70
|
+
rails_version: '7.1'
|
|
71
|
+
db: mysql
|
|
72
|
+
- ruby_version: '3.0'
|
|
73
|
+
rails_version: '7.0'
|
|
74
|
+
db: sqlite3
|
|
75
|
+
- ruby_version: '3.0'
|
|
76
|
+
rails_version: '7.0'
|
|
77
|
+
db: postgresql
|
|
78
|
+
- ruby_version: '3.0'
|
|
79
|
+
rails_version: '7.0'
|
|
80
|
+
db: mysql
|
|
81
|
+
- ruby_version: '3.0'
|
|
82
|
+
rails_version: '6.1'
|
|
83
|
+
db: sqlite3
|
|
84
|
+
- ruby_version: '3.0'
|
|
85
|
+
rails_version: '6.1'
|
|
86
|
+
db: postgresql
|
|
87
|
+
- ruby_version: '3.0'
|
|
88
|
+
rails_version: '6.1'
|
|
89
|
+
db: mysql
|
|
90
|
+
- ruby_version: '3.0'
|
|
91
|
+
rails_version: '6.0'
|
|
92
|
+
db: sqlite3
|
|
93
|
+
- ruby_version: '3.0'
|
|
94
|
+
rails_version: '6.0'
|
|
95
|
+
db: postgresql
|
|
96
|
+
- ruby_version: '3.0'
|
|
97
|
+
rails_version: '6.0'
|
|
98
|
+
db: mysql
|
|
99
|
+
|
|
100
|
+
- ruby_version: '2.7'
|
|
101
|
+
rails_version: '7.1'
|
|
102
|
+
db: sqlite3
|
|
103
|
+
- ruby_version: '2.7'
|
|
104
|
+
rails_version: '7.1'
|
|
105
|
+
db: postgresql
|
|
106
|
+
- ruby_version: '2.7'
|
|
107
|
+
rails_version: '7.1'
|
|
108
|
+
db: mysql
|
|
109
|
+
- ruby_version: '2.7'
|
|
110
|
+
rails_version: '7.0'
|
|
111
|
+
db: sqlite3
|
|
112
|
+
- ruby_version: '2.7'
|
|
113
|
+
rails_version: '7.0'
|
|
114
|
+
db: postgresql
|
|
115
|
+
- ruby_version: '2.7'
|
|
116
|
+
rails_version: '7.0'
|
|
117
|
+
db: mysql
|
|
118
|
+
- ruby_version: '2.7'
|
|
119
|
+
rails_version: '6.1'
|
|
120
|
+
db: sqlite3
|
|
121
|
+
- ruby_version: '2.7'
|
|
122
|
+
rails_version: '6.1'
|
|
123
|
+
db: postgresql
|
|
124
|
+
- ruby_version: '2.7'
|
|
125
|
+
rails_version: '6.1'
|
|
126
|
+
db: mysql
|
|
127
|
+
- ruby_version: '2.7'
|
|
128
|
+
rails_version: '6.0'
|
|
129
|
+
db: sqlite3
|
|
130
|
+
|
|
131
|
+
- ruby_version: '2.6'
|
|
132
|
+
rails_version: '6.1'
|
|
133
|
+
db: sqlite3
|
|
134
|
+
- ruby_version: '2.6'
|
|
135
|
+
rails_version: '6.0'
|
|
136
|
+
db: sqlite3
|
|
137
|
+
- ruby_version: '2.6'
|
|
138
|
+
rails_version: '5.2'
|
|
139
|
+
db: sqlite3
|
|
140
|
+
- ruby_version: '2.6'
|
|
141
|
+
rails_version: '5.2'
|
|
142
|
+
db: postgresql
|
|
143
|
+
- ruby_version: '2.6'
|
|
144
|
+
rails_version: '5.2'
|
|
145
|
+
db: mysql
|
|
146
|
+
- ruby_version: '2.6'
|
|
147
|
+
rails_version: '5.1'
|
|
148
|
+
db: sqlite3
|
|
149
|
+
- ruby_version: '2.6'
|
|
150
|
+
rails_version: '5.0'
|
|
151
|
+
db: sqlite3
|
|
152
|
+
|
|
153
|
+
- ruby_version: '2.5'
|
|
154
|
+
rails_version: '6.1'
|
|
155
|
+
db: sqlite3
|
|
156
|
+
- ruby_version: '2.5'
|
|
157
|
+
rails_version: '5.1'
|
|
158
|
+
db: postgresql
|
|
159
|
+
- ruby_version: '2.5'
|
|
160
|
+
rails_version: '5.1'
|
|
161
|
+
db: mysql
|
|
162
|
+
|
|
163
|
+
- ruby_version: '2.4'
|
|
164
|
+
rails_version: '5.2'
|
|
165
|
+
db: sqlite3
|
|
166
|
+
|
|
167
|
+
- ruby_version: '2.3'
|
|
168
|
+
rails_version: '5.2'
|
|
169
|
+
db: sqlite3
|
|
170
|
+
- ruby_version: '2.3'
|
|
171
|
+
rails_version: '4.1'
|
|
172
|
+
db: sqlite3
|
|
173
|
+
|
|
174
|
+
- ruby_version: '2.2'
|
|
175
|
+
rails_version: '5.2'
|
|
176
|
+
db: sqlite3
|
|
177
|
+
|
|
178
|
+
- ruby_version: '2.1'
|
|
179
|
+
rails_version: '4.2'
|
|
180
|
+
db: sqlite3
|
|
181
|
+
|
|
182
|
+
env:
|
|
183
|
+
RAILS_VERSION: ${{ matrix.rails_version }}
|
|
184
|
+
DB: ${{ matrix.db }}
|
|
185
|
+
POSTGRES_PASSWORD: postgres # for passing the password to the Rails process
|
|
186
|
+
MYSQL_PASSWORD: root # for passing the password to the Rails process
|
|
187
|
+
|
|
188
|
+
runs-on: ubuntu-24.04
|
|
189
|
+
|
|
190
|
+
steps:
|
|
191
|
+
- uses: actions/checkout@v4
|
|
192
|
+
- name: Set up Ruby
|
|
193
|
+
uses: ruby/setup-ruby@v1
|
|
194
|
+
with:
|
|
195
|
+
ruby-version: ${{ matrix.ruby_version }}
|
|
196
|
+
rubygems: ${{ (matrix.ruby_version < '2.3' && '2.7.11') || (matrix.ruby_version < '2.6' && '3.3.26') || (matrix.ruby_version < '3.0' && '3.4.22') || 'latest' }}
|
|
197
|
+
bundler-cache: true
|
|
198
|
+
continue-on-error: ${{ (matrix.ruby_version == 'ruby-head') || (matrix.ruby_version == 'jruby') || (matrix.rails_version == 'edge') }}
|
|
199
|
+
- run: bundle exec rake test
|
|
200
|
+
continue-on-error: ${{ (matrix.ruby_version == 'ruby-head') || (matrix.ruby_version == 'jruby') || (matrix.rails_version == 'edge') }}
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,68 @@
|
|
|
1
|
+
## 1.3.0
|
|
2
|
+
|
|
3
|
+
### Security Fixes:
|
|
4
|
+
|
|
5
|
+
* `page` ignores a Hash or an Array page number (e.g. `?page[]=1`) instead of raising #1087 [@xiaohui-zhangxh]
|
|
6
|
+
* `page_entries_info` escapes the `entry_name`, which could contain user input, while keeping an `html_safe` `entry_name` as is: [d599c37](https://github.com/kaminari/kaminari/commit/d599c3796b2d366c70712ce1c754b9d146749d49)
|
|
7
|
+
|
|
8
|
+
### Incompatible Changes:
|
|
9
|
+
|
|
10
|
+
* Dropped Ruby 2.0 support: [2f1f84b](https://github.com/kaminari/kaminari/commit/2f1f84ba48caf4ff1395f99a88faa6fb832f0024)
|
|
11
|
+
* The default English `page_entries_info` message now separates the range with an en dash (e.g. "1–25") instead of ` - ` #1105 [@jdufresne]
|
|
12
|
+
* `page_entries_info` displays "No entries found" on out of range pages, instead of an inverted range like "Displaying users 81–80 of 50 in total": [b712562](https://github.com/kaminari/kaminari/commit/b7125620b16c2b8f022f670e6b7ff45710563285)
|
|
13
|
+
|
|
14
|
+
### Enhancements:
|
|
15
|
+
|
|
16
|
+
* Rails 7.1, 7.2, 8.0, and 8.1 support
|
|
17
|
+
* Ruby 3.1, 3.2, 3.3, 3.4, and 4.0 support
|
|
18
|
+
* Added `paginated?` to models, relations, and paginatable arrays #1118 [@jarenas9539]
|
|
19
|
+
* Added the `data:` option to `paginate` for the links' data attributes #1095 [@theforestvn88]
|
|
20
|
+
* Registered Kaminari's deprecator to `Rails.application.deprecators` #1103 [@etiennebarrie]
|
|
21
|
+
* `require 'kaminari'` also loads `Kaminari::VERSION` #1079 [@d-otis]
|
|
22
|
+
* The views generator warns when it falls back to erb for an unsupported template engine: [4c2991e](https://github.com/kaminari/kaminari/commit/4c2991e5418cb974f62b8d66b4d69f33888727d5)
|
|
23
|
+
* Improved performance of `total_count` for grouped relations by counting the groups in the database with a subquery #1157 (based on #1022 and #1023 [@bendilley])
|
|
24
|
+
* Improved performance of `total_count` by removing irrelevant `eager_load` and `preload` that ran unwanted joins in the count query #1043 [@Viktor-Ivliev]
|
|
25
|
+
* Improved performance of `paginate` by calling `url_for` only a few times per paginator: [7b5f079](https://github.com/kaminari/kaminari/commit/7b5f0799a07f5aa08fd9fa516df52d8c0bb7537c)
|
|
26
|
+
* Improved performance of `paginate` by looking up each partial template only once per paginator: [c5cc1a1](https://github.com/kaminari/kaminari/commit/c5cc1a141b37d266c79a73d83de7d30583327366)
|
|
27
|
+
* Improved performance of `paginate` by reducing object allocations: [1cc6f98](https://github.com/kaminari/kaminari/commit/1cc6f98a5005d8da259ddf4c9cc3245b339a4e9c), [ff07a28](https://github.com/kaminari/kaminari/commit/ff07a285215cfb8a5f70515e86decf4a16ff643c), [b951069](https://github.com/kaminari/kaminari/commit/b951069e6ae98ecc19f79ca32dc575ac34def157), [2e80453](https://github.com/kaminari/kaminari/commit/2e80453a838574dab48eb11cc3bb041b8ae42513), [794724e](https://github.com/kaminari/kaminari/commit/794724e5f485caa81437db7e299a25e67984b5eb), and [7f08863](https://github.com/kaminari/kaminari/commit/7f0886317d0630ba03d7d500bbf80c1aaa629d58)
|
|
28
|
+
* Improved performance of `page` and `per` on Active Record by copying the Relation only once: [0cb494d](https://github.com/kaminari/kaminari/commit/0cb494d7d2c48566007331e9bc5ce5ff0eb470b3), [c35e5a1](https://github.com/kaminari/kaminari/commit/c35e5a11b644b8df2659cff2ca5af73e21bd1e4b), and [ae23bc6](https://github.com/kaminari/kaminari/commit/ae23bc6b7c88310b0d749c241d4e51c78cacab90)
|
|
29
|
+
* Improved performance of `page_entries_info` #1109 [@jdufresne]
|
|
30
|
+
|
|
31
|
+
### Bug Fixes:
|
|
32
|
+
|
|
33
|
+
* Fixed `ActionController::UrlGenerationError` on Rails 8+ when the request params include route options such as `subdomain` or `host` #1147 [@hpanwar09]
|
|
34
|
+
* Fixed view helpers called with keyword arguments inside the paginator templates on Ruby 3 #1114 [@diasjorge]
|
|
35
|
+
* Fixed an error with a Symbol `param_name` other than `:page` #1121 [@magnum]
|
|
36
|
+
* Fixed `NameError` when including `Kaminari::Helpers::UrlHelper` outside of the views #1100 [@hikonori07]
|
|
37
|
+
* Fixed `page_entries_info` for a paginated empty array with `total_count` #1088 [@monfresh]
|
|
38
|
+
* Fixed `total_count` on the last page of a loaded Relation with `padding`: [c7a46f1](https://github.com/kaminari/kaminari/commit/c7a46f17b2bc1d842a3fe4d0132709bc27e02402)
|
|
39
|
+
* Fixed `ZeroDivisionError` from `per` after `per(0)` #1138 [@dpep]
|
|
40
|
+
* Fixed `per` and `max_paginates_per` dropping the `padding`: [c149803](https://github.com/kaminari/kaminari/commit/c1498035e8bb98cdf8cf14c7a2419a0c197862be)
|
|
41
|
+
* Fixed `per`, `max_paginates_per`, and `padding` changing the receiver's values instead of the returned scope's: [a9cbb2c](https://github.com/kaminari/kaminari/commit/a9cbb2cbeda86abe39f51db6712b2fd34d66faa3)
|
|
42
|
+
* Fixed `max_paginates_per` returning no records after an ignored `per` value such as `per('abc')`: [0f2816a](https://github.com/kaminari/kaminari/commit/0f2816a4c5a6367e8582d0cc44906ca4815c63e5)
|
|
43
|
+
* Fixed `per` treating a value like `"abc\n10"` as `per(0)` instead of ignoring it: [8298351](https://github.com/kaminari/kaminari/commit/8298351e2833209f65eb3f3327b52bbba0bbe401)
|
|
44
|
+
* Fixed `Kaminari::ZeroPerPageOperation` from `total_count` on a loaded `per(0)` Relation #1155 [@andreyruby]
|
|
45
|
+
* Fixed `total_count` returning 0 with `max_pages` after `per(0)`: [06e90d9](https://github.com/kaminari/kaminari/commit/06e90d901d196ea77d2d00d819b53826e538e6c6)
|
|
46
|
+
* Fixed `TypeError` from `total_count` after `unscope(:limit)`: [4fd263b](https://github.com/kaminari/kaminari/commit/4fd263bececd472f779bc6b05de8b182f8b4c9f2)
|
|
47
|
+
* Fixed the Haml and Slim paginators rendering the next and last links on out of range pages, as the erb paginator doesn't: [a44950d](https://github.com/kaminari/kaminari/commit/a44950d71fa03a6136088f9b01f7be1b81e131f6)
|
|
48
|
+
* Fixed the views generator generating nothing for an unsupported template engine, such as one set via `config.generators.template_engine` #1108 [@Xavier-IV]
|
|
49
|
+
* Fixed the views generator crashing on network errors other than `SocketError`: [6d91911](https://github.com/kaminari/kaminari/commit/6d919116edd2ad85bd3f9559d86ae4973242bf86)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## 1.2.2
|
|
53
|
+
|
|
54
|
+
### Enhancements:
|
|
55
|
+
|
|
56
|
+
* Rails 7 support via [dbac7d4](https://github.com/kaminari/kaminari/commit/dbac7d476f39f8a17a35aba7e528aec7c589b3e5) and [07fafc0](https://github.com/kaminari/kaminari/commit/07fafc0561b307b6fbf40e9ec6ab52a6ec5102b4)
|
|
57
|
+
|
|
58
|
+
### Bug Fixes:
|
|
59
|
+
|
|
60
|
+
* Restored `path_to_next_url` helper that was accidentally deleted in v1.2.0 #1027 [@ryym]
|
|
61
|
+
* Fixed invalid link tag HTML output from `rel_next_prev_link_tags` helper #1045 [@dlackty]
|
|
62
|
+
* Fixed Errno::ENOENT error for views generator on Ruby 3 #1050 [@ar31an]
|
|
63
|
+
* Suppress warnings about keyword args on Ruby 2.7 #1053 [@mishina]
|
|
64
|
+
|
|
65
|
+
|
|
1
66
|
## 1.2.1
|
|
2
67
|
|
|
3
68
|
### Security Fixes:
|
|
@@ -45,7 +110,7 @@
|
|
|
45
110
|
* Now the `page_entries_info` method respects the `I18n.locale` value when pluralizing the `entry_name` option #899 [@hundred]
|
|
46
111
|
* `require 'kaminari/core'` is no longer necessary when using `require 'kaminari/activerecord'` #896 [@yhara]
|
|
47
112
|
* Added the `#current_per_page` method to inspect current value of `per_page` #875 [#bfad]
|
|
48
|
-
* Better
|
|
113
|
+
* Better accessibility support by adding accessibility roles to pagination nav #848 [@frrrances]
|
|
49
114
|
|
|
50
115
|
### Bug Fixes:
|
|
51
116
|
|
|
@@ -86,7 +151,7 @@
|
|
|
86
151
|
|
|
87
152
|
* Extracted Grape support to kaminari-grape gem and removed it from the core
|
|
88
153
|
|
|
89
|
-
*
|
|
154
|
+
* Split the gem into 3 internal gems:
|
|
90
155
|
* The core pagination logic (kaminari-core)
|
|
91
156
|
* Active Record adapter (kaminari-activerecord)
|
|
92
157
|
* Action View adapter (kaminari-actionview)
|
|
@@ -297,7 +362,7 @@
|
|
|
297
362
|
|
|
298
363
|
* Fixed displayed number of items on each page w/ Mongoid 2.4.x and MongoMapper #194 [@dblock]
|
|
299
364
|
|
|
300
|
-
* Removed
|
|
365
|
+
* Removed an unused local variable from templates from default template #245 [@juno]
|
|
301
366
|
|
|
302
367
|
* Fixed `page_entry_info` to use the value of `entry_name` option when given collection is empty or a PaginatableArray #265, #277 [@eitoball]
|
|
303
368
|
|
data/Gemfile
CHANGED
|
@@ -4,3 +4,74 @@ source 'https://rubygems.org'
|
|
|
4
4
|
|
|
5
5
|
# Specify your gem's dependencies in kaminari.gemspec
|
|
6
6
|
gemspec
|
|
7
|
+
|
|
8
|
+
if ENV['RAILS_VERSION'] == 'edge'
|
|
9
|
+
gem 'railties', git: 'https://github.com/rails/rails.git'
|
|
10
|
+
gem 'activerecord', git: 'https://github.com/rails/rails.git', require: 'active_record'
|
|
11
|
+
gem 'actionview', git: 'https://github.com/rails/rails.git', require: 'action_view'
|
|
12
|
+
elsif ENV['RAILS_VERSION'] == '5.2'
|
|
13
|
+
gem 'railties', git: 'https://github.com/rails/rails.git', branch: '5-2-stable'
|
|
14
|
+
gem 'activerecord', git: 'https://github.com/rails/rails.git', require: 'active_record', branch: '5-2-stable'
|
|
15
|
+
gem 'actionview', git: 'https://github.com/rails/rails.git', require: 'action_view', branch: '5-2-stable'
|
|
16
|
+
elsif ENV['RAILS_VERSION']
|
|
17
|
+
gem 'railties', "~> #{ENV['RAILS_VERSION']}.0"
|
|
18
|
+
gem 'activerecord', "~> #{ENV['RAILS_VERSION']}.0", require: 'active_record'
|
|
19
|
+
gem 'actionview', "~> #{ENV['RAILS_VERSION']}.0", require: 'action_view'
|
|
20
|
+
else
|
|
21
|
+
gem 'rails'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
gem 'rake', RUBY_VERSION < '2.2' ? '< 13' : '>= 0'
|
|
25
|
+
if RUBY_VERSION >= '3.1'
|
|
26
|
+
gem 'power_assert'
|
|
27
|
+
elsif RUBY_VERSION >= '2.5'
|
|
28
|
+
gem 'power_assert', '< 3'
|
|
29
|
+
end
|
|
30
|
+
gem 'concurrent-ruby', RUBY_VERSION < '2.2' ? '< 1.1.10' : RUBY_VERSION < '2.3' ? '< 1.2' : '>= 1.2'
|
|
31
|
+
gem 'mini_portile2', RUBY_VERSION < '2.3' ? '< 2.5.1' : '>= 0'
|
|
32
|
+
gem 'loofah', RUBY_VERSION < '2.5' ? '< 2.21.0' : '>= 0'
|
|
33
|
+
gem 'i18n', RUBY_VERSION < '2.3' ? '< 1.5.2' : '>= 0'
|
|
34
|
+
gem 'selenium-webdriver'
|
|
35
|
+
|
|
36
|
+
gem 'bigdecimal'
|
|
37
|
+
gem 'mutex_m'
|
|
38
|
+
gem 'benchmark' if RUBY_VERSION >= '3.5'
|
|
39
|
+
|
|
40
|
+
rails_version = ENV['RAILS_VERSION'] || '∞'
|
|
41
|
+
|
|
42
|
+
platforms :ruby do
|
|
43
|
+
case ENV['DB']
|
|
44
|
+
when 'postgresql'
|
|
45
|
+
gem 'pg', rails_version >= '5.1' ? '>= 1.0.0' : '< 1.0.0', require: false
|
|
46
|
+
when 'mysql'
|
|
47
|
+
gem 'mysql2', rails_version >= '4.2' ? '>= 0.4' : '< 0.4', require: false
|
|
48
|
+
when 'sqlite3', nil
|
|
49
|
+
if rails_version <= '5.0'
|
|
50
|
+
gem 'sqlite3', '< 1.4', require: false
|
|
51
|
+
elsif RUBY_VERSION < '2.3'
|
|
52
|
+
gem 'sqlite3', '< 1.5', require: false
|
|
53
|
+
elsif RUBY_VERSION < '2.5'
|
|
54
|
+
gem 'sqlite3', '1.5.1'
|
|
55
|
+
elsif (rails_version <= '8') || (RUBY_VERSION < '3')
|
|
56
|
+
gem 'sqlite3', '< 2', require: false
|
|
57
|
+
else
|
|
58
|
+
gem 'sqlite3', require: false
|
|
59
|
+
end
|
|
60
|
+
else
|
|
61
|
+
raise "Unknown DB: #{ENV['DB']}"
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
platforms :jruby do
|
|
66
|
+
gem 'activerecord-jdbcsqlite3-adapter', require: false
|
|
67
|
+
gem 'activerecord-jdbcpostgresql-adapter', require: false
|
|
68
|
+
gem 'activerecord-jdbcmysql-adapter', require: false
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
if RUBY_ENGINE == 'rbx'
|
|
72
|
+
platforms :rbx do
|
|
73
|
+
gem 'rubysl', '~> 2.0'
|
|
74
|
+
gem 'racc'
|
|
75
|
+
gem 'rubinius-developer_tools'
|
|
76
|
+
end
|
|
77
|
+
end
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Kaminari [](https://github.com/kaminari/kaminari/actions) [](https://codeclimate.com/github/kaminari/kaminari)
|
|
2
2
|
|
|
3
3
|
A Scope & Engine based, clean, powerful, customizable and sophisticated paginator for modern web app frameworks and ORMs
|
|
4
4
|
|
|
@@ -22,7 +22,7 @@ As the whole pagination helper is basically just a collection of links and non-l
|
|
|
22
22
|
So, you can easily modify their behaviour, style or whatever by overriding partial templates.
|
|
23
23
|
|
|
24
24
|
### ORM & Template Engine Agnostic
|
|
25
|
-
Kaminari supports multiple ORMs (ActiveRecord, DataMapper, Mongoid, MongoMapper) multiple web frameworks (Rails, Sinatra, Grape), and multiple template engines (ERB, Haml, Slim).
|
|
25
|
+
Kaminari supports multiple ORMs (ActiveRecord, DataMapper, Mongoid, MongoMapper), multiple web frameworks (Rails, Sinatra, Grape), and multiple template engines (ERB, Haml, Slim).
|
|
26
26
|
|
|
27
27
|
### Modern
|
|
28
28
|
The pagination helper outputs the HTML5 `<nav>` tag by default. Plus, the helper supports Rails unobtrusive Ajax.
|
|
@@ -30,9 +30,9 @@ The pagination helper outputs the HTML5 `<nav>` tag by default. Plus, the helper
|
|
|
30
30
|
|
|
31
31
|
## Supported Versions
|
|
32
32
|
|
|
33
|
-
* Ruby 2.
|
|
33
|
+
* Ruby 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 4.0
|
|
34
34
|
|
|
35
|
-
* Rails 4.1, 4.2, 5.0, 5.1, 5.2, 6.0, 6.1
|
|
35
|
+
* Rails 4.1, 4.2, 5.0, 5.1, 5.2, 6.0, 6.1, 7.0, 7.1, 7.2, 8.0, 8.1
|
|
36
36
|
|
|
37
37
|
* Sinatra 1.4, 2.0
|
|
38
38
|
|
|
@@ -59,7 +59,7 @@ Then bundle:
|
|
|
59
59
|
% bundle
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
If you're building non-Rails
|
|
62
|
+
If you're building non-Rails or non-ActiveRecord app and want the pagination feature on it, please take a look at [Other Framework/Library Support](#other-frameworklibrary-support) section.
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
## Query Basics
|
|
@@ -74,6 +74,12 @@ User.page(7)
|
|
|
74
74
|
|
|
75
75
|
Note: pagination starts at page 1, not at page 0 (page(0) will return the same results as page(1)).
|
|
76
76
|
|
|
77
|
+
Kaminari does not add an `order` to queries. To avoid surprises, you should generally include an order in paginated queries. For example:
|
|
78
|
+
|
|
79
|
+
```ruby
|
|
80
|
+
User.order(:name).page(7)
|
|
81
|
+
```
|
|
82
|
+
|
|
77
83
|
You can get page numbers or page conditions by using below methods.
|
|
78
84
|
```ruby
|
|
79
85
|
User.count #=> 1000
|
|
@@ -85,18 +91,20 @@ User.page(2).prev_page #=> 1
|
|
|
85
91
|
User.page(1).first_page? #=> true
|
|
86
92
|
User.page(50).last_page? #=> true
|
|
87
93
|
User.page(100).out_of_range? #=> true
|
|
94
|
+
User.all.paginated? #=> false
|
|
95
|
+
User.page(1).paginated? #=> true
|
|
88
96
|
```
|
|
89
97
|
|
|
90
98
|
### The `per` Scope
|
|
91
99
|
|
|
92
|
-
To show a lot more users per each page (change the `
|
|
100
|
+
To show a lot more users per each page (change the `per` value)
|
|
93
101
|
|
|
94
102
|
```ruby
|
|
95
|
-
User.page(7).per(50)
|
|
103
|
+
User.order(:name).page(7).per(50)
|
|
96
104
|
```
|
|
97
105
|
|
|
98
106
|
Note that the `per` scope is not directly defined on the models but is just a method defined on the page scope.
|
|
99
|
-
This is absolutely reasonable because you will never actually use `
|
|
107
|
+
This is absolutely reasonable because you will never actually use `per` without specifying the `page` number.
|
|
100
108
|
|
|
101
109
|
Keep in mind that `per` internally utilizes `limit` and so it will override any `limit` that was set previously.
|
|
102
110
|
And if you want to get the size for all request records you can use `total_count` method:
|
|
@@ -113,7 +121,7 @@ a.page(1).per(20).total_count #=> 1000
|
|
|
113
121
|
Occasionally you need to pad a number of records that is not a multiple of the page size.
|
|
114
122
|
|
|
115
123
|
```ruby
|
|
116
|
-
User.page(7).per(50).padding(3)
|
|
124
|
+
User.order(:name).page(7).per(50).padding(3)
|
|
117
125
|
```
|
|
118
126
|
|
|
119
127
|
Note that the `padding` scope also is not directly defined on the models.
|
|
@@ -123,7 +131,7 @@ Note that the `padding` scope also is not directly defined on the models.
|
|
|
123
131
|
If for some reason you need to unscope `page` and `per` methods you can call `except(:limit, :offset)`
|
|
124
132
|
|
|
125
133
|
```ruby
|
|
126
|
-
users = User.page(7).per(50)
|
|
134
|
+
users = User.order(:name).page(7).per(50)
|
|
127
135
|
unpaged_users = users.except(:limit, :offset) # unpaged_users will not use the kaminari scopes
|
|
128
136
|
```
|
|
129
137
|
|
|
@@ -178,6 +186,20 @@ class User < ActiveRecord::Base
|
|
|
178
186
|
end
|
|
179
187
|
```
|
|
180
188
|
|
|
189
|
+
### Configuring max_pages Value for Each Model by `max_pages`
|
|
190
|
+
|
|
191
|
+
You can specify `max_pages` value per each model using the following declarative DSL.
|
|
192
|
+
This value restricts the total number of pages that can be returned. Useful for setting limits on large collections.
|
|
193
|
+
|
|
194
|
+
```ruby
|
|
195
|
+
class User < ActiveRecord::Base
|
|
196
|
+
max_pages 100
|
|
197
|
+
end
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Configuring params_on_first_page when using ransack_memory
|
|
201
|
+
|
|
202
|
+
If you are using [the `ransack_memory` gem](https://github.com/richardrails/ransack_memory) and experience problems navigating back to the previous or first page, set the `params_on_first_page` setting to `true`.
|
|
181
203
|
|
|
182
204
|
## Controllers
|
|
183
205
|
|
|
@@ -211,7 +233,7 @@ This will render several `?page=N` pagination links surrounded by an HTML5 `<nav
|
|
|
211
233
|
<%= paginate @users %>
|
|
212
234
|
```
|
|
213
235
|
|
|
214
|
-
This would output several pagination links such as `« First ‹ Prev ... 2 3 4 5 6 7 8 9 10 ... Next › Last
|
|
236
|
+
This would output several pagination links such as `« First ‹ Prev ... 2 3 4 5 6 7 8 9 10 ... Next › Last »`.
|
|
215
237
|
|
|
216
238
|
### Specifying the "inner window" Size (4 by default)
|
|
217
239
|
|
|
@@ -249,12 +271,12 @@ This would modify the query parameter name on each links.
|
|
|
249
271
|
### Extra Parameters (`:params`) for the Links
|
|
250
272
|
|
|
251
273
|
```erb
|
|
252
|
-
<%= paginate @users, params: {controller: 'foo', action: 'bar'} %>
|
|
274
|
+
<%= paginate @users, params: {controller: 'foo', action: 'bar', format: :turbo_stream} %>
|
|
253
275
|
```
|
|
254
276
|
|
|
255
|
-
This would modify each link's `url_option`.
|
|
277
|
+
This would modify each link's `url_option`. `:controller` and `:action` might be the keys in common.
|
|
256
278
|
|
|
257
|
-
### Ajax Links (
|
|
279
|
+
### Ajax Links (via rails-ujs, works with Rails < 7.2)
|
|
258
280
|
|
|
259
281
|
```erb
|
|
260
282
|
<%= paginate @users, remote: true %>
|
|
@@ -262,6 +284,15 @@ This would modify each link's `url_option`. :`controller` and :`action` might be
|
|
|
262
284
|
|
|
263
285
|
This would add `data-remote="true"` to all the links inside.
|
|
264
286
|
|
|
287
|
+
### Data Attributes (e.g. for Turbo Frames and Stimulus)
|
|
288
|
+
|
|
289
|
+
```erb
|
|
290
|
+
<%= paginate @users, data: {turbo_frame: 'users', turbo_action: 'advance'} %>
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
This would add `data-turbo-frame="users"` and `data-turbo-action="advance"` to all the links inside.
|
|
294
|
+
If you have customized the views with `rails g kaminari:views` before this option was added, your templates will silently ignore it. Add `data: data` to the `link_to` calls in them to enable it.
|
|
295
|
+
|
|
265
296
|
### Specifying an Alternative Views Directory (default is kaminari/)
|
|
266
297
|
|
|
267
298
|
```erb
|
|
@@ -279,6 +310,12 @@ This option makes it easier to do things like A/B testing pagination templates/t
|
|
|
279
310
|
|
|
280
311
|
This simply renders a link to the next page. This would be helpful for creating a Twitter-like pagination feature.
|
|
281
312
|
|
|
313
|
+
The helper methods support a `params` option to further specify the link. If `format` needs to be set, include it in the `params` hash.
|
|
314
|
+
|
|
315
|
+
```erb
|
|
316
|
+
<%= link_to_next_page @items, 'Next Page', params: {controller: 'foo', action: 'bar', format: :turbo_stream} %>
|
|
317
|
+
```
|
|
318
|
+
|
|
282
319
|
### The `page_entries_info` Helper Method
|
|
283
320
|
|
|
284
321
|
```erb
|
|
@@ -342,7 +379,7 @@ en:
|
|
|
342
379
|
one: "Displaying <b>1</b> %{entry_name}"
|
|
343
380
|
other: "Displaying <b>all %{count}</b> %{entry_name}"
|
|
344
381
|
more_pages:
|
|
345
|
-
display_entries: "Displaying %{entry_name} <b>%{first}
|
|
382
|
+
display_entries: "Displaying %{entry_name} <b>%{first}–%{last}</b> of <b>%{total}</b> in total"
|
|
346
383
|
```
|
|
347
384
|
|
|
348
385
|
If you use non-English localization see [i18n rules](https://github.com/svenfuchs/i18n/blob/master/test/test_data/locales/plurals.rb) for changing
|
|
@@ -547,24 +584,18 @@ Feel free to message me on Github (amatsuda) or Twitter ([@a_matsuda](https://tw
|
|
|
547
584
|
|
|
548
585
|
Fork, fix, then send a pull request.
|
|
549
586
|
|
|
550
|
-
To run the test suite locally against
|
|
551
|
-
|
|
552
|
-
```sh
|
|
553
|
-
% bundle install
|
|
554
|
-
% rake test:all
|
|
555
|
-
```
|
|
556
|
-
|
|
557
|
-
To target the test suite against one framework:
|
|
587
|
+
To run the test suite locally against newest stable Rails:
|
|
558
588
|
|
|
559
589
|
```sh
|
|
560
|
-
%
|
|
590
|
+
% bundle install (or bundle update)
|
|
591
|
+
% bundle e rake test
|
|
561
592
|
```
|
|
562
593
|
|
|
563
|
-
|
|
594
|
+
To target the test suite against specific version of Active Record (Rails), set `RAILS_VERSION` environment variable when executing `bundle update` and `rake test`:
|
|
564
595
|
|
|
565
596
|
```sh
|
|
566
|
-
%
|
|
567
|
-
%
|
|
597
|
+
% RAILS_VERSION=7.2 bundle update
|
|
598
|
+
% RAILS_VERSION=7.2 bundle e rake test
|
|
568
599
|
```
|
|
569
600
|
|
|
570
601
|
|
data/Rakefile
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
require "bundler/gem_tasks"
|
|
4
4
|
|
|
5
5
|
require 'rake/testtask'
|
|
6
|
-
require 'kaminari'
|
|
7
6
|
|
|
8
7
|
Rake::TestTask.new do |t|
|
|
9
8
|
t.libs << 'test'
|
|
@@ -12,36 +11,6 @@ Rake::TestTask.new do |t|
|
|
|
12
11
|
t.verbose = true
|
|
13
12
|
end
|
|
14
13
|
|
|
15
|
-
task default: "test:all"
|
|
16
|
-
|
|
17
|
-
namespace :test do
|
|
18
|
-
mappers = %w(
|
|
19
|
-
active_record_edge
|
|
20
|
-
active_record_60
|
|
21
|
-
active_record_52
|
|
22
|
-
active_record_51
|
|
23
|
-
active_record_50
|
|
24
|
-
active_record_42
|
|
25
|
-
active_record_41
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
mappers.each do |gemfile|
|
|
29
|
-
desc "Run Tests against #{gemfile}"
|
|
30
|
-
task gemfile do
|
|
31
|
-
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
|
|
32
|
-
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake -t test"
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
desc "Run Tests against all ORMs"
|
|
37
|
-
task :all do
|
|
38
|
-
mappers.each do |gemfile|
|
|
39
|
-
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
|
|
40
|
-
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake test"
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
14
|
task :install_tasks_for_sub_gems do
|
|
46
15
|
Bundler::GemHelper.install_tasks dir: File.join(__dir__, 'kaminari-core'), name: 'kaminari-core'
|
|
47
16
|
Bundler::GemHelper.install_tasks dir: File.join(__dir__, 'kaminari-actionview'), name: 'kaminari-actionview'
|
data/kaminari.gemspec
CHANGED
|
@@ -13,6 +13,12 @@ Gem::Specification.new do |spec|
|
|
|
13
13
|
spec.description = 'Kaminari is a Scope & Engine based, clean, powerful, agnostic, customizable and sophisticated paginator for Rails 4+'
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
|
|
16
|
+
spec.metadata = {
|
|
17
|
+
'changelog_uri' => 'https://github.com/kaminari/kaminari/blob/master/CHANGELOG.md',
|
|
18
|
+
'source_code_uri' => 'https://github.com/kaminari/kaminari/',
|
|
19
|
+
'rubygems_mfa_required' => 'true'
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
spec.files = `git ls-files | egrep -v 'kaminari-(core|actionview|activerecord)' | grep -v '^test'`.split("\n")
|
|
17
23
|
spec.require_paths = ['lib']
|
|
18
24
|
|
|
@@ -25,7 +31,6 @@ Gem::Specification.new do |spec|
|
|
|
25
31
|
|
|
26
32
|
spec.add_development_dependency 'test-unit-rails'
|
|
27
33
|
spec.add_development_dependency 'bundler', '>= 1.0.0'
|
|
28
|
-
spec.add_development_dependency 'rake', '>= 0'
|
|
29
34
|
spec.add_development_dependency 'rr', '>= 0'
|
|
30
35
|
spec.add_development_dependency 'capybara', '>= 1.0'
|
|
31
36
|
end
|