Skip to content

Commit

Permalink
lighter README and a few docs improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Mar 18, 2019
1 parent f25b5f5 commit 7d71699
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 40 deletions.
38 changes: 8 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ _Each dot in the chart represents the resources that Pagy consumes for one full

_The [IPS/Kb ratio](http://ddnexus.github.io/pagination-comparison/gems.html#efficiency-ratio) is calculated out of speed (IPS) and Memory (Kb): it shows how well each gem uses each Kb of memory it allocates/consumes._

#### Disclaimer

Please, notice that benchmarking and profiling the pagination gems in a working app environment may be a quite a tricky task.

If you compare Pagy in your own app and don't notice much of a difference, your benchmarks are most likely not isolating the pagination code from the rest of your app.

Please check the [Benchmarks and Memory Profiles Source](http://github.com/ddnexus/pagination-comparison) for a working example about how to properly compare the gems. Feel free to ask [here](https://gitter.im/ruby-pagy/Lobby) if you need help.

## Features

### Straightforward Code
Expand All @@ -74,7 +66,7 @@ Please check the [Benchmarks and Memory Profiles Source](http://github.com/ddnex

- 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))_
- 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))_
- It works with helpers or templates _(see [more...](https://ddnexus.github.io/pagy/how-to#using-templates))_
- It works with fast helpers OR easy to edit templates _(see [more...](https://ddnexus.github.io/pagy/how-to#using-templates))_
- 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
- It does not impose any difficult-to-override logic or output _(see [why...](https://ddnexus.github.io/pagy/index#really-easy-to-customize))_
- It also works on legacy systems starting from ruby v1.9+ and jruby v1.7+
Expand Down Expand Up @@ -103,7 +95,7 @@ Or - if you prefer - render the navigation links with a template:

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

## Easy to extend
## Easy to customize

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:

Expand All @@ -129,7 +121,7 @@ Use the official extras, or write your own in just a few lines. Extras add speci
- [i18n](http://ddnexus.github.io/pagy/extras/i18n): Use the `I18n` gem instead of the pagy-i18n implementation
- [items](http://ddnexus.github.io/pagy/extras/items): Allow the client to request a custom number of items per page with an optional selector UI
- [overflow](http://ddnexus.github.io/pagy/extras/overflow): Allow for easy handling of overflowing pages
- [support](http://ddnexus.github.io/pagy/extras/support): Extra support for features like: incremental, infinite, auto-scroll pagination
- [support](http://ddnexus.github.io/pagy/extras/support): Extra support for features like: incremental, auto-incremental and infinite pagination
- [trim](http://ddnexus.github.io/pagy/extras/trim): Remove the `page=1` param from the first page link

### Alternative Components
Expand All @@ -138,7 +130,7 @@ Besides the classic pagination `nav`, Pagy offers a few ready to use alternative

- [compact nav](http://ddnexus.github.io/pagy/extras/plain#compact-navs): An alternative UI that combines the pagination feature with the navigation info in one compact element:<br>![pagy-compact](docs/assets/images/pagy-compact-w.png)

- [responsive nav](http://ddnexus.github.io/pagy/extras/plain#responsive-navs): On resize, the number of page links adapts in real-time to the available window or container width:<br>![pagy-responsive](docs/assets/images/pagy-responsive-w.png)
- [responsive nav](http://ddnexus.github.io/pagy/extras/plain#responsive-navs): A classic looking UI that fits the number of page links to the available width on the client-side:<br>![pagy-responsive](docs/assets/images/pagy-responsive-w.png)

## Resources

Expand Down Expand Up @@ -168,28 +160,13 @@ Besides the classic pagination `nav`, Pagy offers a few ready to use alternative

[Chat on Gitter](https://gitter.im/ruby-pagy/Lobby)


## Please Star and Share!

Pagy is young and needs to be known, and **you** can really help, even with just a click on the star, or sharing a tweet with friends and colleagues. A big thank you for your support!

## Help Wanted

Pagy is a fresh project and your help would be great. If you like it, you have a few options to contribute:

- Create an issue if anything should be improved/fixed
- Submit a pull request to improve Pagy
- Submit some cool extra
- Submit your translation if your language is missing from the [dictionary files](https://github.com/ddnexus/pagy/blob/master/lib/locales)
- Write a Tutorial or a "How To" topic

## Repository Info

### Versioning

Pagy follows the [Semantic Versioning 2.0.0](https://semver.org/). Please, check the [Changelog](https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md) for breaking changes introduced by mayor versions.

### Branching
### Branches

The `master` branch is the latest rubygem-published release. It also contains docs and comment changes that don't affect the published code.

Expand All @@ -201,11 +178,12 @@ Expect any other branch to be experimental, force-rebased and/or deleted even wi

Many thanks to:

- [Imaginary Cloud](https://www.imaginarycloud.com), for continually publishing high-interest articles and helping share Pagy through their fantastic blog
- [GoRails](https://gorails.com) for the great [Pagy Screencast](https://gorails.com/episodes/pagination-with-pagy-gem?autoplay=1) and their top notch [Rails Episodes](https://gorails.com/episodes)
- [Imaginary Cloud](https://www.imaginarycloud.com) for continually publishing high-interest articles and helping to share Pagy when it just started
- [JetBrains](http://www.jetbrains.com) for their free OpenSource license
- [The Contributors](https://github.com/ddnexus/pagy/graphs/contributors) for all the smart code and suggestions merged in the project
- [The Stargazers](https://github.com/ddnexus/pagy/stargazers) for showing their support

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
This project is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
6 changes: 3 additions & 3 deletions docs/extras/plain.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Other extras provide also the following framework-styled helpers:

### :breakpoints

The `:breakpoints` variable is a non-core variable used by the `responsive` navs: it allows you to control how the page links will get shown at different widths. It is a hash where the keys are integers representing the breakpoint widths in pixels and the values are the Pagy `:size` variables to be applied for that width.
The `:breakpoints` variable is a non-core variable used by the `responsive` navs. It allows you to control how the page links will get shown at different widths. It is a hash where the keys are integers representing the breakpoint widths in pixels and the values are the Pagy `:size` variables to be applied for that width.
For example:

```ruby
Expand All @@ -117,13 +117,13 @@ The container width can change as a continous range (normal behavior for a div)

##### Continous Width-ranges

For continous width-range containers you should ensure that the resulting navs can be contained in the breakpoint widths that you set. In other words if you create a size as `[20,20,20,20]`, is pretty obvious that it could not be contained in a `540` width, so assign reasonable sizes based on the available widths.
For continous width-range containers you should ensure that the resulting navs can be contained in the breakpoint widths that you set. In other words if you create a size as `[20,20,20,20]`, is pretty obvious that it could not be contained in a `540` width, so you should assign reasonable sizes based on the available widths.

##### Discrete Step Widths

If you use frameworks like bootstrap (but the same applies to many others) you can assign classes to your container that will snap to specific widths (e.g. `sm-md-lg`). In that case you should sync the quantity and widths of the pagy brakpoints to the quantity and internal container widths of the bootstrap classes.

**IMPORTANT**: The pagy breakpoint widths should not be the same bootstrap breakpoints widths, but the container internal available widths.
**IMPORTANT**: The pagy breakpoint widths should not be the same bootstrap breakpoints widths, but their container internal available widths.

For example: if you assign the following classes:

Expand Down
14 changes: 7 additions & 7 deletions docs/extras/support.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ end
<div id="content">
<table id="records_table">
<tr>
<th> Name
<th> Description
<th>Name</th>
<th>Description</th>
</tr>
<%= render partial: 'page_items' %>
</table>
Expand All @@ -60,8 +60,8 @@ end
```erb
<% @records.each do |record| %>
<tr>
<td> <%= record.name %> </td>
<td> <%= record.description %> </td>
<td><%= record.name %></td>
<td><%= record.description %></td>
</tr>
<% end %>
```
Expand All @@ -82,15 +82,15 @@ $('#next-link').html("<%= j(render 'next_link') %>");

Automatic incremental pagination (sometimes referred as infinite-scroll pagination) is a UI-less pagination that loads the next page at the end of the listing with an AJAX call.

A simple example about how to implement can use the same example for the [Incremental](#navlessincremental) above with just a couple of changes:
We can implement it by using the same [Incremental example](#navlessincremental) above with just a couple of changes:

Hide the link in `_next_link.html.slim` by adding a style tag:
1. Hide the link in `_next_link.html.erb` by adding a style attribute:

```erb
<%== pagy_next_link(@pagy, 'More...', 'id="next_link" style="display: none;"') %>
```

Then the following javascript would take care of clicking the link when the page get loaded/resized/scrolled , so to keep the page filled with results, one page at a time:
2. Add a javascript that will click the link when the listing-bottom appear in the viewport on load/resize/scroll. It will keep the page filled with results, one page at a time:

```js
var loadNextPage = function(){
Expand Down

0 comments on commit 7d71699

Please sign in to comment.