No commit activity in last 3 years
No release in over 3 years
Kaminari extension for logarithmic pagination
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
>= 0

Runtime

 Project Readme

Kaminari::Logarithmic

This plugin extends popular kaminari gem to provide functionality for distributing big number of pages logarithmically. Such approach originally was discussed here.

Installation

Add this line to your application's Gemfile:

gem 'kaminari-logarithmic'

And then execute:

$ bundle

Or install it yourself as:

$ gem install kaminari-logarithmic

Important

Currently you will not see any changes if you use default kaminari views. To make it work you should customize views.

  1. First you should generate partials in app/views/kaminari folder (skip if you did that earlier):

    rails g kaminari:views default

More details and options on kaminari documentation page. 2. Assuming you generated views in erb format find following lines in _paginator.erb partial:

```ruby
<% if page.left_outer? || page.right_outer? || page.inside_window? -%>
  <%= page_tag page %>
```
  1. Add special condition (or supply your custom logic) :
    page.logarithmic?
    

Example: ruby <% if page.logarithmic? || page.left_outer? || page.right_outer? || page.inside_window? -%> <%= page_tag page %>

Usage

Do all the pagination stuff in controller and model usually. In your view use special helper instead of paginate:

paginate_logarithmic @your_collection

By default even distribution strategy is used. You can specify strategy with strategy option:

paginate_logarithmic @users, strategy: :fixed_steps

Strategies

At the moment 2 strategies are available:

  1. :even.
  2. :fixed_steps

Even distribution strategy

TODO: description and image

Fixed steps strategy

The strategy is illustrated on the following image:

enter image description here

Contributing

  1. Fork it ( https://github.com/[my-github-username]/kaminari-logarithmic/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request