Coder Social home page Coder Social logo

pagy's Introduction

Pagy

Gem Version Build Status

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

Benchmarks

The best way to quickly get an idea about Pagy is comparing it to the other well known gems.

The values shown in the charts below have been recorded while each gem was producing the exact same output: same environment conditions, same task, just different gems (see the Detailed Gems Comparison)

Faster

IPS Chart

Less Memory

Memory Chart

Simpler

Objects Chart

More Efficient

Efficiency Table

The IPS/Kb ratio is calculated out of speed (IPS) and Memory (Kb): it shows how well each gem uses any Kb of memory it allocates/consumes.

Features

Straightforward Code

  • Pagy is just ~100 lines of simple ruby, organized in 3 flat modules very easy to understand and use (see more...)
  • No dependencies: it produces its own HTML, URLs, pluralization and interpolation with its own specialized and fast code (see why...)
  • 100% of its methods are public API, accessible and overridable right where you use them (no need of monkey-patching)
  • 100% test coverage for core code and extras

Totally Agnostic

  • It doesn't need to know anything about your models, ORM or storage, so it doesn't add any code to them (see why...)
  • It works with all kinds of collections, even pre-paginated, records, Arrays, JSON data... and just whatever you can count (see how...)
  • It works with all Rack frameworks (Rails, Sinatra, Padrino, ecc.) out of the box (see more...)
  • It works with any possible non-Rack environment by just overriding one or two two-lines methods (see more...)

Unlike the other gems

  • It works with collections/scopes that already used limit and offset (see how...)
  • It works with helpers or templates (see more...)
  • It raises real Pagy::OutOfRangeError exceptions that you can rescue from (see how...)
  • It does not impose any difficult-to-override logic or output (see why...)

Easy to use

You can use Pagy in a quite familiar way:

Paginate your collection in some controller:

@pagy, @records = pagy(Product.some_scope)

Render the navigation links with a super-fast helper in some view:

<%== pagy_nav(@pagy) %>

Or - if you prefer - render the navigation links with a template:

<%== render 'pagy/nav', locals: {pagy: @pagy} %>

(see Quick Start)

Easy to extend

Use the official extras, or write your own in just a few lines.

Array Extra

Paginate arrays efficiently avoiding expensive array-wrapping and without any overriding. (see more...)

Bootstrap Extra

Nav helper and templates for Bootstrap pagination. (see more...)

Bulma Extra

Nav helper and templates for Bulma CSS framework pagination. (see more...)

Compact Extra

An alternative UI that combines the pagination feature with the navigation info in one compact element. (see more...)

pagy-compact

Items Extra

Allow the client to request a custom number of items per page with a ready to use selector UI. (see more...)

Responsive Extra

On resize, the number of page links will adapt in real-time to the available window or container width. (see more...)

pagy-responsive

Chat Support and Feedback

Chat on Gitter

Useful Links


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 collegues. Thank you!

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
  • Write a Tutorial or a "How To" topic
  • Submit some cool extra

Branches and Pull Requests

master is the latest rubygem-published release (plus changes that don't affect the actual gem behavior, e.g. doc, tests). You should use it as the base branch for pull requests, because it will not be force-rebased.

dev is the development branch that is kept rebased on top of master, so expect it to be force-rebased (i.e. do not use it as the base for your commits). Use dev as a preview for trying the new code that will be merged in the next release, but please, don't use it as the base branch for pull requests.

License

The gem is available as open source under the terms of the MIT License.

pagy's People

Contributors

ddnexus avatar grosser avatar bquorning avatar cseelus avatar enzinia avatar gamafranco avatar berniechiu avatar artinboghosian avatar espen avatar kevincolemaninc avatar mcary avatar sliminas avatar ya-s-u avatar msdundar avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.