Project

leaflet

0.0
No commit activity in last 3 years
No release in over 3 years
A very robust, custom, light-weight paginator. Based on the leaf gem which is based on the will_paginate gem.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 0.0.1
 Project Readme

Build Status

Leaflet

A very robust light-weight paginator based on leaf which is based on will_paginate.

Design principles

  • Does not fiddle with Array, ActiveRecord, or anything else. It is self-contained.
  • Compatible with both will_paginate and kaminari API.
  • Never raise an exception! Negative pages will simple become positive, out of bounds simple means to the last page, etc...

Features

  • Convert an Array into a Collection
  • Create a partial Collection from any data subset (something like this)
  • Export as JSON for transferring the collection over an API

Installation

gem install leaflet

Examples

# Converting an Array into a paginatable Collection
complete_collection = Leaflet::Collection.new my_array
complete_collection.paginate(page: 5, per_page: 3)    # <-- Returns an Array with the paginated subset of the original Array

# Creating a custom Collection
my_array_subset = [:d, :e, :f]  # E.g. fetched from Redis according to page and per_page
collection = Leaflet::Collection.new my_array_subset, total: 26, page:2, per_page: 3

Credits

Leaflet is based on leaf (by Peter Hellberg) which is based on will_paginate by PJ Hyett, who later handed over development to Mislav Marohnić.