kaminari 1.2.2 → 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 +151 -58
- data/.gitignore +1 -2
- data/CHANGELOG.md +54 -3
- data/Gemfile +71 -0
- data/README.md +37 -21
- data/Rakefile +0 -31
- data/kaminari.gemspec +6 -1
- data/lib/kaminari/version.rb +1 -1
- data/lib/kaminari.rb +1 -0
- metadata +165 -172
- data/.codeclimate.yml +0 -19
- data/gemfiles/active_record_41.gemfile +0 -30
- data/gemfiles/active_record_42.gemfile +0 -30
- data/gemfiles/active_record_50.gemfile +0 -26
- data/gemfiles/active_record_51.gemfile +0 -26
- data/gemfiles/active_record_52.gemfile +0 -26
- data/gemfiles/active_record_60.gemfile +0 -28
- data/gemfiles/active_record_61.gemfile +0 -28
- data/gemfiles/active_record_70.gemfile +0 -28
- data/gemfiles/active_record_edge.gemfile +0 -35
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
|
data/.github/workflows/main.yml
CHANGED
|
@@ -1,107 +1,200 @@
|
|
|
1
1
|
name: build
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
schedule:
|
|
7
|
+
- cron: '58 23 * * *'
|
|
6
8
|
|
|
7
9
|
jobs:
|
|
8
10
|
build:
|
|
9
11
|
services:
|
|
10
12
|
postgresql:
|
|
11
|
-
image: postgres:
|
|
13
|
+
image: postgres:10
|
|
12
14
|
ports:
|
|
13
15
|
- 5432:5432
|
|
14
16
|
env:
|
|
15
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
|
|
16
26
|
strategy:
|
|
17
27
|
fail-fast: true
|
|
28
|
+
|
|
18
29
|
matrix:
|
|
19
|
-
ruby_version:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- '2.5'
|
|
24
|
-
- 'jruby-9.3.2.0'
|
|
25
|
-
gemfile:
|
|
26
|
-
- gemfiles/active_record_70.gemfile
|
|
27
|
-
- gemfiles/active_record_61.gemfile
|
|
28
|
-
- gemfiles/active_record_60.gemfile
|
|
29
|
-
- gemfiles/active_record_52.gemfile
|
|
30
|
-
- gemfiles/active_record_51.gemfile
|
|
31
|
-
- gemfiles/active_record_50.gemfile
|
|
32
|
-
- gemfiles/active_record_edge.gemfile
|
|
33
|
-
db:
|
|
34
|
-
- sqlite3
|
|
35
|
-
- postgresql
|
|
36
|
-
- mysql
|
|
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
|
+
|
|
37
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
|
|
38
72
|
- ruby_version: '3.0'
|
|
39
|
-
|
|
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
|
|
40
90
|
- ruby_version: '3.0'
|
|
41
|
-
|
|
91
|
+
rails_version: '6.0'
|
|
92
|
+
db: sqlite3
|
|
42
93
|
- ruby_version: '3.0'
|
|
43
|
-
|
|
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
|
|
44
106
|
- ruby_version: '2.7'
|
|
45
|
-
|
|
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
|
|
46
124
|
- ruby_version: '2.7'
|
|
47
|
-
|
|
125
|
+
rails_version: '6.1'
|
|
126
|
+
db: mysql
|
|
48
127
|
- ruby_version: '2.7'
|
|
49
|
-
|
|
128
|
+
rails_version: '6.0'
|
|
129
|
+
db: sqlite3
|
|
130
|
+
|
|
131
|
+
- ruby_version: '2.6'
|
|
132
|
+
rails_version: '6.1'
|
|
133
|
+
db: sqlite3
|
|
50
134
|
- ruby_version: '2.6'
|
|
51
|
-
|
|
135
|
+
rails_version: '6.0'
|
|
136
|
+
db: sqlite3
|
|
52
137
|
- ruby_version: '2.6'
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
+
|
|
56
153
|
- ruby_version: '2.5'
|
|
57
|
-
|
|
58
|
-
- ruby_version: 'jruby-9.3.2.0'
|
|
59
|
-
gemfile: gemfiles/active_record_edge.gemfile
|
|
60
|
-
include:
|
|
61
|
-
- ruby_version: 'ruby-head'
|
|
62
|
-
gemfile: gemfiles/active_record_edge.gemfile
|
|
154
|
+
rails_version: '6.1'
|
|
63
155
|
db: sqlite3
|
|
64
|
-
- ruby_version: '
|
|
65
|
-
|
|
156
|
+
- ruby_version: '2.5'
|
|
157
|
+
rails_version: '5.1'
|
|
66
158
|
db: postgresql
|
|
67
|
-
- ruby_version: '
|
|
68
|
-
|
|
159
|
+
- ruby_version: '2.5'
|
|
160
|
+
rails_version: '5.1'
|
|
69
161
|
db: mysql
|
|
162
|
+
|
|
70
163
|
- ruby_version: '2.4'
|
|
71
|
-
|
|
72
|
-
db: sqlite3
|
|
73
|
-
- ruby_version: '2.3'
|
|
74
|
-
gemfile: gemfiles/active_record_52.gemfile
|
|
164
|
+
rails_version: '5.2'
|
|
75
165
|
db: sqlite3
|
|
166
|
+
|
|
76
167
|
- ruby_version: '2.3'
|
|
77
|
-
|
|
168
|
+
rails_version: '5.2'
|
|
78
169
|
db: sqlite3
|
|
79
170
|
- ruby_version: '2.3'
|
|
80
|
-
|
|
171
|
+
rails_version: '4.1'
|
|
81
172
|
db: sqlite3
|
|
173
|
+
|
|
82
174
|
- ruby_version: '2.2'
|
|
83
|
-
|
|
175
|
+
rails_version: '5.2'
|
|
84
176
|
db: sqlite3
|
|
177
|
+
|
|
85
178
|
- ruby_version: '2.1'
|
|
86
|
-
|
|
179
|
+
rails_version: '4.2'
|
|
87
180
|
db: sqlite3
|
|
88
|
-
|
|
181
|
+
|
|
89
182
|
env:
|
|
90
|
-
|
|
183
|
+
RAILS_VERSION: ${{ matrix.rails_version }}
|
|
91
184
|
DB: ${{ matrix.db }}
|
|
92
185
|
POSTGRES_PASSWORD: postgres # for passing the password to the Rails process
|
|
93
186
|
MYSQL_PASSWORD: root # for passing the password to the Rails process
|
|
187
|
+
|
|
188
|
+
runs-on: ubuntu-24.04
|
|
189
|
+
|
|
94
190
|
steps:
|
|
95
|
-
- uses: actions/checkout@
|
|
96
|
-
- name: Install libmysqld-dev
|
|
97
|
-
run: sudo apt-get install libmysqld-dev
|
|
98
|
-
- name: Start local MySQL
|
|
99
|
-
run: sudo /etc/init.d/mysql start
|
|
191
|
+
- uses: actions/checkout@v4
|
|
100
192
|
- name: Set up Ruby
|
|
101
193
|
uses: ruby/setup-ruby@v1
|
|
102
194
|
with:
|
|
103
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' }}
|
|
104
197
|
bundler-cache: true
|
|
105
|
-
continue-on-error: ${{ matrix.ruby_version == 'ruby-head' || matrix.ruby_version == 'jruby
|
|
198
|
+
continue-on-error: ${{ (matrix.ruby_version == 'ruby-head') || (matrix.ruby_version == 'jruby') || (matrix.rails_version == 'edge') }}
|
|
106
199
|
- run: bundle exec rake test
|
|
107
|
-
continue-on-error: ${{ matrix.ruby_version == 'ruby-head' || matrix.ruby_version == 'jruby
|
|
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,54 @@
|
|
|
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
|
+
|
|
1
52
|
## 1.2.2
|
|
2
53
|
|
|
3
54
|
### Enhancements:
|
|
@@ -59,7 +110,7 @@
|
|
|
59
110
|
* Now the `page_entries_info` method respects the `I18n.locale` value when pluralizing the `entry_name` option #899 [@hundred]
|
|
60
111
|
* `require 'kaminari/core'` is no longer necessary when using `require 'kaminari/activerecord'` #896 [@yhara]
|
|
61
112
|
* Added the `#current_per_page` method to inspect current value of `per_page` #875 [#bfad]
|
|
62
|
-
* Better
|
|
113
|
+
* Better accessibility support by adding accessibility roles to pagination nav #848 [@frrrances]
|
|
63
114
|
|
|
64
115
|
### Bug Fixes:
|
|
65
116
|
|
|
@@ -100,7 +151,7 @@
|
|
|
100
151
|
|
|
101
152
|
* Extracted Grape support to kaminari-grape gem and removed it from the core
|
|
102
153
|
|
|
103
|
-
*
|
|
154
|
+
* Split the gem into 3 internal gems:
|
|
104
155
|
* The core pagination logic (kaminari-core)
|
|
105
156
|
* Active Record adapter (kaminari-activerecord)
|
|
106
157
|
* Action View adapter (kaminari-actionview)
|
|
@@ -311,7 +362,7 @@
|
|
|
311
362
|
|
|
312
363
|
* Fixed displayed number of items on each page w/ Mongoid 2.4.x and MongoMapper #194 [@dblock]
|
|
313
364
|
|
|
314
|
-
* Removed
|
|
365
|
+
* Removed an unused local variable from templates from default template #245 [@juno]
|
|
315
366
|
|
|
316
367
|
* Fixed `page_entry_info` to use the value of `entry_name` option when given collection is empty or a PaginatableArray #265, #277 [@eitoball]
|
|
317
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
|
@@ -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.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1
|
|
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, 7.0, 7.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
|
|
@@ -91,6 +91,8 @@ User.page(2).prev_page #=> 1
|
|
|
91
91
|
User.page(1).first_page? #=> true
|
|
92
92
|
User.page(50).last_page? #=> true
|
|
93
93
|
User.page(100).out_of_range? #=> true
|
|
94
|
+
User.all.paginated? #=> false
|
|
95
|
+
User.page(1).paginated? #=> true
|
|
94
96
|
```
|
|
95
97
|
|
|
96
98
|
### The `per` Scope
|
|
@@ -184,6 +186,17 @@ class User < ActiveRecord::Base
|
|
|
184
186
|
end
|
|
185
187
|
```
|
|
186
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
|
+
|
|
187
200
|
### Configuring params_on_first_page when using ransack_memory
|
|
188
201
|
|
|
189
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`.
|
|
@@ -220,7 +233,7 @@ This will render several `?page=N` pagination links surrounded by an HTML5 `<nav
|
|
|
220
233
|
<%= paginate @users %>
|
|
221
234
|
```
|
|
222
235
|
|
|
223
|
-
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 »`.
|
|
224
237
|
|
|
225
238
|
### Specifying the "inner window" Size (4 by default)
|
|
226
239
|
|
|
@@ -261,9 +274,9 @@ This would modify the query parameter name on each links.
|
|
|
261
274
|
<%= paginate @users, params: {controller: 'foo', action: 'bar', format: :turbo_stream} %>
|
|
262
275
|
```
|
|
263
276
|
|
|
264
|
-
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.
|
|
265
278
|
|
|
266
|
-
### Ajax Links (
|
|
279
|
+
### Ajax Links (via rails-ujs, works with Rails < 7.2)
|
|
267
280
|
|
|
268
281
|
```erb
|
|
269
282
|
<%= paginate @users, remote: true %>
|
|
@@ -271,6 +284,15 @@ This would modify each link's `url_option`. :`controller` and :`action` might be
|
|
|
271
284
|
|
|
272
285
|
This would add `data-remote="true"` to all the links inside.
|
|
273
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
|
+
|
|
274
296
|
### Specifying an Alternative Views Directory (default is kaminari/)
|
|
275
297
|
|
|
276
298
|
```erb
|
|
@@ -288,7 +310,7 @@ This option makes it easier to do things like A/B testing pagination templates/t
|
|
|
288
310
|
|
|
289
311
|
This simply renders a link to the next page. This would be helpful for creating a Twitter-like pagination feature.
|
|
290
312
|
|
|
291
|
-
The helper methods support a `params` option to further specify the link. If `format` needs to be set,
|
|
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.
|
|
292
314
|
|
|
293
315
|
```erb
|
|
294
316
|
<%= link_to_next_page @items, 'Next Page', params: {controller: 'foo', action: 'bar', format: :turbo_stream} %>
|
|
@@ -357,7 +379,7 @@ en:
|
|
|
357
379
|
one: "Displaying <b>1</b> %{entry_name}"
|
|
358
380
|
other: "Displaying <b>all %{count}</b> %{entry_name}"
|
|
359
381
|
more_pages:
|
|
360
|
-
display_entries: "Displaying %{entry_name} <b>%{first}
|
|
382
|
+
display_entries: "Displaying %{entry_name} <b>%{first}–%{last}</b> of <b>%{total}</b> in total"
|
|
361
383
|
```
|
|
362
384
|
|
|
363
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
|
|
@@ -562,24 +584,18 @@ Feel free to message me on Github (amatsuda) or Twitter ([@a_matsuda](https://tw
|
|
|
562
584
|
|
|
563
585
|
Fork, fix, then send a pull request.
|
|
564
586
|
|
|
565
|
-
To run the test suite locally against
|
|
566
|
-
|
|
567
|
-
```sh
|
|
568
|
-
% bundle install
|
|
569
|
-
% rake test:all
|
|
570
|
-
```
|
|
571
|
-
|
|
572
|
-
To target the test suite against one framework:
|
|
587
|
+
To run the test suite locally against newest stable Rails:
|
|
573
588
|
|
|
574
589
|
```sh
|
|
575
|
-
%
|
|
590
|
+
% bundle install (or bundle update)
|
|
591
|
+
% bundle e rake test
|
|
576
592
|
```
|
|
577
593
|
|
|
578
|
-
|
|
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`:
|
|
579
595
|
|
|
580
596
|
```sh
|
|
581
|
-
%
|
|
582
|
-
%
|
|
597
|
+
% RAILS_VERSION=7.2 bundle update
|
|
598
|
+
% RAILS_VERSION=7.2 bundle e rake test
|
|
583
599
|
```
|
|
584
600
|
|
|
585
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
|
data/lib/kaminari/version.rb
CHANGED