{"id":20496415,"url":"https://github.com/hardpixel/smart-pagination","last_synced_at":"2025-08-19T04:43:06.531Z","repository":{"id":56896209,"uuid":"92960207","full_name":"hardpixel/smart-pagination","owner":"hardpixel","description":"View helpers for SmartPaginate, an extension for Active Record and Ruby Arrays.","archived":false,"fork":false,"pushed_at":"2022-05-14T18:51:07.000Z","size":30,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T11:40:00.958Z","etag":null,"topics":["actionview","activerecord","pagination","rails","ruby-gem"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hardpixel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-31T15:22:38.000Z","updated_at":"2022-05-14T18:51:08.000Z","dependencies_parsed_at":"2022-08-21T01:50:37.403Z","dependency_job_id":null,"html_url":"https://github.com/hardpixel/smart-pagination","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardpixel%2Fsmart-pagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardpixel%2Fsmart-pagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardpixel%2Fsmart-pagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardpixel%2Fsmart-pagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hardpixel","download_url":"https://codeload.github.com/hardpixel/smart-pagination/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248758994,"owners_count":21157074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actionview","activerecord","pagination","rails","ruby-gem"],"created_at":"2024-11-15T18:07:04.017Z","updated_at":"2025-04-13T18:21:14.803Z","avatar_url":"https://github.com/hardpixel.png","language":"Ruby","readme":"# SmartPagination\n\nSmartPagination adds view helpers for SmartPaginate. A simple, smart and clean pagination extension for Active Record and plain Ruby Arrays:\n\n- **Simple:** Easy to use, with a simple interface. It just does pagination, nothing more.\n- **Smart:** Can navigate through the pages without having to do an expensive count query. SmartPaginate will actually fetch one record more than needed and use it to determine if there's a next page.\n- **Clean:** The code is as minimal as possible while still useful. SmartPaginate does not auto include itself or monkey patch any classes.\n\nFor more details you can check SmartPaginate at https://github.com/ppostma/smart_paginate.\n\n[![Gem Version](https://badge.fury.io/rb/smart_pagination.svg)](https://badge.fury.io/rb/smart_pagination)\n[![Build Status](https://travis-ci.org/hardpixel/smart-pagination.svg?branch=master)](https://travis-ci.org/hardpixel/smart-pagination)\n[![Code Climate](https://codeclimate.com/github/hardpixel/smart-pagination/badges/gpa.png)](https://codeclimate.com/github/hardpixel/smart-pagination)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'smart_pagination'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install smart_pagination\n\n## Usage\n\nTo enable pagination in an Active Record model, include the `SmartPagination` or `SmartPaginate` concern in your class:\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  include SmartPagination\nend\n```\n\nThen you can use the paginate scope to paginate results:\n\n```ruby\n@users = User.paginate(page: params[:page], per_page: params[:per_page])\n```\n\nAnd finally you can use the `smart_pagination_for` or `pagination_for` helper in your views to render the pagination links:\n\n```erb\n\u003c%= smart_pagination_for(@users) %\u003e\n```\n\nIf you want to render only previous and next links, you can use the `smart_pager_for` or `pager_for` helper in your views:\n\n```erb\n\u003c%= smart_pager_for(@users) %\u003e\n```\n\nIf you want to render the pagination information text (Displaying x of y Items), you can use the `smart_pagination_info_for` or `pagination_info_for` helper in your views:\n\n```erb\n\u003c%= smart_pagination_info_for(@users) %\u003e\n```\n\nThere are a number of options you can use to customize the pagination links. The default options are:\n\n```ruby\noptions = {\n  info_mode:      false,\n  pager_mode:     false,\n  auto_hide:      false,\n  item_class:     '',\n  previous_text:  '\u0026laquo;',\n  previous_class: 'previous',\n  next_text:      '\u0026raquo;',\n  next_class:     'next',\n  active_class:   'active',\n  disabled_class: 'disabled',\n  wrapper:        'ul',\n  wrapper_class:  'pagination',\n  item_wrapper:   'li',\n  inner_window:    2,\n  outer_window:    0\n}\n\nsmart_pagination_for(@users, options)\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/hardpixel/smart-pagination.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardpixel%2Fsmart-pagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhardpixel%2Fsmart-pagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardpixel%2Fsmart-pagination/lists"}