Skip to content

Commit

Permalink
Merge pull request #1498 from denny/update/pagy-4-5-deprecations
Browse files Browse the repository at this point in the history
Update pagy from 4 to 5
  • Loading branch information
denny authored Feb 1, 2024
2 parents 8298fdd + 32a7551 commit 16defdb
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 39 deletions.
25 changes: 13 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PATH
acts-as-taggable-on
acts_as_paranoid
nokogiri (>= 1.11.0.rc4)
pagy (~> 4.11)
pagy (~> 5.10)
pg (>= 1.2.3, < 1.6.0)
pundit
rails (~> 6.1.2, >= 6.1.2.1)
Expand All @@ -18,7 +18,7 @@ PATH
acts_as_paranoid
ckeditor
nokogiri (>= 1.11.0.rc4)
pagy
pagy (~> 5.10)
pg (>= 1.2.3, < 1.6.0)
pundit
rails (~> 6.1.2, >= 6.1.2.1)
Expand Down Expand Up @@ -47,7 +47,7 @@ PATH
mini_magick
mjml-rails
nokogiri (>= 1.10.4)
pagy (~> 4.11)
pagy (~> 5.10)
persistent-dmnd
pg (>= 1.2.3, < 1.6.0)
pry-rails
Expand All @@ -72,7 +72,7 @@ PATH
shiny_forms (21.06)
acts_as_paranoid
nokogiri (>= 1.11.0.rc4)
pagy
pagy (~> 5.10)
pg (>= 1.2.3, < 1.6.0)
pundit
rails (~> 6.1.2, >= 6.1.2.1)
Expand All @@ -84,7 +84,7 @@ PATH
acts_as_paranoid
ckeditor
nokogiri (>= 1.11.0.rc4)
pagy
pagy (~> 5.10)
pg (>= 1.2.3, < 1.6.0)
pundit
rails (~> 6.1.2, >= 6.1.2.1)
Expand All @@ -95,7 +95,7 @@ PATH
shiny_lists (21.06)
acts_as_paranoid
nokogiri (>= 1.11.0.rc4)
pagy
pagy (~> 5.10)
pg (>= 1.2.3, < 1.6.0)
pundit
rails (~> 6.1.2, >= 6.1.2.1)
Expand All @@ -108,7 +108,7 @@ PATH
acts_as_paranoid
ckeditor
nokogiri (>= 1.11.0.rc4)
pagy
pagy (~> 5.10)
pg (>= 1.2.3, < 1.6.0)
pundit
rails (~> 6.1.2, >= 6.1.2.1)
Expand All @@ -120,7 +120,7 @@ PATH
acts_as_paranoid
ckeditor
nokogiri (>= 1.11.0.rc4)
pagy
pagy (~> 5.10)
pg (>= 1.2.3, < 1.6.0)
pundit
rails (~> 6.1.2, >= 6.1.2.1)
Expand All @@ -132,7 +132,7 @@ PATH
acts_as_paranoid
ckeditor
nokogiri (>= 1.11.0.rc4)
pagy
pagy (~> 5.10)
pg (>= 1.2.3, < 1.6.0)
pundit
rails (~> 6.1.2, >= 6.1.2.1)
Expand All @@ -143,7 +143,7 @@ PATH
shiny_profiles (21.06)
acts_as_paranoid
nokogiri (>= 1.11.0.rc4)
pagy
pagy (~> 5.10)
pg (>= 1.2.3, < 1.6.0)
pundit
rails (~> 6.1.2, >= 6.1.2.1)
Expand All @@ -165,7 +165,7 @@ PATH
algoliasearch-rails (~> 1.25)
ckeditor
nokogiri (>= 1.11.0.rc4)
pagy
pagy (~> 5.10)
pg (>= 1.2.3, < 1.6.0)
pg_search
pundit
Expand Down Expand Up @@ -529,7 +529,8 @@ GEM
parser
sorbet-runtime (>= 0.5.9914)
zeitwerk (>= 2.6.1)
pagy (4.11.0)
pagy (5.10.1)
activesupport
parallel (1.24.0)
parallel_tests (4.4.0)
parallel
Expand Down
2 changes: 1 addition & 1 deletion plugins/ShinyAccess/shiny_access.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'acts-as-taggable-on'

# Pagination
spec.add_dependency 'pagy', '~> 4.11'
spec.add_dependency 'pagy', '~> 5.10'

