Skip to content

Commit 901f779

Browse files
committed
compact > combo and other changes
1 parent f7425a5 commit 901f779

30 files changed

Lines changed: 258 additions & 240 deletions

β€ŽLEGACY_CHANGELOG.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
### Breaking Changes
191191

192192
- I18n refactoring
193-
- Compact helpers and item selectors have been refactored: you should update your overridden helpers accordingly
193+
- Combo helpers and item selectors have been refactored: you should update your overridden helpers accordingly
194194
- The i18n structure has changed, update your custom i18n locale file
195195

196196
### Commits

β€ŽREADME.mdβ€Ž

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111

1212
Pagy is the ultimate pagination gem that outperforms the others in each and every benchmark and comparison.
1313

14-
## Improvements in 2.0+
14+
## New in 3.0+
1515

16-
- Lower ruby requirements (ruby 1.9+ || jruby 1.7+) make Pagy very convenient also on older systems
17-
- Added RFC-8288 compliant http response `headers` extra
18-
- The i18n internal implementation now includes full dynamic support for multi-language apps, it's ~18x faster and uses ~10x less memory than the i18n gem
19-
- The `searchkick` and `elasticsearch_rails` extras have been refactored with more and better options
20-
- Pagy 2.0+ is even faster and lighter than 1.0+ (see charts below)
16+
- Internal refactoring of nav helpers for improved performance and more intuitive API
17+
- Added [Maximizing Performance](https://ddnexus.github.io/pagy/how-to#maximizing-performance) docs as a practical guide to choose the best options for your requirements and environment
18+
- Pagy 3.0+ is even faster and lighter than 2.0+ on modern environments (see the charts below)
19+
20+
**Notice**: Updating from 2.0+ to 3.0+ requires only a few renaming. Check the [CHANGELOG](https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md) for details.
21+
22+
**Suggestion**: If you are using any `pagy*_nav` helper, [consider to switch](https://ddnexus.github.io/pagy/how-to#consider-the-nav_js) to `pagy*_nav_js`, which gives you the same output with a substancial performance boost.
2123

2224
## Comparison with other gems
2325

@@ -64,7 +66,7 @@ _The [IPS/Kb ratio](http://ddnexus.github.io/pagination-comparison/gems.html#eff
6466

6567
### Unlike the other gems
6668

67-
- Pagy is very modular and does not load nor execute unnecessary code in your app _(see [why...](https://ddnexus.github.io/pagy/how-to#global-configuration))_
69+
- Pagy is very modular and does not load any unnecessary code in your app _(see [why...](https://ddnexus.github.io/pagy/how-to#global-configuration))_
6870
- It works even with collections/scopes that already used `limit` and `offset` _(see [how...](https://ddnexus.github.io/pagy/how-to#paginate-a-pre-offsetted-and-pre-limited-collection))_
6971
- It works with fast helpers OR easy to edit templates _(see [more...](https://ddnexus.github.io/pagy/how-to#using-templates))_
7072
- It raises real `Pagy::OverflowError` exceptions that you can rescue from _(see [how...](https://ddnexus.github.io/pagy/how-to#handling-pagyoutofrangeerror-exception))_ or use the [overflow extra](http://ddnexus.github.io/pagy/extras/overflow) for a few ready to use common behaviors
@@ -73,7 +75,7 @@ _The [IPS/Kb ratio](http://ddnexus.github.io/pagination-comparison/gems.html#eff
7375

7476
### Easy to use
7577

76-
You can use Pagy in a quite familiar way:
78+
After installing and including Pagy _(see [Quick Start](https://ddnexus.github.io/pagy/how-to#quick-start))_, you can use it in a quite familiar way:
7779

7880
Paginate your collection in some controller:
7981

@@ -93,8 +95,6 @@ Or - if you prefer - render the navigation links with a template:
9395
<%== render 'pagy/nav', locals: {pagy: @pagy} %>
9496
```
9597

96-
_(see [Quick Start](https://ddnexus.github.io/pagy/how-to#quick-start) for more details)_
97-
9898
## Easy to customize
9999

100100
Use the official extras, or write your own in just a few lines. Extras add special options and manage different components, behaviors, Frontend or Backend environments... usually by just requiring them:
@@ -108,12 +108,12 @@ Use the official extras, or write your own in just a few lines. Extras add speci
108108

109109
### Frontend Extras
110110

111-
- [bootstrap](http://ddnexus.github.io/pagy/extras/bootstrap): Add nav, nav_js and compact_nav_js helpers for the Bootstrap [pagination component](https://getbootstrap.com/docs/4.1/components/pagination)
112-
- [bulma](http://ddnexus.github.io/pagy/extras/bulma): Add nav, nav_js and compact_nav_js helpers for the Bulma CSS [pagination component](https://bulma.io/documentation/components/pagination)
113-
- [foundation](http://ddnexus.github.io/pagy/extras/foundation): Add nav, nav_js and compact_nav_js helpers for the Foundation [pagination component](https://foundation.zurb.com/sites/docs/pagination.html)
114-
- [materialize](http://ddnexus.github.io/pagy/extras/materialize): Add nav, nav_js and compact_nav_js helpers for the Materialize CSS [pagination component](https://materializecss.com/pagination.html)
115-
- [navs](http://ddnexus.github.io/pagy/extras/navs): Add nav_js and compact_nav_js unstyled helpers
116-
- [semantic](http://ddnexus.github.io/pagy/extras/semantic): Add nav, nav_js and compact_nav_js helpers for the Semantic UI CSS [pagination component](https://semantic-ui.com/collections/menu.html)
111+
- [bootstrap](http://ddnexus.github.io/pagy/extras/bootstrap): Add nav, nav_js and combo_nav_js helpers for the Bootstrap [pagination component](https://getbootstrap.com/docs/4.1/components/pagination)
112+
- [bulma](http://ddnexus.github.io/pagy/extras/bulma): Add nav, nav_js and combo_nav_js helpers for the Bulma CSS [pagination component](https://bulma.io/documentation/components/pagination)
113+
- [foundation](http://ddnexus.github.io/pagy/extras/foundation): Add nav, nav_js and combo_nav_js helpers for the Foundation [pagination component](https://foundation.zurb.com/sites/docs/pagination.html)
114+
- [materialize](http://ddnexus.github.io/pagy/extras/materialize): Add nav, nav_js and combo_nav_js helpers for the Materialize CSS [pagination component](https://materializecss.com/pagination.html)
115+
- [navs](http://ddnexus.github.io/pagy/extras/navs): Add nav_js and combo_nav_js unstyled helpers
116+
- [semantic](http://ddnexus.github.io/pagy/extras/semantic): Add nav, nav_js and combo_nav_js helpers for the Semantic UI CSS [pagination component](https://semantic-ui.com/collections/menu.html)
117117

118118
### Feature Extras
119119

@@ -126,11 +126,11 @@ Use the official extras, or write your own in just a few lines. Extras add speci
126126

127127
### Alternative Components
128128

129-
Besides the classic pagination `nav`, Pagy offers a few ready to use alternatives like:
129+
Besides the classic pagination offered by the `pagy_nav` helpers, you can use a couple of more performant alternatives:
130130

131-
- [nav_js](http://ddnexus.github.io/pagy/extras/navs#javascript-navs): A classic looking UI that fits the number of page links to the available width on the client-side:<br>![bootstrap_nav_js](docs/assets/images/bootstrap_nav_js-w.png)
131+
- [pagy_nav_js](http://ddnexus.github.io/pagy/extras/navs#javascript-navs): A faster and lighter classic looking UI, rendered on the client side with optional responsiveness:<br>![bootstrap_nav_js](docs/assets/images/bootstrap_nav_js-w.png)
132132

133-
- [compact_nav_js](http://ddnexus.github.io/pagy/extras/navs#javascript-compact-navs): An alternative UI that combines the pagination feature with the navigation info in one compact element:<br>![bootstrap_compact_nav_js](docs/assets/images/bootstrap_compact_nav_js-w.png)
133+
- [pagy_combo_nav_js](http://ddnexus.github.io/pagy/extras/navs#javascript-combo-navs): The fastest and lighest alternative UI that combines navigation and pagination info in a single compact element:<br>![bootstrap_combo_nav_js](docs/assets/images/bootstrap_combo_nav_js-w.png)
134134

135135
## Resources
136136

β€Ždocs/api/countless.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The available values for the `:overflow` variable are `:empty_page` and `:except
4141

4242
### Features without support
4343

44-
The `pagy_info` and all the `*_compact_nav_js` helpers that use the total `count` are not supported.
44+
The `pagy_info` and all the `*_combo_nav_js` helpers that use the total `count` are not supported.
4545

4646
## How countless pagination works
4747

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

β€Ždocs/extras.mdβ€Ž

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ Pagy comes with a few optional extensions/extras:
88
| Extra | Description | Links |
99
|:----------------------|:---------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------|
1010
| `array` | Paginate arrays efficiently avoiding expensive array-wrapping and without overriding | [array.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/array.rb), [documentation](extras/array.md) |
11-
| `bootstrap` | Add nav, nav_js and compact_nav_js helpers for the Bootstrap [pagination component](https://getbootstrap.com/docs/4.1/components/pagination) | [bootstrap.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/bootstrap.rb), [documentation](extras/bootstrap.md) |
12-
| `bulma` | Add nav, nav_js and compact_nav_js helpers for the Bulma [pagination component](https://bulma.io/documentation/components/pagination) | [bulma.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/bulma.rb), [documentation](extras/bulma.md) |
11+
| `bootstrap` | Add nav, nav_js and combo_nav_js helpers for the Bootstrap [pagination component](https://getbootstrap.com/docs/4.1/components/pagination) | [bootstrap.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/bootstrap.rb), [documentation](extras/bootstrap.md) |
12+
| `bulma` | Add nav, nav_js and combo_nav_js helpers for the Bulma [pagination component](https://bulma.io/documentation/components/pagination) | [bulma.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/bulma.rb), [documentation](extras/bulma.md) |
1313
| `countless` | Paginate without any count, saving one query per rendering | [countless.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/countless.rb), [documentation](extras/countless.md) |
1414
| `elasticsearch_rails` | Paginate `elasticsearch_rails` gem results efficiently | [elasticsearch_rails.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/elasticsearch_rails.rb), [documentation](extras/elasticsearch_rails.md) |
15-
| `foundation` | Add nav, nav_js and compact_nav_js helpers for the Foundation [pagination component](https://foundation.zurb.com/sites/docs/pagination.html) | [foundation.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/foundation.rb), [documentation](extras/foundation.md) |
15+
| `foundation` | Add nav, nav_js and combo_nav_js helpers for the Foundation [pagination component](https://foundation.zurb.com/sites/docs/pagination.html) | [foundation.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/foundation.rb), [documentation](extras/foundation.md) |
1616
| `headers` | Add [RFC-8288](https://tools.ietf.org/html/rfc8288) compliant http response headers (and other helpers) useful for API pagination | [headers.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/headers.rb), [documentation](extras/headers.md) |
1717
| `i18n` | Use the `I18n` gem instead of the pagy implementation | [i18n.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/i81n.rb), [documentation](extras/i18n.md) |
1818
| `items` | Allow the client to request a custom number of items per page with a ready to use selector UI | [items.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/items.rb), [documentation](extras/items.md) |
19-
| `materialize` | Add nav, nav_js and compact_nav_js helpers for the Materialize CSS [pagination component](https://materializecss.com/pagination.html) | [materialize.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/materialize.rb), [documentation](extras/materialize.md) |
20-
| `navs` | Add nav_js and compact_nav_js javascript unstyled helpers | [navs.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/navs.rb), [documentation](extras/navs.md) |
19+
| `materialize` | Add nav, nav_js and combo_nav_js helpers for the Materialize CSS [pagination component](https://materializecss.com/pagination.html) | [materialize.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/materialize.rb), [documentation](extras/materialize.md) |
20+
| `navs` | Add nav_js and combo_nav_js javascript unstyled helpers | [navs.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/navs.rb), [documentation](extras/navs.md) |
2121
| `overflow` | Allow for easy handling of overflowing pages | [overflow.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/overflow.rb), [documentation](extras/overflow.md) |
2222
| `searchkick` | Paginate arrays efficiently avoiding expensive array-wrapping and without overriding | [searchkick.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/searchkick.rb), [documentation](extras/searchkick.md) |
23-
| `semantic` | Add nav, nav_js and compact_nav_js helpers for the Semantic UI CSS [pagination component](https://semantic-ui.com/collections/menu.html) | [semantic.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/semantic.rb), [documentation](extras/semantic.md) |
23+
| `semantic` | Add nav, nav_js and combo_nav_js helpers for the Semantic UI CSS [pagination component](https://semantic-ui.com/collections/menu.html) | [semantic.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/semantic.rb), [documentation](extras/semantic.md) |
2424
| `support` | Extra support for features like: incremental, infinite, auto-scroll pagination | [support.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/support.rb), [documentation](extras/support.md) |
2525
| `trim` | Remove the `page=1` param from links | [trim.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/trim.rb), [documentation](extras/trim.md) |
2626

@@ -47,12 +47,16 @@ A few extras require the [pagy/extras/shared](https://github.com/ddnexus/pagy/bl
4747

4848
A few helpers use javascript, and they are clearly recognizable by the `js` suffix:
4949

50-
- `pagy_*_nav_js`
51-
- `pagy_*_compact_nav_js`
50+
- `pagy*_nav_js`
51+
- `pagy*_combo_nav_js`
5252
- `pagy_items_selector_js`
5353

5454
If you use any of them you should load the [pagy.js](https://github.com/ddnexus/pagy/blob/master/lib/javascripts/pagy.js) file, and run `Pagy.init()` on window load and eventually on [AJAX-load](#using-ajax-with-javascript-enabled-helpers).
5555

56+
### Add the oj gem
57+
58+
Although it's not a requirement, if you are on ruby 2.0+ (not jruby), you should add the `gem 'oj'` to your Gemfile. When available, Pagy will automatically use it to boost the performance.
59+
5660
### In rails apps
5761

5862
#### With the asset pipeline

β€Ždocs/extras/bootstrap.mdβ€Ž

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ with a fast helper:
2121
```erb
2222
<%== pagy_bootstrap_nav(@pagy) %>
2323
<%== pagy_bootstrap_nav_js(@pagy) %>
24-
<%== pagy_bootstrap_compact_nav_js(@pagy) %>
24+
<%== pagy_bootstrap_combo_nav_js(@pagy) %>
2525
```
2626

2727
or with a template:
@@ -30,7 +30,7 @@ or with a template:
3030
<%== render 'pagy/bootstrap_nav', locals: {pagy: @pagy} %>
3131
```
3232

33-
Configure [javascript](../extras.md#javascript) if you use `pagy_bootstrap_nav_js` or `pagy_bootstrap_compact_nav_js`.
33+
Configure [javascript](../extras.md#javascript) if you use `pagy_bootstrap_nav_js` or `pagy_bootstrap_combo_nav_js`.
3434

3535
## Files
3636

@@ -57,12 +57,12 @@ This method is the same as the `pagy_nav_js`, but customized for the Bootstrap f
5757
See more details in the [javascript navs](navs.md#javascript-navs) documentation.
5858

5959

60-
### pagy_bootstrap_compact_nav_js(pagy, ...)
60+
### pagy_bootstrap_combo_nav_js(pagy, ...)
6161

62-
This method is the same as the `pagy_compact_nav_js`, but customized for the Bootstrap framework.
62+
This method is the same as the `pagy_combo_nav_js`, but customized for the Bootstrap framework.
6363

6464
Here is an example:
6565

66-
![bootstrap_compact_nav_js](../assets/images/bootstrap_compact_nav_js-g.png)
66+
![bootstrap_combo_nav_js](../assets/images/bootstrap_combo_nav_js-g.png)
6767

68-
See more details in the [javascript compact navs](navs.md#javascript-compact-navs) documentation.
68+
See more details in the [javascript compact navs](navs.md#javascript-combo-navs) documentation.

β€Ždocs/extras/bulma.mdβ€Ž

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ with a fast helper:
2121
```erb
2222
<%== pagy_bulma_nav(@pagy) %>
2323
<%== pagy_bulma_nav_js(@pagy) %>
24-
<%== pagy_bulma_compact_nav_js(@pagy) %>
24+
<%== pagy_bulma_combo_nav_js(@pagy) %>
2525
```
2626

2727
or with a template:
@@ -30,7 +30,7 @@ or with a template:
3030
<%== render 'pagy/bulma_nav', locals: {pagy: @pagy} %>
3131
```
3232

33-
Configure [javascript](../extras.md#javascript) if you use `pagy_bulma_nav_js` or `pagy_bulma_compact_nav_js`.
33+
Configure [javascript](../extras.md#javascript) if you use `pagy_bulma_nav_js` or `pagy_bulma_combo_nav_js`.
3434

3535
## Files
3636

@@ -55,12 +55,12 @@ This method is the same as the `pagy_nav_js`, but customized for the Bulma CSS f
5555

5656
See more details in the [javascript navs](navs.md#javascript-navs) documentation.
5757

58-
### pagy_bulma_compact_nav_js(pagy, ...)
58+
### pagy_bulma_combo_nav_js(pagy, ...)
5959

60-
This method is the same as the `pagy_compact_nav_js`, but customized for the Bulma CSS framework.
60+
This method is the same as the `pagy_combo_nav_js`, but customized for the Bulma CSS framework.
6161

6262
Here is an example:
6363

64-
![bulma_compact_nav_js](../assets/images/bulma_compact_nav_js-g.png)
64+
![bulma_combo_nav_js](../assets/images/bulma_combo_nav_js-g.png)
6565

66-
See more details in the [compact_navs_js](navs.md#javascript-compact-navs) documentation.
66+
See more details in the [compact_navs_js](navs.md#javascript-combo-navs) documentation.

0 commit comments

Comments
 (0)