All Projects → ddnexus → Pagy

ddnexus / Pagy

Licence: mit
🏆 The Best Pagination Ruby Gem 🥇

Programming Languages

ruby
36898 projects - #4 most used programming language
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
Haml
164 projects
Slim
82 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to Pagy

Bootstrap Table
An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation, Vue.js)
Stars: ✭ 11,068 (+231.38%)
Mutual labels:  foundation, semantic-ui, bootstrap, bulma, materialize
Config
Easiest way to add multi-environment yaml settings to Rails, Sinatra, Pandrino and other Ruby projects.
Stars: ✭ 1,821 (-45.48%)
Mutual labels:  rails, sinatra, padrino
Rack Policy
Rack middleware for the EU ePrivacy Directive compliance in Ruby Web Apps
Stars: ✭ 149 (-95.54%)
Mutual labels:  rails, sinatra
Timber Ruby
🌲 Great Ruby logging made easy.
Stars: ✭ 154 (-95.39%)
Mutual labels:  rails, sinatra
Ruby2 Rails4 Bootstrap Heroku
A starter application based on Ruby 2.4, Rails 4.2 and Bootstrap for Sass 3, deployable on Heroku
Stars: ✭ 181 (-94.58%)
Mutual labels:  rails, bootstrap
Redis dashboard
Sinatra app to monitor Redis servers.
Stars: ✭ 141 (-95.78%)
Mutual labels:  rails, sinatra
Recaptcha
ReCaptcha helpers for ruby apps
Stars: ✭ 1,819 (-45.54%)
Mutual labels:  rails, sinatra
X Editable Rails
Edit fields easily with X-Editable helper
Stars: ✭ 159 (-95.24%)
Mutual labels:  rails, bootstrap
Daru View
daru-view is for easy and interactive plotting in web application & IRuby notebook. daru-view is a plugin gem to the existing daru gem.
Stars: ✭ 65 (-98.05%)
Mutual labels:  rails, sinatra
pagination
Aplus Framework Pagination Library
Stars: ✭ 167 (-95%)
Mutual labels:  bulma, semantic-ui
Rack Reducer
Declaratively filter data via URL params, in any Rack app, with any ORM.
Stars: ✭ 241 (-92.78%)
Mutual labels:  rails, sinatra
Pluck to hash
Extend ActiveRecord pluck to return array of hashes
Stars: ✭ 275 (-91.77%)
Mutual labels:  rails, sinatra
Bootstrap form
Official repository of the bootstrap_form gem, a Rails form builder that makes it super easy to create beautiful-looking forms using Bootstrap 5.
Stars: ✭ 1,532 (-54.13%)
Mutual labels:  rails, bootstrap
Instuigram
🎓 Learning Ruby on Rails through building the Instagram Application.
Stars: ✭ 88 (-97.37%)
Mutual labels:  rails, bootstrap
Tabler Rubygem
Rubygem for https://tabler.github.io
Stars: ✭ 77 (-97.69%)
Mutual labels:  rails, bootstrap
Draftsman
Ruby gem that lets you create draft versions of your database records.
Stars: ✭ 159 (-95.24%)
Mutual labels:  rails, sinatra
serverless-rack
Serverless plugin to deploy Ruby Rack applications (Sinatra/Rails/Padrino/Cuba etc.) and bundle gems
Stars: ✭ 58 (-98.26%)
Mutual labels:  sinatra, padrino
Simple Navigation
A ruby gem for creating navigations (with multiple levels) for your Rails, Sinatra or Padrino applications. Render your navigation as html list, link list or breadcrumbs.
Stars: ✭ 868 (-74.01%)
Mutual labels:  rails, sinatra
Redmine bootstrap kit
A Redmine plugin which makes developing your own Redmine plugin easy ;)
Stars: ✭ 36 (-98.92%)
Mutual labels:  rails, bootstrap
Bugsnag Ruby
Bugsnag error monitoring & reporting software for rails, sinatra, rack and ruby
Stars: ✭ 211 (-93.68%)
Mutual labels:  rails, sinatra

Pagy

Gem Version ruby Build Status CodeCov Rubocop Status MIT license CII Best Practices Commits Downloads Chat

🏆 The Best Pagination Ruby Gem 🥇

~ 40x Faster!

IPS Chart

~ 36x Lighter!

Memory Chart

~ 35x Simpler!

Objects Chart

~ 1,410x More Efficient!

Resource Consumption Chart

Each dot in the visualization above represents the resources that Pagy consumes for one full rendering. The other gems consume hundreds of times as much for the same rendering.

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

See the Detailed Gems Comparison for full details.

👍 If you like Pagy, give it a star!

Thank you for showing your support!

🤩 It does it all. Better.

Code Structure

  • Pagy has a very slim core code very easy to understand and use (see more...)
  • It has a quite fat set of optional extras that you can explicitly require for very efficient and modular customization (see extras)
  • It has no dependencies: it produces its own HTML, URLs, i18n with its own specialized and fast code (see why...)
  • Its methods are accessible and overridable right where you use them (no pesky monkey-patching needed)

Unlike the other gems

  • Pagy is very modular and does not load any unnecessary code in your app (see why...)
  • It doesn't impose limits on your code even with collections|scopes that already used limit and offset (see how...)
  • It works with fast helpers OR easy to edit templates (see more...)
  • It raises real Pagy::OverflowError exceptions that you can rescue from (see how...) or use the overflow extra for a few ready to use common behaviors
  • It does not impose any difficult-to-override logic or output (see why...)

Better Components

