<commit_before>Meteor Paginate
===============

State of the art, out of the box Meteor pagination.
---------------------------------------------------
Live demo: [http://pages.meteor.com/](http://pages.meteor.com/)

Features
--------

+ **Incremental subscriptions**. Downloads only what's needed, not the entire collection at once. Suitable for large datasets.
+ **Local cache**. One page - one request. Saves and reuses data on subsequent visits to the same page.
+ **Neighbor prefetching**. After loading the current page, it prefetches the neighbors to ensure seamless transition.
+ **Request throttling**. Allows you to limit how often the page can be changed.
+ **Easy integration**. The package works out of the box. Pages changes are triggered by one session variable.
+ **Bootstrap 2/3-compatible navigation template**. The package itself borrows some CSS from Bootstrap 3 to ensure good looks without dependency, but can be re-styled easily.
+ **Failure resistance**. Accounts for multiple scenarios of failure.
+ **Built-in iron-router integration**. Easy binding to any other router.
+ **Trivial customization**. Items per page, sorting, filters and more adjustable on the fly! Just modify a setting and see the pagination redrawing.

Installation
------------
Meteorite:
`mrt add pages`

Basic usage
-----------
The following code should be executed in the common code (both on the server and the client).

Coffeescript:

`@Pages = Meteor.Paginate "collection-name"`
      
or Javascript:

`
this.Pages = Meteor.Paginate("collection-name");
`

and HTML:
```
<body>
    {{> paginateNav}}
    <div style="min-height:400px">
    {{> paginate}}
    </div>
    {{> paginateNav}}
</body>
```

Settings
--------
Settings can be passed as a second argument to `Meteor.Paginate()`. Almost all can be changed from the client-side, causing immediate redrawing. Settings can be changed in:
1. Common code, on declaration (client and server)
```
@Pages = Meteor.Paginate "collection-name",
    perPage: 20
    sort: 
        title: 1
    filters: 
        count: 
            $gt: 10
```
2. Client-side
```
Pages.set
    perPage: 10
    sort: title: -1
```

Available to the client:
+ **dataMargin (*Number*, default: 3)** - determines how many neighboring pages on each side should be prefetched for seamless transition after loading the current page.
+ **filters (*Object*, default = {})** - MongoDB find query object, eg. `{name: {$lt: 5}}`
+ **itemTemplate (*String*, default = "paginateItemDefault")** - name of the template to use for items. The default template simply lists all attributes of an item
+ **onReloadPage1 (*Boolean*, default = false)** - determines whether to navigate to page 1 after reloading caused by a change in settings (eg. new sorting order)
+ **paginationMargin (*Number*, default = 3)** - the number of neighboring pages to display on each side of the navigation panel
+ **perPage (*Number*, default = 10)** - number of items to display per page (can't be larger than server-imposed **pageSizeLimit**)
+ **route (*String*, default = "/page/")** - route prefix used for subsequent pages (eg. "/page/" gives "/page/1", "/page/2" etc.)
+ **router (*String or Boolean*, default = false)** - Three options:
   - *true* - a router is used but the routes are configured separately by the user
   - *false* - no router used
   - *"iron-router"* - *iron-router* is used and the routes are automatically set up by *pages*
+ **routerTemplate (*String*, default = "pages")** - a template used by *iron-router* to generate paging 
+ **sort (*Object*, defualt = {})** - MongoDB sort determining object, eg. {name: 1}

Unavailable to the client:
+ pageSizeLimit (*Number, default = 60*) - limits the maximum number of items displayed per page


Examples
--------

Currently there're just two examples. One demonstrates the most basic usage and the other shows how to easily integrate *pages* with iron-router. If you experience any problems, make sure all the dependencies are installed (using Meteorite).
Basic example:
```
meteor add coffeescript
mrt add pages
```
Iron-router:
```
meteor add coffeescript
mrt add pages
mrt add iron-router
mrt add bootstrap-3 (optional)
```<commit_msg>README update<commit_after>Meteor Paginate
===============

State of the art, out of the box Meteor pagination.
---------------------------------------------------
Live demo: [http://pages.meteor.com/](http://pages.meteor.com/)

Features
--------

+ **Incremental subscriptions**. Downloads only what's needed, not the entire collection at once. Suitable for large datasets.
+ **Local cache**. One page - one request. Saves and reuses data on subsequent visits to the same page.
+ **Neighbor prefetching**. After loading the current page, it prefetches the neighbors to ensure seamless transition.
+ **Request throttling**. Allows you to limit how often the page can be changed.
+ **Easy integration**. The package works out of the box. Pages changes are triggered by one session variable.
+ **Bootstrap 2/3-compatible navigation template**. The package itself borrows some CSS from Bootstrap 3 to ensure good looks without dependency, but can be re-styled easily.
+ **Failure resistance**. Accounts for multiple scenarios of failure.
+ **Built-in iron-router integration**. Easy binding to any other router.
+ **Trivial customization**. Items per page, sorting, filters and more adjustable on the fly! Just modify a setting and see the pagination redrawing.

Installation
------------
Meteorite:
`mrt add pages`

Basic usage
-----------
The following code should be executed in the common code (both on the server and the client).

Coffeescript:

`@Pages = Meteor.Paginate "collection-name"`
      
or Javascript:

`
this.Pages = Meteor.Paginate("collection-name");
`

and HTML:
```
<body>
    {{> paginateNav}}
    <div style="min-height:400px">
    {{> paginate}}
    </div>
    {{> paginateNav}}
</body>
```

Settings
--------
Settings can be passed as a second argument to `Meteor.Paginate()`. Almost all can be changed from the client-side, causing immediate redrawing. Settings can be changed in:
1. Common code, on declaration (client and server)
```
@Pages = Meteor.Paginate "collection-name",
    perPage: 20
    sort: 
        title: 1
    filters: 
        count: 
            $gt: 10
```
2. Client-side
```
Pages.set {
    perPage: 10
    sort: title: -1
}
```

Available to the client:
+ **dataMargin (*Number*, default: 3)** - determines how many neighboring pages on each side should be prefetched for seamless transition after loading the current page.
+ **filters (*Object*, default = {})** - MongoDB find query object, eg. `{name: {$lt: 5}}`
+ **itemTemplate (*String*, default = "paginateItemDefault")** - name of the template to use for items. The default template simply lists all attributes of an item
+ **onReloadPage1 (*Boolean*, default = false)** - determines whether to navigate to page 1 after reloading caused by a change in settings (eg. new sorting order)
+ **paginationMargin (*Number*, default = 3)** - the number of neighboring pages to display on each side of the navigation panel
+ **perPage (*Number*, default = 10)** - number of items to display per page (can't be larger than server-imposed **pageSizeLimit**)
+ **route (*String*, default = "/page/")** - route prefix used for subsequent pages (eg. "/page/" gives "/page/1", "/page/2" etc.)
+ **router (*String or Boolean*, default = false)** - Three options:
   - *true* - a router is used but the routes are configured separately by the user
   - *false* - no router used
   - *"iron-router"* - *iron-router* is used and the routes are automatically set up by *pages*
+ **routerTemplate (*String*, default = "pages")** - a template used by *iron-router* to generate paging 
+ **sort (*Object*, defualt = {})** - MongoDB sort determining object, eg. {name: 1}

Unavailable to the client:
+ pageSizeLimit (*Number, default = 60*) - limits the maximum number of items displayed per page


Examples
--------

Currently there're just two examples. One demonstrates the most basic usage and the other shows how to easily integrate *pages* with iron-router. If you experience any problems, make sure all the dependencies are installed (using Meteorite).
Basic example:
```
meteor add coffeescript
mrt add pages
```
Iron-router:
```
meteor add coffeescript
mrt add pages
mrt add iron-router
mrt add bootstrap-3 (optional)
```
{'fraction_non_alphanumeric': 0.13150875565348485, 'fraction_numerical': 0.0067261973791024, 'mean_word_length': 3.2799007444168735, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2511186', 'n_tokens_mistral': 2489, 'n_tokens_neox': 2344, 'n_words': 1051}