paginate-responder 2.1.0 → 2.2.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/.editorconfig +12 -0
- data/.github/workflows/maintenance-cache-wipe.yml +13 -0
- data/.github/workflows/maintenance-workflow-cleanup.yml +17 -0
- data/.github/workflows/release.yml +38 -0
- data/.github/workflows/test.yml +70 -0
- data/.markdownlint.yml +12 -0
- data/.rubocop.yml +12 -0
- data/Appraisals +16 -21
- data/CHANGELOG.md +74 -26
- data/Gemfile +19 -2
- data/README.md +20 -38
- data/Rakefile +2 -0
- data/gemfiles/rails_6.1.gemfile +21 -0
- data/gemfiles/rails_7.0.gemfile +21 -0
- data/gemfiles/rails_7.1.gemfile +21 -0
- data/gemfiles/rails_7.2.gemfile +21 -0
- data/gemfiles/rails_8.0.gemfile +21 -0
- data/lib/paginate-responder/base.rb +12 -6
- data/lib/paginate-responder/kaminari_adapter.rb +7 -6
- data/lib/paginate-responder/pagy_adapter.rb +6 -5
- data/lib/paginate-responder/version.rb +4 -2
- data/lib/paginate-responder/will_paginate_adapter.rb +5 -5
- data/lib/paginate-responder.rb +2 -0
- data/lib/responders/paginate_responder.rb +4 -2
- data/paginate-responder.gemspec +18 -25
- data/renovate.json5 +4 -0
- data/spec/{paginate_responder_spec.rb → responders/paginate_responder_spec.rb} +41 -46
- data/spec/spec_helper.rb +8 -8
- data/spec/support/{10-application.rb → application.rb} +22 -33
- data/spec/support/{05-setup-and-teardown-adapter.rb → setup_and_teardown_adapter.rb} +4 -2
- metadata +25 -207
- data/.travis.yml +0 -58
- data/gemfiles/rails_4_2.gemfile +0 -8
- data/gemfiles/rails_5_0.gemfile +0 -8
- data/gemfiles/rails_5_1.gemfile +0 -8
- data/gemfiles/rails_5_2.gemfile +0 -8
- data/gemfiles/rails_head.gemfile +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17cc83402b74b045416cac923b83a2f67ce068130bb91bc25813873ed0e79ef7
|
4
|
+
data.tar.gz: 476362aba5cef9a87b875d4acc4347522f62e5acc5500f3c574a29580f181136
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f489c5a9c124381a4061c96816ca04c37d455a8e485ebf461919ab616978998ab94712f10ab07aefa4bc998f15ee1167b390c89e6120071277ef00c3c237a76
|
7
|
+
data.tar.gz: 129d753a004579c49219fe32b0b37accb912145b84e26d2d2d0df337b73c0a8c81983b9b958745cbe22e4a749e7b841982d0e36664ee0c1ef6388230f2a4e798
|
data/.editorconfig
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
name: maintenance-workflow-cleanup
|
3
|
+
on:
|
4
|
+
schedule:
|
5
|
+
- cron: "0 0 1 * *"
|
6
|
+
workflow_dispatch:
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
delete-workflow-runs:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: Mattraks/delete-workflow-runs@v2
|
13
|
+
with:
|
14
|
+
token: ${{ github.token }}
|
15
|
+
repository: ${{ github.repository }}
|
16
|
+
retain_days: 180
|
17
|
+
keep_minimum_runs: 50
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# vim: ft=yaml
|
2
|
+
|
3
|
+
name: release
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
tags:
|
8
|
+
- v*
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
rubygems:
|
12
|
+
if: github.repository == 'jgraichen/paginate-responder'
|
13
|
+
runs-on: ubuntu-24.04
|
14
|
+
|
15
|
+
permissions:
|
16
|
+
contents: write
|
17
|
+
id-token: write
|
18
|
+
|
19
|
+
env:
|
20
|
+
BUNDLE_JOBS: 4
|
21
|
+
BUNDLE_RETRY: 10
|
22
|
+
BUNDLE_WITHOUT: development test
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v4
|
26
|
+
|
27
|
+
- uses: ruby/setup-ruby@v1
|
28
|
+
with:
|
29
|
+
ruby-version: ruby
|
30
|
+
bundler-cache: true
|
31
|
+
|
32
|
+
- uses: rubygems/release-gem@v1
|
33
|
+
|
34
|
+
- uses: taiki-e/create-gh-release-action@v1
|
35
|
+
with:
|
36
|
+
changelog: CHANGELOG.md
|
37
|
+
draft: true
|
38
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# vim: ft=yaml
|
2
|
+
|
3
|
+
name: test
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
pull_request:
|
8
|
+
workflow_dispatch:
|
9
|
+
|
10
|
+
env:
|
11
|
+
BUNDLE_JOBS: 4
|
12
|
+
BUNDLE_RETRY: 3
|
13
|
+
BUNDLE_WITHOUT: development
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
rspec:
|
17
|
+
name: Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }}
|
18
|
+
runs-on: ubuntu-24.04
|
19
|
+
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby:
|
23
|
+
- "3.4"
|
24
|
+
- "3.3"
|
25
|
+
- "3.2"
|
26
|
+
- "3.1"
|
27
|
+
gemfile:
|
28
|
+
- rails_8.0
|
29
|
+
- rails_7.2
|
30
|
+
- rails_7.1
|
31
|
+
- rails_7.0
|
32
|
+
- rails_6.1
|
33
|
+
exclude:
|
34
|
+
- ruby: "3.4"
|
35
|
+
gemfile: rails_7.0
|
36
|
+
- ruby: "3.4"
|
37
|
+
gemfile: rails_6.1
|
38
|
+
- ruby: "3.1"
|
39
|
+
gemfile: rails_8.0
|
40
|
+
fail-fast: False
|
41
|
+
|
42
|
+
env:
|
43
|
+
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
44
|
+
|
45
|
+
steps:
|
46
|
+
- uses: actions/checkout@master
|
47
|
+
|
48
|
+
- name: Install dependencies
|
49
|
+
run: |
|
50
|
+
sudo apt-get install --quiet --yes libsqlite3-dev
|
51
|
+
|
52
|
+
- uses: ruby/setup-ruby@v1
|
53
|
+
with:
|
54
|
+
ruby-version: ${{ matrix.ruby }}
|
55
|
+
bundler-cache: True
|
56
|
+
|
57
|
+
- run: bundle exec rspec --color --format documentation
|
58
|
+
|
59
|
+
rubocop:
|
60
|
+
name: rubocop
|
61
|
+
runs-on: ubuntu-24.04
|
62
|
+
|
63
|
+
steps:
|
64
|
+
- uses: actions/checkout@master
|
65
|
+
- uses: ruby/setup-ruby@v1
|
66
|
+
with:
|
67
|
+
ruby-version: "3.4"
|
68
|
+
bundler-cache: True
|
69
|
+
|
70
|
+
- run: bundle exec rubocop --parallel --color
|
data/.markdownlint.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# markdownlint config
|
2
|
+
|
3
|
+
# The CHANGELOG contains duplicated headers by design
|
4
|
+
MD024: false
|
5
|
+
|
6
|
+
# MD013/line-length: disable line length for all. We prefer lines as
|
7
|
+
# long as paragraph with in-editor line breaks.
|
8
|
+
MD013: false
|
9
|
+
|
10
|
+
# MD048/code-fence-style: code fence style
|
11
|
+
MD048:
|
12
|
+
style: backtick
|
data/.rubocop.yml
ADDED
data/Appraisals
CHANGED
@@ -1,31 +1,26 @@
|
|
1
|
-
|
2
|
-
gem 'rails', '~> 4.2.0'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
gem '
|
3
|
+
appraise 'rails-8.0' do
|
4
|
+
gem 'rails', '~> 8.0.0'
|
5
|
+
gem 'sqlite3', '~> 2.0'
|
6
6
|
end
|
7
7
|
|
8
|
-
appraise
|
9
|
-
gem 'rails', '~>
|
10
|
-
|
11
|
-
# Fix version conflict in active_record
|
12
|
-
gem 'sqlite3', '~> 1.3.6'
|
8
|
+
appraise 'rails-7.2' do
|
9
|
+
gem 'rails', '~> 7.2.0'
|
10
|
+
gem 'sqlite3', '~> 2.0'
|
13
11
|
end
|
14
12
|
|
15
|
-
appraise
|
16
|
-
gem 'rails', '~>
|
17
|
-
|
18
|
-
# Fix version conflict in active_record
|
19
|
-
gem 'sqlite3', '~> 1.3.6'
|
13
|
+
appraise 'rails-7.1' do
|
14
|
+
gem 'rails', '~> 7.1.0'
|
15
|
+
gem 'sqlite3', '~> 1.4'
|
20
16
|
end
|
21
17
|
|
22
|
-
appraise
|
23
|
-
gem 'rails', '~>
|
24
|
-
|
25
|
-
# Fix version conflict in active_record
|
26
|
-
gem 'sqlite3', '~> 1.3.6'
|
18
|
+
appraise 'rails-7.0' do
|
19
|
+
gem 'rails', '~> 7.0.0'
|
20
|
+
gem 'sqlite3', '~> 1.4'
|
27
21
|
end
|
28
22
|
|
29
|
-
appraise
|
30
|
-
gem 'rails',
|
23
|
+
appraise 'rails-6.1' do
|
24
|
+
gem 'rails', '~> 6.1.0'
|
25
|
+
gem 'sqlite3', '~> 1.4'
|
31
26
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Changelog
|
2
|
+
|
2
3
|
All notable changes to this project will be documented in this file.
|
3
4
|
|
4
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
@@ -6,57 +7,104 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
7
|
|
7
8
|
## [Unreleased]
|
8
9
|
|
10
|
+
## [2.2.0] - 2025-07-04
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Dropped unsupported Ruby and Rails versions from test matrix
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- Added Rails 6.1 + 7.0 and Ruby 3.0 to new GitHub Actions test pipeline
|
19
|
+
- Added Rails 7.1 and Ruby 3.1, 3.2, 3.3 to test matrix
|
20
|
+
- Added Ruby 3.4 and Rails 7.2+ to test matrix
|
21
|
+
|
22
|
+
### Fixed
|
23
|
+
|
24
|
+
- Fix header case issues in test suite with Rails 7.1
|
25
|
+
|
9
26
|
## 2.1.0 - 2019-02-28
|
27
|
+
|
10
28
|
### Added
|
11
|
-
|
29
|
+
|
30
|
+
- Respond with pagination link headers to HEAD requests (#12)
|
12
31
|
|
13
32
|
## 2.0.0 - 2019-02-19
|
33
|
+
|
14
34
|
### Changed
|
15
|
-
|
35
|
+
|
36
|
+
- Override respond, not to_format for compatibility with decorate-responder 2.0 (#17)
|
16
37
|
|
17
38
|
## 1.8.0 - 2019-02-19
|
39
|
+
|
18
40
|
### Added
|
19
|
-
|
41
|
+
|
42
|
+
- Support for pagination using `pagy` gem (#14)
|
20
43
|
|
21
44
|
### Fixed
|
22
|
-
* sqlite3 version conflict in active_record (#15)
|
23
|
-
* Invalid ?page parameter could cause exceptions (#16)
|
24
45
|
|
25
|
-
|
46
|
+
- sqlite3 version conflict in active_record (#15)
|
47
|
+
- Invalid ?page parameter could cause exceptions (#16)
|
48
|
+
|
49
|
+
## 1.7.0 - 2017-06-02
|
50
|
+
|
51
|
+
### Changed
|
52
|
+
|
53
|
+
- Add `X-Current-Page` header (#10)
|
54
|
+
|
55
|
+
## 1.6.0 - 2016-11-08
|
56
|
+
|
57
|
+
### Changed
|
58
|
+
|
59
|
+
- Large rewrite of adapters to provide more customizable logic
|
60
|
+
- Add controller hook for adapter initialization
|
61
|
+
|
62
|
+
## 1.5.0 - 2016-04-06
|
63
|
+
|
64
|
+
### Changed
|
65
|
+
|
66
|
+
- Adjust `per_page` parameter if max-per-page limit is exceeded (#6)
|
67
|
+
- Add `X-Per-Page` header (#7)
|
68
|
+
|
69
|
+
## 1.4.2 - 2016-02-11
|
26
70
|
|
27
|
-
|
71
|
+
### Changed
|
72
|
+
|
73
|
+
- Fix performance issue with adapter lookup
|
74
|
+
|
75
|
+
## 1.4.1 - 2014-04-30
|
76
|
+
|
77
|
+
### Changed
|
28
78
|
|
29
|
-
|
79
|
+
- Fix issue with non-paginated resources
|
30
80
|
|
31
|
-
|
32
|
-
* Add controller hook for adapter initialization
|
81
|
+
## 1.4.0 - 2014-04-28
|
33
82
|
|
34
|
-
|
83
|
+
### Added
|
35
84
|
|
36
|
-
|
37
|
-
* Add `X-Per-Page` header (#7)
|
85
|
+
- Add `X-Total-Count` header (#4)
|
38
86
|
|
39
|
-
## 1.
|
87
|
+
## 1.3.0 - 2013-03-07
|
40
88
|
|
41
|
-
|
89
|
+
### Fixed
|
42
90
|
|
43
|
-
|
91
|
+
- Fix issues with adapter selection
|
44
92
|
|
45
|
-
|
93
|
+
## 1.2.0 - 2013-02-25
|
46
94
|
|
47
|
-
|
95
|
+
### Added
|
48
96
|
|
49
|
-
|
97
|
+
- Add kaminari support
|
50
98
|
|
51
|
-
|
99
|
+
### Fixed
|
52
100
|
|
53
|
-
|
101
|
+
- Fix issue with missing #each on Fixnum in header generation
|
54
102
|
|
55
|
-
## 1.
|
103
|
+
## 1.1.0 - 2013-01-18
|
56
104
|
|
57
|
-
|
58
|
-
* Fix issue with missing #each on Fixnum in header generation
|
105
|
+
### Added
|
59
106
|
|
60
|
-
|
107
|
+
- Generate Link header using `rack-link_headers`
|
61
108
|
|
62
|
-
|
109
|
+
[Unreleased]: https://github.com/jgraichen/paginate-responder/compare/v2.2.0...HEAD
|
110
|
+
[2.2.0]: https://github.com/jgraichen/paginate-responder/compare/v2.1.0...v2.2.0
|
data/Gemfile
CHANGED
@@ -1,7 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in paginate-responder.gemspec
|
4
6
|
gemspec
|
5
7
|
|
6
|
-
|
7
|
-
gem '
|
8
|
+
gem 'kaminari'
|
9
|
+
gem 'pagy'
|
10
|
+
gem 'will_paginate'
|
11
|
+
|
12
|
+
gem 'actionpack', '>= 6.1.0'
|
13
|
+
gem 'activerecord', '>= 6.1.0'
|
14
|
+
gem 'sqlite3'
|
15
|
+
|
16
|
+
gem 'rspec'
|
17
|
+
gem 'rspec-rails'
|
18
|
+
|
19
|
+
gem 'rubocop-config', github: 'jgraichen/rubocop-config', tag: 'v14'
|
20
|
+
|
21
|
+
group :development do
|
22
|
+
gem 'appraisal'
|
23
|
+
gem 'rake'
|
24
|
+
end
|
data/README.md
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
# Paginate::Responder
|
2
|
-
|
3
|
-
[](https://rubygems.org/gems/paginate-responder)
|
4
|
-
[](https://travis-ci.org/jgraichen/paginate-responder)
|
5
|
-
[](https://codeclimate.com/github/jgraichen/paginate-responder)
|
1
|
+
# Paginate::Responder
|
6
2
|
|
3
|
+
[](https://rubygems.org/gems/paginate-responder)
|
4
|
+
[](https://github.com/jgraichen/paginate-responder/actions/workflows/test.yml)
|
7
5
|
|
8
6
|
A Rails pagination responder with link header support.
|
9
7
|
|
@@ -11,20 +9,15 @@ A Rails pagination responder with link header support.
|
|
11
9
|
|
12
10
|
Add this line to your application's Gemfile:
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
$ bundle
|
19
|
-
|
20
|
-
Or install it yourself as:
|
21
|
-
|
22
|
-
$ gem install paginate-responder
|
12
|
+
```ruby
|
13
|
+
gem 'paginate-responder'
|
14
|
+
```
|
23
15
|
|
24
16
|
You will also need a pagination gem. `PaginateResponder` comes with adapters for
|
25
|
-
|
26
|
-
|
27
|
-
|
17
|
+
|
18
|
+
- [`will_paginate`](https://github.com/mislav/will_paginate),
|
19
|
+
- [`kaminari`](https://github.com/amatsuda/kaminari), and
|
20
|
+
- [`pagy`](https://github.com/ddnexus/pagy).
|
28
21
|
|
29
22
|
It is recommended to use only one pagination gem at once.
|
30
23
|
|
@@ -42,7 +35,7 @@ class MyController < ApplicationController
|
|
42
35
|
end
|
43
36
|
```
|
44
37
|
|
45
|
-
Or use it with [plataformatec/responders](https://github.com/plataformatec/responders):
|
38
|
+
Or use it with [`plataformatec/responders`](https://github.com/plataformatec/responders):
|
46
39
|
|
47
40
|
```ruby
|
48
41
|
class MyController < ApplicationController
|
@@ -53,24 +46,18 @@ end
|
|
53
46
|
`PaginateResponder` will add the following link headers to
|
54
47
|
non HTML responses:
|
55
48
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
49
|
+
- `first` First page's URL.
|
50
|
+
- `last` Last page's URL.
|
51
|
+
- `next` Next page's URL.
|
52
|
+
- `prev` Previous page's URL.
|
60
53
|
|
61
|
-
`next` and `prev` page links will not be added if current
|
62
|
-
page is `first` or `last` page.
|
54
|
+
`next` and `prev` page links will not be added if current page is `first` or `last` page.
|
63
55
|
|
64
|
-
|
65
|
-
number of pages if available and a `X-Total-Count` header
|
66
|
-
with the total number of items. This allows applications
|
67
|
-
to display a progress bar or similar while fetching pages.
|
56
|
+
Additionally, a `X-Total-Pages` header will be added with the total number of pages if available and a `X-Total-Count` header with the total number of items. This allows applications to display a progress bar or similar while fetching pages.
|
68
57
|
|
69
58
|
## Override page detections and options
|
70
59
|
|
71
|
-
You can override the page detection by creating a method
|
72
|
-
`page` in your controller that returns the page index as
|
73
|
-
a fixnum:
|
60
|
+
You can override the page detection by creating a method `page` in your controller that returns the page index as a numeric:
|
74
61
|
|
75
62
|
```ruby
|
76
63
|
class ApplicationController
|
@@ -80,7 +67,7 @@ class ApplicationController
|
|
80
67
|
end
|
81
68
|
```
|
82
69
|
|
83
|
-
|
70
|
+
The same applies to `per_page` and `max_per_page`:
|
84
71
|
|
85
72
|
```ruby
|
86
73
|
class ApplicationController
|
@@ -94,11 +81,6 @@ class ApplicationController
|
|
94
81
|
end
|
95
82
|
```
|
96
83
|
|
97
|
-
## TODOs
|
98
|
-
|
99
|
-
* Documentation
|
100
|
-
** Controller methods
|
101
|
-
|
102
84
|
## Contributing
|
103
85
|
|
104
86
|
1. Fork it
|
@@ -113,4 +95,4 @@ end
|
|
113
95
|
|
114
96
|
[MIT License](http://www.opensource.org/licenses/mit-license.php)
|
115
97
|
|
116
|
-
Copyright
|
98
|
+
Copyright © 2013-2025, Jan Graichen
|
data/Rakefile
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "kaminari"
|
6
|
+
gem "pagy"
|
7
|
+
gem "will_paginate"
|
8
|
+
gem "actionpack", ">= 6.1.0"
|
9
|
+
gem "activerecord", ">= 6.1.0"
|
10
|
+
gem "sqlite3", "~> 1.4"
|
11
|
+
gem "rspec"
|
12
|
+
gem "rspec-rails"
|
13
|
+
gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12"
|
14
|
+
gem "rails", "~> 6.1.0"
|
15
|
+
|
16
|
+
group :development do
|
17
|
+
gem "appraisal"
|
18
|
+
gem "rake"
|
19
|
+
end
|
20
|
+
|
21
|
+
gemspec path: "../"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "kaminari"
|
6
|
+
gem "pagy"
|
7
|
+
gem "will_paginate"
|
8
|
+
gem "actionpack", ">= 6.1.0"
|
9
|
+
gem "activerecord", ">= 6.1.0"
|
10
|
+
gem "sqlite3", "~> 1.4"
|
11
|
+
gem "rspec"
|
12
|
+
gem "rspec-rails"
|
13
|
+
gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12"
|
14
|
+
gem "rails", "~> 7.0.0"
|
15
|
+
|
16
|
+
group :development do
|
17
|
+
gem "appraisal"
|
18
|
+
gem "rake"
|
19
|
+
end
|
20
|
+
|
21
|
+
gemspec path: "../"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "kaminari"
|
6
|
+
gem "pagy"
|
7
|
+
gem "will_paginate"
|
8
|
+
gem "actionpack", ">= 6.1.0"
|
9
|
+
gem "activerecord", ">= 6.1.0"
|
10
|
+
gem "sqlite3", "~> 1.4"
|
11
|
+
gem "rspec"
|
12
|
+
gem "rspec-rails"
|
13
|
+
gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12"
|
14
|
+
gem "rails", "~> 7.1.0"
|
15
|
+
|
16
|
+
group :development do
|
17
|
+
gem "appraisal"
|
18
|
+
gem "rake"
|
19
|
+
end
|
20
|
+
|
21
|
+
gemspec path: "../"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "kaminari"
|
6
|
+
gem "pagy"
|
7
|
+
gem "will_paginate"
|
8
|
+
gem "actionpack", ">= 6.1.0"
|
9
|
+
gem "activerecord", ">= 6.1.0"
|
10
|
+
gem "sqlite3", "~> 2.0"
|
11
|
+
gem "rspec"
|
12
|
+
gem "rspec-rails"
|
13
|
+
gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12"
|
14
|
+
gem "rails", "~> 7.2.0"
|
15
|
+
|
16
|
+
group :development do
|
17
|
+
gem "appraisal"
|
18
|
+
gem "rake"
|
19
|
+
end
|
20
|
+
|
21
|
+
gemspec path: "../"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "kaminari"
|
6
|
+
gem "pagy"
|
7
|
+
gem "will_paginate"
|
8
|
+
gem "actionpack", ">= 6.1.0"
|
9
|
+
gem "activerecord", ">= 6.1.0"
|
10
|
+
gem "sqlite3", "~> 2.0"
|
11
|
+
gem "rspec"
|
12
|
+
gem "rspec-rails"
|
13
|
+
gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12"
|
14
|
+
gem "rails", "~> 8.0.0"
|
15
|
+
|
16
|
+
group :development do
|
17
|
+
gem "appraisal"
|
18
|
+
gem "rake"
|
19
|
+
end
|
20
|
+
|
21
|
+
gemspec path: "../"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PaginateResponder
|
2
4
|
class Base
|
3
5
|
attr_reader :responder, :resource
|
@@ -39,10 +41,10 @@ module PaginateResponder
|
|
39
41
|
link! 'next', page: next_page if next_page
|
40
42
|
link! 'last', page: last_page if last_page
|
41
43
|
|
42
|
-
response.headers[
|
43
|
-
response.headers[
|
44
|
-
response.headers[
|
45
|
-
response.headers[
|
44
|
+
response.headers['X-Total-Pages'] = total_pages.to_s if total_pages
|
45
|
+
response.headers['X-Total-Count'] = total_count.to_s if total_count
|
46
|
+
response.headers['X-Per-Page'] = per_page.to_s if per_page
|
47
|
+
response.headers['X-Current-Page'] = page.to_s if page
|
46
48
|
end
|
47
49
|
|
48
50
|
def page
|
@@ -65,7 +67,11 @@ module PaginateResponder
|
|
65
67
|
val ||= controller.per_page if controller.respond_to? :per_page
|
66
68
|
val ||= controller.params[:per_page].try(:to_i)
|
67
69
|
val ||= default_per_page
|
68
|
-
val < 1
|
70
|
+
if val < 1
|
71
|
+
1
|
72
|
+
else
|
73
|
+
[val, max_per_page].min
|
74
|
+
end
|
69
75
|
end
|
70
76
|
end
|
71
77
|
|
@@ -124,7 +130,7 @@ module PaginateResponder
|
|
124
130
|
end
|
125
131
|
|
126
132
|
class << self
|
127
|
-
def suitable?(
|
133
|
+
def suitable?(_resource)
|
128
134
|
false
|
129
135
|
end
|
130
136
|
end
|