Besides the classic pagination offered by the pagy_nav helpers, you can also use a couple of more performant alternatives:

  • pagy_nav_js: A faster and lighter classic looking UI, rendered on the client side with optional responsiveness:
    bootstrap_nav_js

  • pagy_combo_nav_js: The fastest and lightest alternative UI (48x faster, 48x lighter and 2,270x more efficient than Kaminari) that combines navigation and pagination info in a single compact element:
    bootstrap_combo_nav_js

😎 It's easy to use and customize

Code for basic pagination...
# Optionally override some pagy default with your own in the pagy initializer
Pagy::DEFAULT[:items] = 10        # items per page
Pagy::DEFAULT[:size]  = [1,4,4,1] # nav bar links

# Include it in the controllers (e.g. application_controller.rb)
include Pagy::Backend

# Include it in the helpers (e.g. application_helper.rb)
include Pagy::Frontend

# Wrap your collections with pagy in your actions
@pagy, @records = pagy(Product.all)
<%# Render the navigation bar in your views %>
<%== pagy_nav(@pagy) %>

(See Quick Start)

Customization for CSS frameworks...
# Require a CSS framework extra in the pagy initializer (e.g. bootstrap)
require 'pagy/extras/bootstrap'
<%# Use it in your views %>
<%== pagy_bootstrap_nav(@pagy) %>

(See the bootstrap extra)

Customization for special collections...
# Require some special backend extra in the pagy initializer (e.g. elasticsearch_rails)
require 'pagy/extras/elasticsearch_rails'

# Extend your models (e.g. application_record.rb)
extend Pagy::ElasticsearchRails

# Use it in your actions
response         = Article.pagy_search(params[:q])
@pagy, @response = pagy_elasticsearch_rails(response)

(See the elasticsearch_rails extra)

Customization for client-side|JSON rendering...
# Require the metadata extra in the pagy initializer
require 'pagy/extras/metadata'

# Use it in your actions
pagy, records = pagy(Product.all)
render json: { data: records,
               pagy: pagy_metadata(pagy) }

(See the metadata extra)

Customization for headers pagination for APIs...
# Require the headers extra in the pagy initializer
require 'pagy/extras/headers'

# Use it in your actions
pagy, records = pagy(Product.all)
pagy_headers_merge(pagy)
render json: records

(See the headers extra)

More customization with extras...

Extras add special options and manage different components, behaviors, Frontend or Backend environments... usually by just requiring them (and optionally overriding some default).

Backend Extras

  • arel: Better performance of grouped ActiveRecord collections
  • array: Paginate arrays efficiently, avoiding expensive array-wrapping and without overriding
  • calendar: Add pagination filtering by calendar time unit (year, quarter, month, week, day)
  • countless: Paginate without the need of any count, saving one query per rendering
  • elasticsearch_rails: Paginate ElasticsearchRails response objects
  • headers: Add RFC-8288 compliant http response headers (and other helpers) useful for API pagination
  • meilisearch: Paginate Meilisearch results
  • metadata: Provides the pagination metadata to Javascript frameworks like Vue.js, react.js, etc.
  • searchkick: Paginate Searchkick::Results objects

Frontend Extras

Extra Features and Tools

  • Pagy::Console: Try any pagy feature or helper right in the irb/rails console even without any app or config
  • gearbox: Automatically change the number of items per page depending on the page number
  • i18n: Use the I18n gem instead of the pagy-i18n implementation
  • items: Allow the client to request a custom number of items per page with an optional selector UI
  • overflow: Allow for easy handling of overflowing pages
  • standalone: Use pagy without any request object, nor Rack environment/gem, nor any defined params method
  • support: Extra support for features like: incremental, auto-incremental and infinite pagination
  • trim: Remove the page=1 param from the first page link

See also the How To Page

🤓 It's very well documented and supported

Read the documentation...
Ask for support...
Watch some great screencast...

GoRails Screencast

GoRails Screencast

Notice: the pagy_nav_bootstrap helper used in the screencast has been renamed as pagy_bootstrap_nav since version 2.0

Mike Rogers Screencast

How To Paginate A Collection Using Pagy

SupeRails Screencast

Ruby on Rails #19 gem Pagy - Ultimate Guide

Raul Palacio Screencast (Spanish)

Raul Palacio Screncast

Posts and tutorials...

📦 Repository Info

What's new in 5.0
  • This version requires ruby 2.5+. For ruby <2.5 use pagy 3+ (see the pagy3 branch)
  • New: Added the calendar extra for pagination filtering by calendar time unit (year, quarter, month, week, day)
  • New: Added the gearbox extra to automatically change the number of items depending on the page number.
  • Removed support for 4.0 deprecations (see the Changelog)
  • Big code restyling with improved performance, readability and rubocop compliance.
How to contribute
  • Pull Requests are welcome!
  • For simple contribution you can quickly check your changes with the Pagy::Console or with the single file pagy_standalone_app.ru.
  • For more complex contributions you can use the docker development environment or your own environment of course.
  • If you Create A Pull Request, please ensure that the "All checks have passed" indicator gets green light on the Pull Request page. That means that the tests passed and Codecov and Rubocop are happy.
Versioning
Branches
  • The master branch is the latest rubygem-published release. It also contains docs and comment changes that don't affect the published code. It is never force-pushed.
  • The dev branch is the development branch with the new code that will be merged in the next release. It could be force-pushed.
  • Expect any other branch to be experimental, force-pushed, rebased and/or deleted even without merging.

💞 Related Projects

  • pagy-cursor An early stage project that implements cursor pagination for AR
  • grape-pagy Pagy pagination for the grape API framework

👏 Credits

Many thanks to:

📃 License

This project is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].