diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 585174102..000000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -sudo: false -language: ruby -rvm: - - 2.3.3 - - 2.4.2 -before_install: gem install bundler -v 1.16.0 diff --git a/README.md b/README.md index 73f19409e..faac85137 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Pagy +[![Gem Version](https://badge.fury.io/rb/pagy.svg)](https://badge.fury.io/rb/pagy) + Pagy is the ultimate pagination gem that outperforms the others in each and every benchmark and comparison. ### Benchmarks @@ -44,7 +46,7 @@ _The [IPS/Kb ratio](http://ddnexus.github.io/pagination-comparison/gems.html#eff #### Totally agnostic - it doesn't need to know anything about your models, ORM or Storage, so it doesn't add any code to them -- it works with all kind of collections, even pre-paginated, records, Arrays, JSON data... and just whatever you can count +- it works with all kinds of collections, even pre-paginated, records, Arrays, JSON data... and just whatever you can count - it works with all Rack frameworks (Rails, Sinatra, Padrino, ecc.) out of the box - it works with any possible non-Rack envoronment by just overriding one or two one-liner methods diff --git a/docs/_config.yml b/docs/_config.yml index b2f24bd7a..fabb115cc 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,4 +1,3 @@ - title: Pagy description: The Ultimate Pagination Ruby Gem theme: jekyll-theme-minimal diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index f77d2f038..ea6f84450 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -14,43 +14,35 @@
+ + +
-

{{ site.title | default: site.github.repository_name }}

-

{{ site.description | default: site.github.project_tagline }}

-
-
+ + {% if site.github.is_project_page %} +

© 2018 Domizio DemichelisMIT License

+ {% endif %} -
- -
+
+

Basic Concepts

+

How To

+

API

+

Pagy

+

Pagy::Backend

+

Pagy::Frontend

+

Join the chat at https://gitter.im/ruby-pagy/Lobby

+
-
- Join the chat at https://gitter.im/ruby-pagy/Lobby -
+ -
- -
- {{ content }} -
- +
diff --git a/docs/api.md b/docs/api.md index f78d61bb5..b74ef732d 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,5 +1,7 @@ # API +[![Gem Version](https://badge.fury.io/rb/pagy.svg)](https://badge.fury.io/rb/pagy) + The whole code structure of pagy is very simple: it is organized around 3 small modules of just ~120 lines of code in total: | Module | Description | Links | diff --git a/docs/api/frontend.md b/docs/api/frontend.md index 5ccba1a7e..91f39949a 100644 --- a/docs/api/frontend.md +++ b/docs/api/frontend.md @@ -167,8 +167,8 @@ This method is similar to the `I18n.t` and its equivalent rails `t` helper. It i This method may be defined in 2 different ways: -- if `I18n` is defined: it is defined to use the standard `I18n.t` helper. _It's 5x slower but provides full I18n features_ -- if `I18n` is missing or the `Pagy::I18N[:gem]` variable (see below) is explicitly set to `false`: it is defined to use the pagy I18n-like implementation. _It's 5x faster but provides only pluralization/interpolation without translation, so it's only useful with single language apps_ +- if `I18n` is defined: it is defined to use the standard `I18n.t` helper. _It's 5x slower but provides full I18n features_. +- if `I18n` is missing or the `Pagy::I18N[:gem]` variable (see below) is explicitly set to `false`: it is defined to use the pagy I18n-like implementation. _It's 5x faster but provides only pluralization/interpolation without translation, so it's only useful with single language apps_. See also [Using I18n](/pagy/how-to#using-i18n). diff --git a/docs/assets/css/style.scss b/docs/assets/css/style.scss index 44707d0f5..92a3f1415 100644 --- a/docs/assets/css/style.scss +++ b/docs/assets/css/style.scss @@ -37,22 +37,36 @@ pre { background-color: #FFF; } -footer { - bottom: 0; +header { + div#site-header { + border-bottom: 1px solid #e5e5e5; + } + h1#site-title { + margin-bottom: .5rem; + } + p { + margin-bottom: .5rem; + } } #toc { - position: fixed; - top: 170px; - ul { - list-style-type: square; - padding-left: 20px; - line-height: 1.8rem; + margin: 2em 0; + p.indent1 { + margin-left: 2rem; + } + p#gitter-badge { + margin-top: 1.6em; } } -#gitter-badge { - position: fixed; - bottom: 20px; - left: 30px; +footer { + bottom: 0; +} + +@media print, screen and (max-width: 960px) { + + header { + padding-right: 0; + } + } diff --git a/docs/how-to.md b/docs/how-to.md index ca52394c8..b27f99ee4 100644 --- a/docs/how-to.md +++ b/docs/how-to.md @@ -101,7 +101,7 @@ You don't need to explicitly pass the usual `params[:page]` page number to the ` pagy(my_scope, page: 3) ``` -That will override the result of the `:page` variable, which default is `params[:page]`. +That will explicitly set the `:page` variable, overriding the `params[:page]` default. __Notice__: If you need to get the page number from another param or in some different way, just override the `pagy_get_vars` method right in your controller. @@ -228,7 +228,7 @@ You may want to read also the [Pagy::Frontend API documentation](/pagy/api/front ### Caching the collecion count -Every pagination gem needs the collection count in order to calculate all the rest. If you use a storage system like any SQL DB, there is no way to paginate and provide a full nav system without knowing the count, so the gem has to execute an extra query to get it. That is usually not a problem if your DB is well organized and maintained, but that may not be always the case. +Every pagination gem needs the collection count in order to calculate all the other variables involvd in the pagination. If you use a storage system like any SQL DB, there is no way to paginate and provide a full nav system without executing an extra query to get the collection count. That is usually not a problem if your DB is well organized and maintained, but that may not be always the case. Sometimes you may have to deal with some not very efficient legacy apps/DBs that you cannot totally control. In that case the extra count query may affect the performance of the app quite badly. @@ -288,11 +288,12 @@ You can do so by setting the `:item_path` variable to the path to lookup in the # or single pagy instance @pagy, @record = pagy(my_scope, item_path: 'activerecord.models.product' ) ``` + __Notice__: The variables passed to a pagy object have the precedence over the variables returned by the `pagy_get_vars`. The fastest way is passing a literal string to the `pagy` method, the most convenient way is using `pagy_get_vars`. ### Handling Pagy::OutOfRangeError exception -Pass a `:page` number out of range and pagy will raise a `Pagy::OutOfRangeError` exception, which you can rescue from and do what you think fits. You can rescue from the exception and render a not found page, or render a specific page number, or whatever. For example: +Pass an out of range `:page` number and pagy will raise a `Pagy::OutOfRangeError` exception, which you can rescue from and do what you think fits. You can rescue from the exception and render a not found page, or render a specific page number, or whatever. For example: ```ruby # in a controller