# HTML & XML parser
spec.add_dependency 'nokogiri', '>= 1.11.0.rc4'
Expand Down
2 changes: 1 addition & 1 deletion plugins/ShinyBlog/shiny_blog.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'acts-as-taggable-on'

# Pagination
spec.add_dependency 'pagy'
spec.add_dependency 'pagy', '~> 5.10'

# CKEditor: WYSIWYG editor for admin area
spec.add_dependency 'ckeditor'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ def set_view_paths
end

# Change pager link format from admin/action?page=3&items=12 to admin/action/page/3/items/12
def pagy_url_for( pagy, page )
# rubocop:disable Lint/UnusedMethodArgument
def pagy_url_for( pagy, page, absolute: false, html_escaped: false )
params = request.query_parameters.merge( page: page, items: pagy.vars[:items], only_path: true )
url_for( params )
end
# rubocop:enable Lint/UnusedMethodArgument

def recaptcha_v3_site_key
ENV[ 'RECAPTCHA_V3_SITE_KEY' ]
Expand Down
30 changes: 15 additions & 15 deletions plugins/ShinyCMS/config/initializers/pagy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# Countless extra (paginate without any count): https://ddnexus.github.io/pagy/extras/countless
require 'pagy/extras/countless'
# Pagy::VARS[:cycle] = false # default
# Pagy::DEFAULT[:cycle] = false # default

# Elasticsearch Rails extra: https://ddnexus.github.io/pagy/extras/elasticsearch_rails
# require 'pagy/extras/elasticsearch_rails'
Expand Down Expand Up @@ -57,13 +57,13 @@
# require 'pagy/extras/navs'

# Multi size var used by the *_nav_js helpers: https://ddnexus.github.io/pagy/extras/navs#steps
# Pagy::VARS[:steps] = { 0 => [2,3,3,2], 540 => [3,5,5,3], 720 => [5,7,7,5] } # example
# Pagy::DEFAULT[:steps] = { 0 => [2,3,3,2], 540 => [3,5,5,3], 720 => [5,7,7,5] } # example

### Feature Extras

# HTTP Headers extra: http://ddnexus.github.io/pagy/extras/headers
# require 'pagy/extras/headers'
# Pagy::VARS[:headers] = { page: 'Current-Page', items: 'Page-Items', count: 'Total-Count', pages: 'Total-Pages' }
# Pagy::DEFAULT[:headers] = { page: 'Current-Page', items: 'Page-Items', count: 'Total-Count', pages: 'Total-Pages' }

# Support extra: https://ddnexus.github.io/pagy/extras/support
# Extra support for features like: incremental, infinite, auto-scroll pagination
Expand All @@ -72,40 +72,40 @@
# Items extra: https://ddnexus.github.io/pagy/extras/items
# Allow the client to request a custom number of items per page with an optional selector UI
require 'pagy/extras/items'
# Pagy::VARS[ :items_param ] = :items # default
# Pagy::VARS[ :max_items ] = 100 # default
# Pagy::DEFAULT[ :items_param ] = :items # default
# Pagy::DEFAULT[ :max_items ] = 100 # default

# Overflow extra: https://ddnexus.github.io/pagy/extras/overflow
# require 'pagy/extras/overflow'
# Pagy::VARS[:overflow] = :empty_page # default (other options: :last_page and :exception)
# Pagy::DEFAULT[:overflow] = :empty_page # default (other options: :last_page and :exception)

# Metadata (for JS frameworks) extra: https://ddnexus.github.io/pagy/extras/metadata
# require 'pagy/extras/shared'
# require 'pagy/extras/metadata'
# Pagy::VARS[:metadata] = [:scaffold_url, :count, :page, :prev, :next, :last] # example
# Pagy::DEFAULT[:metadata] = [:scaffold_url, :count, :page, :prev, :next, :last] # example

# Trim extra: https://ddnexus.github.io/pagy/extras/trim
# Remove page=1 param from links
require 'pagy/extras/trim'

## Pagy Variables (https://ddnexus.github.io/pagy/api/pagy#variables)

# All the Pagy::VARS are set for all the Pagy instances but can be overridden
# All the Pagy::DEFAULT are set for all the Pagy instances but can be overridden
# per instance by just passing them to Pagy.new or the #pagy controller method

### Instance variables (https://ddnexus.github.io/pagy/api/pagy#instance-variables)

# TODO: pull this from settings, and allow different defaults for main site and admin area
Pagy::VARS[ :items ] = 10
Pagy::DEFAULT[ :items ] = 10

### Other Variables (https://ddnexus.github.io/pagy/api/pagy#other-variables)

