Skip to content

Commit

Permalink
Change default :size to 7
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Jan 18, 2024
1 parent 2438e33 commit 97bb482
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 51 deletions.
2 changes: 1 addition & 1 deletion docs/api/pagy.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ They are all integers:

| Variable | Description | Default |
|:----------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------|
| `:size` | The size of the page links to show: can be an array of initial pages, before current page, after current page, final pages or the total page size. _(see also [How to control the page links](/docs/how-to.md#control-the-page-links))_ | `[1,4,4,1]` |
| `:size` | The size of the page links to show: can be an array of initial pages, before current page, after current page, final pages or the total page size. _(see also [How to control the page links](/docs/how-to.md#control-the-page-links))_ | `7` |
| `:page_param` | The name of the page param name used in the url. _(see [How to customize the page param](/docs/how-to.md#customize-the-page-param))_ | `:page` |
| `:params` | It can be a `Hash` of params to add to the URL, or a `Proc` that can edit/add/delete the request params _(see [How to customize the params](/docs/how-to.md#customize-the-params))_ | `{}` |
| `:fragment` | The arbitrary fragment string (including the "#") to add to the url. _(see [How to customize the params](/docs/how-to.md#customize-the-params))_ | `""` |
Expand Down
2 changes: 1 addition & 1 deletion lib/config/pagy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# Other Variables
# See https://ddnexus.github.io/pagy/docs/api/pagy#other-variables
# Pagy::DEFAULT[:size] = [1,4,4,1] # default
# Pagy::DEFAULT[:size] = [1,4,4,1] # default pagy < 7.0
# Pagy::DEFAULT[:page_param] = :page # default
# The :params can be also set as a lambda e.g ->(params){ params.exclude('useless').merge!('custom' => 'useful') }
# Pagy::DEFAULT[:params] = {} # default
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.root
DEFAULT = { page: 1, # rubocop:disable Style/MutableConstant
items: 20,
outset: 0,
size: [1, 4, 4, 1],
size: 7,
page_param: :page,
params: {},
fragment: '',
Expand Down
12 changes: 6 additions & 6 deletions test/pagy/extras/bootstrap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

describe '#pagy_bootstrap_nav' do
it 'renders first page' do
pagy = Pagy.new(count: 1000, page: 1)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 1)
_(app.pagy_bootstrap_nav(pagy)).must_rematch
_(app.pagy_bootstrap_nav(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra')).must_rematch
end
it 'renders intermediate page' do
pagy = Pagy.new(count: 1000, page: 20)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 20)
_(app.pagy_bootstrap_nav(pagy)).must_rematch
_(app.pagy_bootstrap_nav(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra')).must_rematch
end
it 'renders last page' do
pagy = Pagy.new(count: 1000, page: 50)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 50)
_(app.pagy_bootstrap_nav(pagy)).must_rematch
_(app.pagy_bootstrap_nav(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra')).must_rematch
end
Expand All @@ -32,7 +32,7 @@

describe '#pagy_bootstrap_nav_js' do
it 'renders first page' do
pagy = Pagy.new(count: 1000, page: 1)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 1)
_(app.pagy_bootstrap_nav_js(pagy)).must_rematch
_(app.pagy_bootstrap_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
Expand All @@ -46,13 +46,13 @@
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
end
it 'renders intermediate page' do
pagy = Pagy.new(count: 1000, page: 20)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 20)
_(app.pagy_bootstrap_nav_js(pagy)).must_rematch
_(app.pagy_bootstrap_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
end
it 'renders last page' do
pagy = Pagy.new(count: 1000, page: 50)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 50)
_(app.pagy_bootstrap_nav_js(pagy)).must_rematch
_(app.pagy_bootstrap_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
Expand Down
12 changes: 6 additions & 6 deletions test/pagy/extras/bulma_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

describe '#pagy_bulma_nav' do
it 'renders first page' do
pagy = Pagy.new(count: 1000, page: 1)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 1)
_(app.pagy_bulma_nav(pagy, pagy_id: 'test-nav-id')).must_rematch
_(app.pagy_bulma_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra')).must_rematch
end
it 'renders intermediate page' do
pagy = Pagy.new(count: 1000, page: 20)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 20)
_(app.pagy_bulma_nav(pagy)).must_rematch
_(app.pagy_bulma_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra')).must_rematch
end
it 'renders last page' do
pagy = Pagy.new(count: 1000, page: 50)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 50)
_(app.pagy_bulma_nav(pagy)).must_rematch
_(app.pagy_bulma_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra')).must_rematch
end
Expand All @@ -32,7 +32,7 @@

describe '#pagy_bulma_nav_js' do
it 'renders first page' do
pagy = Pagy.new(count: 1000, page: 1)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 1)
_(app.pagy_bulma_nav_js(pagy)).must_rematch
_(app.pagy_bulma_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
Expand All @@ -46,13 +46,13 @@
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
end
it 'renders intermediate page' do
pagy = Pagy.new(count: 1000, page: 20)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 20)
_(app.pagy_bulma_nav_js(pagy)).must_rematch
_(app.pagy_bulma_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
end
it 'renders last page' do
pagy = Pagy.new(count: 1000, page: 50)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 50)
_(app.pagy_bulma_nav_js(pagy)).must_rematch
_(app.pagy_bulma_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
Expand Down
11 changes: 7 additions & 4 deletions test/pagy/extras/calendar_extra_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def app(**opts)
end
it 'selects :month for the last page' do
calendar, _pagy, entries = app(params: { month_page: 26 }).send(:pagy_calendar, @collection,
month: {},
month: { },
pagy: { items: 600 })
_(calendar[:month].series).must_equal [1, :gap, 22, 23, 24, 25, '26']
_(calendar[:month].prev).must_equal 25
Expand All @@ -141,7 +141,8 @@ def app(**opts)
end
it 'selects :week for the first page' do
calendar, _pagy, entries = app(params: { week_page: 1 }).send(:pagy_calendar, @collection,
week: { first_weekday: :sunday },
week: { first_weekday: :sunday,
size: [1, 4, 4, 1]},
pagy: { items: 600 })
_(calendar[:week].series).must_equal ["1", 2, 3, 4, 5, :gap, 109]
_(calendar[:week].pages).must_equal 109
Expand All @@ -151,7 +152,8 @@ def app(**opts)
end
it 'selects :week for an intermediate page' do
calendar, _pagy, entries = app(params: { week_page: 25 }).send(:pagy_calendar, @collection,
week: { first_weekday: :sunday },
week: { first_weekday: :sunday,
size: [1, 4, 4, 1] },
pagy: { items: 600 })
_(calendar[:week].series).must_equal [1, :gap, 21, 22, 23, 24, "25", 26, 27, 28, 29, :gap, 109]
_(calendar[:week].prev).must_equal 24
Expand All @@ -160,7 +162,8 @@ def app(**opts)
end
it 'selects :week for the last page' do
calendar, _pagy, entries = app(params: { week_page: 109 }).send(:pagy_calendar, @collection,
week: { first_weekday: :sunday },
week: { first_weekday: :sunday,
size: [1, 4, 4, 1]},
pagy: { items: 600 })
_(calendar[:week].series).must_equal [1, :gap, 105, 106, 107, 108, "109"]
_(calendar[:week].prev).must_equal 108
Expand Down
4 changes: 2 additions & 2 deletions test/pagy/extras/countless_extra_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
_(pagy.next).must_equal 2
end
it 'shows start-pages, :gap, before-pages, current and next for intermediate page' do
pagy, = app.send(:pagy_countless, @collection, page: 25)
pagy, = app.send(:pagy_countless, @collection, size: [1, 4, 4, 1], page: 25)
_(pagy.series).must_equal [1, :gap, 21, 22, 23, 24, '25', 26]
_(pagy.prev).must_equal 24
_(pagy.next).must_equal 26
end
it 'shows start-pages, :gap, before-pages, current and next for last page' do
pagy, = app.send(:pagy_countless, @collection, page: last_page)
pagy, = app.send(:pagy_countless, @collection, size: [1, 4, 4, 1], page: last_page)
_(pagy.series).must_equal [1, :gap, 46, 47, 48, 49, '50']
_(pagy.prev).must_equal 49
_(pagy.next).must_be_nil
Expand Down
12 changes: 6 additions & 6 deletions test/pagy/extras/foundation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

describe '#pagy_foundation_nav' do
it 'renders first page' do
pagy = Pagy.new(count: 1000, page: 1)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 1)
_(app.pagy_foundation_nav(pagy)).must_rematch
_(app.pagy_foundation_nav(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra')).must_rematch
end
it 'renders intermediate page' do
pagy = Pagy.new(count: 1000, page: 20)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 20)
_(app.pagy_foundation_nav(pagy)).must_rematch
_(app.pagy_foundation_nav(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra')).must_rematch
end
it 'renders last page' do
pagy = Pagy.new(count: 1000, page: 50)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 50)
_(app.pagy_foundation_nav(pagy)).must_rematch
_(app.pagy_foundation_nav(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra')).must_rematch
end
Expand All @@ -32,7 +32,7 @@

describe '#pagy_foundation_nav_js' do
it 'renders first page' do
pagy = Pagy.new(count: 1000, page: 1)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 1)
_(app.pagy_foundation_nav_js(pagy)).must_rematch
_(app.pagy_foundation_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
Expand All @@ -46,13 +46,13 @@
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
end
it 'renders intermediate page' do
pagy = Pagy.new(count: 1000, page: 20)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 20)
_(app.pagy_foundation_nav_js(pagy)).must_rematch
_(app.pagy_foundation_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
end
it 'renders last page' do
pagy = Pagy.new(count: 1000, page: 50)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 50)
_(app.pagy_foundation_nav_js(pagy)).must_rematch
_(app.pagy_foundation_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
Expand Down
12 changes: 6 additions & 6 deletions test/pagy/extras/materialize_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

describe '#pagy_materialize_nav' do
it 'renders first page' do
pagy = Pagy.new(count: 1000, page: 1)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 1)
_(app.pagy_materialize_nav(pagy)).must_rematch
_(app.pagy_materialize_nav(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra')).must_rematch
end
it 'renders intermediate page' do
pagy = Pagy.new(count: 1000, page: 20)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 20)
_(app.pagy_materialize_nav(pagy)).must_rematch
_(app.pagy_materialize_nav(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra')).must_rematch
end
it 'renders last page' do
pagy = Pagy.new(count: 1000, page: 50)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 50)
_(app.pagy_materialize_nav(pagy)).must_rematch
_(app.pagy_materialize_nav(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra')).must_rematch
end
Expand All @@ -32,7 +32,7 @@

describe '#pagy_materialize_nav_js' do
it 'renders first page' do
pagy = Pagy.new(count: 1000, page: 1)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 1)
_(app.pagy_materialize_nav_js(pagy)).must_rematch
_(app.pagy_materialize_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
Expand All @@ -46,13 +46,13 @@
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
end
it 'renders intermediate page' do
pagy = Pagy.new(count: 1000, page: 20)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 20)
_(app.pagy_materialize_nav_js(pagy)).must_rematch
_(app.pagy_materialize_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
end
it 'renders last page' do
pagy = Pagy.new(count: 1000, page: 50)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 50)
_(app.pagy_materialize_nav_js(pagy)).must_rematch
_(app.pagy_materialize_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
Expand Down
2 changes: 1 addition & 1 deletion test/pagy/extras/metadata_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
_(Pagy::DEFAULT[:metadata]).must_rematch
end
it 'returns the full pagy metadata' do
pagy, _records = app.send(:pagy, @collection, metadata: (Pagy::DEFAULT[:metadata]) + [:sequels])
pagy, _records = app.send(:pagy, @collection, size: [1, 4, 4, 1], metadata: (Pagy::DEFAULT[:metadata]) + [:sequels])
_(app.send(:pagy_metadata, pagy)).must_rematch
end
it 'checks for unknown metadata' do
Expand Down
6 changes: 3 additions & 3 deletions test/pagy/extras/navs_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

describe '#pagy_nav_js' do
it 'renders first page' do
pagy = Pagy.new(count: 1000, page: 1)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 1)
_(app.pagy_nav_js(pagy)).must_rematch
_(app.pagy_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
Expand All @@ -24,13 +24,13 @@
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
end
it 'renders intermediate page' do
pagy = Pagy.new(count: 1000, page: 20)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 20)
_(app.pagy_nav_js(pagy)).must_rematch
_(app.pagy_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
end
it 'renders last page' do
pagy = Pagy.new(count: 1000, page: 50)
pagy = Pagy.new(size: [1, 4, 4, 1], count: 1000, page: 50)
_(app.pagy_nav_js(pagy)).must_rematch
_(app.pagy_nav_js(pagy, pagy_id: 'test-nav-id', link_extra: 'link-extra',
steps: { 0 => [1, 2, 2, 1], 600 => [1, 3, 3, 1] })).must_rematch
Expand Down
Loading

0 comments on commit 97bb482

Please sign in to comment.