You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,13 +11,15 @@
11
11
12
12
Pagy is the ultimate pagination gem that outperforms the others in each and every benchmark and comparison.
13
13
14
-
## Improvements in 2.0+
14
+
## New in 3.0+
15
15
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.
- 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))_
68
70
- 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))_
69
71
- It works with fast helpers OR easy to edit templates _(see [more...](https://ddnexus.github.io/pagy/how-to#using-templates))_
70
72
- 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
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:
77
79
78
80
Paginate your collection in some controller:
79
81
@@ -93,8 +95,6 @@ Or - if you prefer - render the navigation links with a template:
93
95
<%== render 'pagy/nav', locals: {pagy: @pagy} %>
94
96
```
95
97
96
-
_(see [Quick Start](https://ddnexus.github.io/pagy/how-to#quick-start) for more details)_
97
-
98
98
## Easy to customize
99
99
100
100
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
108
108
109
109
### Frontend Extras
110
110
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)
117
117
118
118
### Feature Extras
119
119
@@ -126,11 +126,11 @@ Use the official extras, or write your own in just a few lines. Extras add speci
126
126
127
127
### Alternative Components
128
128
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:
130
130
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>
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>
132
132
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>
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>
|`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)|
13
13
|`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)|
|`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)|
16
16
|`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)|
17
17
|`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)|
18
18
|`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)|
21
21
|`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)|
22
22
|`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)|
24
24
|`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)|
25
25
|`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)|
26
26
@@ -47,12 +47,16 @@ A few extras require the [pagy/extras/shared](https://github.com/ddnexus/pagy/bl
47
47
48
48
A few helpers use javascript, and they are clearly recognizable by the `js` suffix:
49
49
50
-
-`pagy_*_nav_js`
51
-
-`pagy_*_compact_nav_js`
50
+
-`pagy*_nav_js`
51
+
-`pagy*_combo_nav_js`
52
52
-`pagy_items_selector_js`
53
53
54
54
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).
55
55
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.
0 commit comments