Skip to content

Commit

Permalink
minor docs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Mar 31, 2018
1 parent 0366669 commit e610b82
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 54 deletions.
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion 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
Expand Down Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion docs/_config.yml
@@ -1,4 +1,3 @@

title: Pagy
description: The Ultimate Pagination Ruby Gem
theme: jekyll-theme-minimal
Expand Down
50 changes: 21 additions & 29 deletions docs/_layouts/default.html
Expand Up @@ -14,43 +14,35 @@
</head>
<body>
<div class="wrapper">

<a href="https://github.com/ddnexus/pagy" class="github-corner" title="View source on Github" aria-label="View source on Github"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#828B94; color:#f7f7f7; position: fixed; top: 0; border: 0; right: 0; opacity:0.3" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>

<header>
<a href="{{ site.github.url }}"> <h1>{{ site.title | default: site.github.repository_name }}</h1> </a>
<p>{{ site.description | default: site.github.project_tagline }}</p>
<hr>
</header>
<div id="site-header">
<a href="{{ site.github.url }}"> <h1 id="site-title">{{ site.title | default: site.github.repository_name }}</h1> </a>
<p>{{ site.description | default: site.github.project_tagline }}</p>
</div>
{% if site.github.is_project_page %}
<p><small>&copy; 2018 <a href="{{ site.github.owner_url }}">Domizio Demichelis</a> &mdash; <a href="https://opensource.org/licenses/MIT">MIT License</a></small></p>
{% endif %}

<div id="github_corner">
<a href="https://github.com/ddnexus/pagy" class="github-corner" title="View source on Github" aria-label="View source on Github"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#828B94; color:#f7f7f7; position: fixed; top: 0; border: 0; left: 0; transform: scale(-1, 1);" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
</div>
<div id="toc">
<p><a href="/pagy/index">Basic Concepts</a></p>
<p><a href="/pagy/how-to">How To</a></p>
<p><a href="/pagy/api">API</a></p>
<p class="indent1"><a href="/pagy/api/pagy">Pagy</a></p>
<p class="indent1"><a href="/pagy/api/backend">Pagy::Backend</a></p>
<p class="indent1"><a href="/pagy/api/frontend">Pagy::Frontend</a></p>
<p id="gitter-badge"><a href="https://gitter.im/ruby-pagy/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge" rel="nofollow" target="_blank"><img src="https://camo.githubusercontent.com/1adf5e58915e2093fd2e856136ae26c99e2ae214/68747470733a2f2f6261646765732e6769747465722e696d2f727562792d706167792f4c6f6262792e737667" alt="Join the chat at https://gitter.im/ruby-pagy/Lobby" data-canonical-src="https://badges.gitter.im/ruby-pagy/Lobby.svg" style="max-width:100%;"></a></p>
</div>

<div id="gitter-badge">
<a href="https://gitter.im/ruby-pagy/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge" rel="nofollow" target="_blank"><img src="https://camo.githubusercontent.com/1adf5e58915e2093fd2e856136ae26c99e2ae214/68747470733a2f2f6261646765732e6769747465722e696d2f727562792d706167792f4c6f6262792e737667" alt="Join the chat at https://gitter.im/ruby-pagy/Lobby" data-canonical-src="https://badges.gitter.im/ruby-pagy/Lobby.svg" style="max-width:100%;"></a>
</div>
</header>

<div id="toc">
<ul>
<li><a href="/pagy/index">Basic Concepts</a></li>
<li><a href="/pagy/how-to">How To</a></li>
<li><a href="/pagy/api">API</a></li>
<ul>
<li><a href="/pagy/api/pagy">Pagy</a></li>
<li><a href="/pagy/api/backend">Pagy::Backend</a></li>
<li><a href="/pagy/api/frontend">Pagy::Frontend</a></li>
</ul>
</ul>
</div>

<section>

{{ content }}

</section>
<footer>
{% if site.github.is_project_page %}
<p><small>&copy; 2018 by <a href="{{ site.github.owner_url }}">{{ site.github.owner_name }}</a> &mdash; <a href="https://opensource.org/licenses/MIT">MIT License</a></small></p>
{% endif %}
</footer>

</div>
<script src="{{ '/assets/js/scale.fix.js' | relative_url }}"></script>

Expand Down
2 changes: 2 additions & 0 deletions 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 |
Expand Down
4 changes: 2 additions & 2 deletions docs/api/frontend.md
Expand Up @@ -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).

Expand Down
38 changes: 26 additions & 12 deletions docs/assets/css/style.scss
Expand Up @@ -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;
}

}
7 changes: 4 additions & 3 deletions docs/how-to.md
Expand Up @@ -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.

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e610b82

Please sign in to comment.