Skip to content

Commit 2cbe0f2

Browse files
committed
Upgrade Pagy to v43
See [upgrade guide](https://ddnexus.github.io/pagy/guides/upgrade-guide/) for details
1 parent 9f8885e commit 2cbe0f2

6 files changed

Lines changed: 44 additions & 218 deletions

File tree

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ gem 'omniauth_openid_connect'
4040
gem 'omniauth-rails_csrf_protection'
4141

4242
# Pagy used for pagination on long lists of records
43-
gem 'pagy', '~> 9.1'
43+
gem 'pagy'
4444

4545
# Parser added explicitly to allow for the namespace to be available for scout
4646
gem 'parser'

Gemfile.lock

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ GEM
284284
validate_url
285285
webfinger (~> 2.0)
286286
orm_adapter (0.5.0)
287-
pagy (9.4.0)
287+
pagy (43.2.3)
288+
json
289+
yaml
288290
parallel (1.27.0)
289291
parser (3.3.10.0)
290292
ast (~> 2.4.1)
@@ -499,6 +501,7 @@ GEM
499501
websocket-extensions (0.1.5)
500502
xpath (3.2.0)
501503
nokogiri (~> 1.8)
504+
yaml (0.4.0)
502505
yard (0.9.38)
503506
zeitwerk (2.7.4)
504507

@@ -532,7 +535,7 @@ DEPENDENCIES
532535
omniauth
533536
omniauth-rails_csrf_protection
534537
omniauth_openid_connect
535-
pagy (~> 9.1)
538+
pagy
536539
parser
537540
pg
538541
puma (>= 5.0)

app/controllers/term_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
class TermController < ApplicationController
4-
include Pagy::Backend
4+
include Pagy::Method
55

66
# This provides the list of terms that are awaiting confirmation. By default this shows only terms which have been
77
# categorized automatically. Adding `type=all` to the querystring will show _all_ terms which the user has not yet

app/helpers/application_helper.rb

Lines changed: 0 additions & 5 deletions
This file was deleted.

app/views/term/unconfirmed.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ take you to the form for submitting this information.</p>
1010
</p>
1111
<% end %>
1212

13-
<p><%== pagy_info(@pagy) %></p>
13+
<p><%== @pagy.info_tag %></p>
1414

1515
<ul class="list-unbulleted">
1616
<% @records.each do |t| %>
1717
<li><%= link_to(t.phrase, new_term_confirmation_path(t)) %></li>
1818
<% end %>
1919
</ul>
2020

21-
<%== pagy_nav(@pagy) %>
21+
<%== @pagy.series_nav %>

config/initializers/pagy.rb

Lines changed: 35 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -1,220 +1,48 @@
11
# frozen_string_literal: true
22

3-
# Pagy initializer file (9.1.1)
4-
# Customize only what you really need and notice that the core Pagy works also without any of the following lines.
5-
# Should you just cherry pick part of this file, please maintain the require-order of the extras
3+
# Pagy initializer file (43.2.3)
4+
# See https://ddnexus.github.io/pagy/resources/initializer/
65

7-
8-
# Pagy Variables
9-
# See https://ddnexus.github.io/pagy/docs/api/pagy#variables
10-
# You can set any pagy variable as a Pagy::DEFAULT. They can also be overridden per instance by just passing them to
11-
# Pagy.new|Pagy::Countless.new|Pagy::Calendar::*.new or any of the #pagy* controller methods
12-
# Here are the few that make more sense as DEFAULTs:
13-
# Pagy::DEFAULT[:limit] = 20 # default
14-
# Pagy::DEFAULT[:size] = 7 # default
15-
# Pagy::DEFAULT[:ends] = true # default
16-
# Pagy::DEFAULT[:page_param] = :page # default
17-
# Pagy::DEFAULT[:count_args] = [] # example for non AR ORMs
18-
# Pagy::DEFAULT[:max_pages] = 3000 # example
19-
20-
21-
# Extras
22-
# See https://ddnexus.github.io/pagy/categories/extra
23-
24-
25-
# Legacy Compatibility Extras
26-
27-
# Size extra: Enable the Array type for the `:size` variable (e.g. `size: [1,4,4,1]`)
28-
# See https://ddnexus.github.io/pagy/docs/extras/size
29-
# require 'pagy/extras/size' # must be required before the other extras
30-
31-
32-
# Backend Extras
33-
34-
# Arel extra: For better performance utilizing grouped ActiveRecord collections:
35-
# See: https://ddnexus.github.io/pagy/docs/extras/arel
36-
# require 'pagy/extras/arel'
37-
38-
# Array extra: Paginate arrays efficiently, avoiding expensive array-wrapping and without overriding
39-
# See https://ddnexus.github.io/pagy/docs/extras/array
40-
# require 'pagy/extras/array'
41-
42-
# Calendar extra: Add pagination filtering by calendar time unit (year, quarter, month, week, day)
43-
# See https://ddnexus.github.io/pagy/docs/extras/calendar
44-
# require 'pagy/extras/calendar'
45-
# Default for each calendar unit class in IRB:
46-
# >> Pagy::Calendar::Year::DEFAULT
47-
# >> Pagy::Calendar::Quarter::DEFAULT
48-
# >> Pagy::Calendar::Month::DEFAULT
49-
# >> Pagy::Calendar::Week::DEFAULT
50-
# >> Pagy::Calendar::Day::DEFAULT
6+
############ Global Options ################################################################
7+
# See https://ddnexus.github.io/pagy/toolbox/options/ for details.
8+
# Add your global options below. They will be applied globally.
9+
# For example:
5110
#
52-
# Uncomment the following lines, if you need calendar localization without using the I18n extra
53-
# module LocalizePagyCalendar
54-
# def localize(time, opts)
55-
# ::I18n.l(time, **opts)
56-
# end
57-
# end
58-
# Pagy::Calendar.prepend LocalizePagyCalendar
59-
60-
# Countless extra: Paginate without any count, saving one query per rendering
61-
# See https://ddnexus.github.io/pagy/docs/extras/countless
62-
# require 'pagy/extras/countless'
63-
# Pagy::DEFAULT[:countless_minimal] = false # default (eager loading)
64-
65-
# Elasticsearch Rails extra: Paginate `ElasticsearchRails::Results` objects
66-
# See https://ddnexus.github.io/pagy/docs/extras/elasticsearch_rails
67-
# Default :pagy_search method: change only if you use also
68-
# the searchkick or meilisearch extra that defines the same
69-
# Pagy::DEFAULT[:elasticsearch_rails_pagy_search] = :pagy_search
70-
# Default original :search method called internally to do the actual search
71-
# Pagy::DEFAULT[:elasticsearch_rails_search] = :search
72-
# require 'pagy/extras/elasticsearch_rails'
73-
74-
# Headers extra: http response headers (and other helpers) useful for API pagination
75-
# See https://ddnexus.github.io/pagy/docs/extras/headers
76-
# require 'pagy/extras/headers'
77-
# Pagy::DEFAULT[:headers] = { page: 'Current-Page',
78-
# limit: 'Page-Items',
79-
# count: 'Total-Count',
80-
# pages: 'Total-Pages' } # default
81-
82-
# Keyset extra: Paginate with the Pagy keyset pagination technique
83-
# See https://ddnexus.github.io/pagy/docs/extras/keyset
84-
# require 'pagy/extras/keyset'
85-
86-
# Meilisearch extra: Paginate `Meilisearch` result objects
87-
# See https://ddnexus.github.io/pagy/docs/extras/meilisearch
88-
# Default :pagy_search method: change only if you use also
89-
# the elasticsearch_rails or searchkick extra that define the same method
90-
# Pagy::DEFAULT[:meilisearch_pagy_search] = :pagy_search
91-
# Default original :search method called internally to do the actual search
92-
# Pagy::DEFAULT[:meilisearch_search] = :ms_search
93-
# require 'pagy/extras/meilisearch'
94-
95-
# Metadata extra: Provides the pagination metadata to Javascript frameworks like Vue.js, react.js, etc.
96-
# See https://ddnexus.github.io/pagy/docs/extras/metadata
97-
# you must require the JS Tools internal extra (BEFORE the metadata extra) ONLY if you need also the :sequels
98-
# require 'pagy/extras/js_tools'
99-
# require 'pagy/extras/metadata'
100-
# For performance reasons, you should explicitly set ONLY the metadata you use in the frontend
101-
# Pagy::DEFAULT[:metadata] = %i[scaffold_url page prev next last] # example
102-
103-
# Searchkick extra: Paginate `Searchkick::Results` objects
104-
# See https://ddnexus.github.io/pagy/docs/extras/searchkick
105-
# Default :pagy_search method: change only if you use also
106-
# the elasticsearch_rails or meilisearch extra that defines the same
107-
# Pagy::DEFAULT[:searchkick_pagy_search] = :pagy_search
108-
# Default original :search method called internally to do the actual search
109-
# Pagy::DEFAULT[:searchkick_search] = :search
110-
# require 'pagy/extras/searchkick'
111-
# uncomment if you are going to use Searchkick.pagy_search
112-
# Searchkick.extend Pagy::Searchkick
113-
11+
# Pagy.options[:limit] = 10 # Limit the items per page
12+
# Pagy.options[:client_max_limit] = 100 # The client can request a limit up to 100
13+
# Pagy.options[:max_pages] = 200 # Allow only 200 pages
14+
# Pagy.options[:jsonapi] = true # Use JSON:API compliant URLs
11415

115-
# Frontend Extras
11616

117-
# Bootstrap extra: Add nav, nav_js and combo_nav_js helpers and templates for Bootstrap pagination
118-
# See https://ddnexus.github.io/pagy/docs/extras/bootstrap
119-
# require 'pagy/extras/bootstrap'
120-
121-
# Bulma extra: Add nav, nav_js and combo_nav_js helpers and templates for Bulma pagination
122-
# See https://ddnexus.github.io/pagy/docs/extras/bulma
123-
# require 'pagy/extras/bulma'
124-
125-
# Pagy extra: Add the pagy styled versions of the javascript-powered navs
126-
# and a few other components to the Pagy::Frontend module.
127-
# See https://ddnexus.github.io/pagy/docs/extras/pagy
128-
# require 'pagy/extras/pagy'
129-
130-
# Multi size var used by the *_nav_js helpers
131-
# See https://ddnexus.github.io/pagy/docs/extras/pagy#steps
132-
# Pagy::DEFAULT[:steps] = { 0 => 5, 540 => 7, 720 => 9 } # example
133-
134-
135-
# Feature Extras
136-
137-
# Gearbox extra: Automatically change the limit per page depending on the page number
138-
# See https://ddnexus.github.io/pagy/docs/extras/gearbox
139-
# require 'pagy/extras/gearbox'
140-
# set to false only if you want to make :gearbox_extra an opt-in variable
141-
# Pagy::DEFAULT[:gearbox_extra] = false # default true
142-
# Pagy::DEFAULT[:gearbox_limit] = [15, 30, 60, 100] # default
143-
144-
# Limit extra: Allow the client to request a custom limit per page with an optional selector UI
145-
# See https://ddnexus.github.io/pagy/docs/extras/limit
146-
# require 'pagy/extras/limit'
147-
# set to false only if you want to make :limit_extra an opt-in variable
148-
# Pagy::DEFAULT[:limit_extra] = false # default true
149-
# Pagy::DEFAULT[:limit_param] = :limit # default
150-
# Pagy::DEFAULT[:limit_max] = 100 # default
151-
152-
# Overflow extra: Allow for easy handling of overflowing pages
153-
# See https://ddnexus.github.io/pagy/docs/extras/overflow
154-
# require 'pagy/extras/overflow'
155-
# Pagy::DEFAULT[:overflow] = :empty_page # default (other options: :last_page and :exception)
156-
157-
# Trim extra: Remove the page=1 param from links
158-
# See https://ddnexus.github.io/pagy/docs/extras/trim
159-
# require 'pagy/extras/trim'
160-
# set to false only if you want to make :trim_extra an opt-in variable
161-
# Pagy::DEFAULT[:trim_extra] = false # default true
162-
163-
# Standalone extra: Use pagy in non Rack environment/gem
164-
# See https://ddnexus.github.io/pagy/docs/extras/standalone
165-
# require 'pagy/extras/standalone'
166-
# Pagy::DEFAULT[:url] = 'http://www.example.com/subdir' # optional default
167-
168-
# Jsonapi extra: Implements JSON:API specifications
169-
# See https://ddnexus.github.io/pagy/docs/extras/jsonapi
170-
# require 'pagy/extras/jsonapi' # must be required after the other extras
171-
# set to false only if you want to make :jsonapi an opt-in variable
172-
# Pagy::DEFAULT[:jsonapi] = false # default true
173-
174-
# Rails
175-
# Enable the .js file required by the helpers that use javascript
176-
# (pagy*_nav_js, pagy*_combo_nav_js, and pagy_limit_selector_js)
177-
# See https://ddnexus.github.io/pagy/docs/api/javascript
178-
179-
# With the asset pipeline
180-
# Sprockets need to look into the pagy javascripts dir, so add it to the assets paths
181-
# Rails.application.config.assets.paths << Pagy.root.join('javascripts')
17+
############ JavaScript ####################################################################
18+
# See https://ddnexus.github.io/pagy/resources/javascript/ for details.
19+
# Examples for Rails:
20+
# For apps with an assets pipeline
21+
# Rails.application.config.assets.paths << Pagy::ROOT.join('javascripts')
22+
#
23+
# For apps with a javascript builder (e.g. esbuild, webpack, etc.)
24+
# javascript_dir = Rails.root.join('app/javascript')
25+
# Pagy.sync_javascript(javascript_dir, 'pagy.mjs') if Rails.env.development?
18226

183-
# I18n
18427

185-
# Pagy internal I18n: ~18x faster using ~10x less memory than the i18n gem
186-
# See https://ddnexus.github.io/pagy/docs/api/i18n
187-
# Notice: No need to configure anything in this section if your app uses only "en"
188-
# or if you use the i18n extra below
189-
#
190-
# Examples:
191-
# load the "de" built-in locale:
192-
# Pagy::I18n.load(locale: 'de')
28+
############# Overriding Pagy::I18n Lookup #################################################
29+
# Refer to https://ddnexus.github.io/pagy/resources/i18n/ for details.
30+
# Override the I18n lookup by dropping your custom dictionary in some pagy dir.
31+
# Example for Rails:
19332
#
194-
# load the "de" locale defined in the custom file at :filepath:
195-
# Pagy::I18n.load(locale: 'de', filepath: 'path/to/pagy-de.yml')
196-
#
197-
# load the "de", "en" and "es" built-in locales:
198-
# (the first passed :locale will be used also as the default_locale)
199-
# Pagy::I18n.load({ locale: 'de' },
200-
# { locale: 'en' },
201-
# { locale: 'es' })
202-
#
203-
# load the "en" built-in locale, a custom "es" locale,
204-
# and a totally custom locale complete with a custom :pluralize proc:
205-
# (the first passed :locale will be used also as the default_locale)
206-
# Pagy::I18n.load({ locale: 'en' },
207-
# { locale: 'es', filepath: 'path/to/pagy-es.yml' },
208-
# { locale: 'xyz', # not built-in
209-
# filepath: 'path/to/pagy-xyz.yml',
210-
# pluralize: lambda{ |count| ... } )
33+
# Pagy::I18n.pathnames << Rails.root.join('config/locales/pagy')
21134

21235

213-
# I18n extra: uses the standard i18n gem which is ~18x slower using ~10x more memory
214-
# than the default pagy internal i18n (see above)
215-
# See https://ddnexus.github.io/pagy/docs/extras/i18n
216-
# require 'pagy/extras/i18n'
36+
############# I18n Gem Translation #########################################################
37+
# See https://ddnexus.github.io/pagy/resources/i18n/ for details.
38+
#
39+
# Pagy.translate_with_the_slower_i18n_gem!
21740

21841

219-
# When you are done setting your own default freeze it, so it will not get changed accidentally
220-
Pagy::DEFAULT.freeze
42+
############# Calendar Localization for non-en locales ####################################
43+
# See https://ddnexus.github.io/pagy/toolbox/paginators/calendar#localization for details.
44+
# Add your desired locales to the list and uncomment the following line to enable them,
45+
# regardless of whether you use the I18n gem for translations or not, whether with
46+
# Rails or not.
47+
#
48+
# Pagy::Calendar.localize_with_rails_i18n_gem(*your_locales)

0 commit comments

Comments
 (0)