Pagy::VARS[ :size ] = [ 3, 3, 3, 3 ]
Pagy::DEFAULT[ :size ] = [ 3, 3, 3, 3 ]

# Pagy::VARS[:page_param] = :page # default
# Pagy::VARS[:params] = {} # default
# Pagy::VARS[:anchor] = '#anchor' # example
# Pagy::VARS[:link_extra] = 'data-remote="true"' # example
# Pagy::DEFAULT[:page_param] = :page # default
# Pagy::DEFAULT[:params] = {} # default
# Pagy::DEFAULT[:anchor] = '#anchor' # example
# Pagy::DEFAULT[:link_extra] = 'data-remote="true"' # example

## Rails

Expand Down Expand Up @@ -139,4 +139,4 @@
# require 'pagy/extras/i18n'

# Default i18n key
# Pagy::VARS[:i18n_key] = 'pagy.item_name'
# Pagy::DEFAULT[:i18n_key] = 'pagy.item_name'
2 changes: 1 addition & 1 deletion plugins/ShinyCMS/shinycms.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'ckeditor'

# Pagination
spec.add_dependency 'pagy', '~> 4.11'
spec.add_dependency 'pagy', '~> 5.10'

# Atom feeds
spec.add_dependency 'rss'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,13 @@
expect( response.body ).not_to have_css match_tag, text: items[10].public_send( match_text )
end
end

describe 'URL is correctly formatted in links' do
it 'has a link to see older items' do
get "#{base_url}/page/1/items/5"

expect( response.body ).to have_link 'Older', href: "#{base_url}/page/2/items/5"
end
end
end
end
2 changes: 1 addition & 1 deletion plugins/ShinyForms/shiny_forms.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'acts_as_paranoid'

# Pagination
spec.add_dependency 'pagy'
spec.add_dependency 'pagy', '~> 5.10'

# HTML & XML parser
spec.add_dependency 'nokogiri', '>= 1.11.0.rc4'
Expand Down
2 changes: 1 addition & 1 deletion plugins/ShinyInserts/shiny_inserts.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'acts_as_paranoid'

# Pagination
spec.add_dependency 'pagy'
spec.add_dependency 'pagy', '~> 5.10'

# CKEditor: WYSIWYG editor for admin area
spec.add_dependency 'ckeditor'
Expand Down
2 changes: 1 addition & 1 deletion plugins/ShinyLists/shiny_lists.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'acts_as_paranoid'

# Pagination
spec.add_dependency 'pagy'
spec.add_dependency 'pagy', '~> 5.10'

# HTML & XML parser
spec.add_dependency 'nokogiri', '>= 1.11.0.rc4'
Expand Down
2 changes: 1 addition & 1 deletion plugins/ShinyNews/shiny_news.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'acts-as-taggable-on'

# Pagination
spec.add_dependency 'pagy'
spec.add_dependency 'pagy', '~> 5.10'

# CKEditor: WYSIWYG editor for admin area
spec.add_dependency 'ckeditor'
Expand Down
2 changes: 1 addition & 1 deletion plugins/ShinyNewsletters/shiny_newsletters.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'acts_as_paranoid'

# Pagination
spec.add_dependency 'pagy'
spec.add_dependency 'pagy', '~> 5.10'

# CKEditor: WYSIWYG editor for admin area
spec.add_dependency 'ckeditor'
Expand Down
2 changes: 1 addition & 1 deletion plugins/ShinyPages/shiny_pages.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'acts_as_paranoid'

# Pagination
spec.add_dependency 'pagy'
spec.add_dependency 'pagy', '~> 5.10'

# CKEditor: WYSIWYG editor for admin area
spec.add_dependency 'ckeditor'
Expand Down
2 changes: 1 addition & 1 deletion plugins/ShinyProfiles/shiny_profiles.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'acts_as_paranoid'

# Pagination
spec.add_dependency 'pagy'
spec.add_dependency 'pagy', '~> 5.10'

# HTML & XML parser
spec.add_dependency 'nokogiri', '>= 1.11.0.rc4'
Expand Down
2 changes: 1 addition & 1 deletion plugins/ShinySearch/shiny_search.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'acts-as-taggable-on'

# Pagination
spec.add_dependency 'pagy'
spec.add_dependency 'pagy', '~> 5.10'

# CKEditor: WYSIWYG editor for admin area
spec.add_dependency 'ckeditor'
Expand Down

0 comments on commit 16defdb

Please sign in to comment.