Skip to content

Commit

Permalink
docs fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Aug 23, 2018
1 parent 435e849 commit a8ad399
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -125,8 +125,8 @@ Besides the classic pagination `nav`, Pagy offers a few ready to use alternative
### Posts and Tutorials

- [Pagination with Pagy](https://www.imaginarycloud.com/blog/paginating-ruby-on-rails-apps-with-pagy) by Tiago Franco
- [Stateful Tabs Pagination](https://www.imaginarycloud.com/blog/how-to-paginate-ruby-on-rails-apps-with-pagy) by Chris Seelus
- [Quick guide for Sinatra and Sequel](https://medium.com/@vfreefly/how-to-use-pagy-with-sequel-and-sinatra-157dfec1c417) by Victor Afanasev
- [Stateful Tabs with Pagy](https://www.imaginarycloud.com/blog/how-to-paginate-ruby-on-rails-apps-with-pagy) by Chris Seelus
- [Quick guide for Pagy with Sinatra and Sequel](https://medium.com/@vfreefly/how-to-use-pagy-with-sequel-and-sinatra-157dfec1c417) by Victor Afanasev

## Please Star and Share!

Expand Down
2 changes: 1 addition & 1 deletion docs/extras/foundation.md
Expand Up @@ -35,7 +35,7 @@ This extra is composed of 4 files:

## Methods

This extra adds one nav helpers to the `Pagy::Frontend` module. You can customize it by overriding it directly in your own view helper.
This extra adds 3 nav helpers to the `Pagy::Frontend` module. You can customize it by overriding it directly in your own view helper.

### pagy_nav_foundation(pagy)

Expand Down
9 changes: 9 additions & 0 deletions docs/how-to.md
Expand Up @@ -267,6 +267,15 @@ subset = Product.offset(100).limit(315)

Assuming the `:items` default of `20`, you will get the pages with the right records you are expecting. The first page from record 101 to 120 of the main collection, and the last page from 401 to 415 of the main collection. Besides the `from` and `to` attribute readers will correctly return the numbers relative to the subset that you are paginating, i.e. from 1 to 20 for the first page and from 301 to 315 for the last page.

## Paginate non-ActiveRecord collections

The `pagy_get_vars` method works out of the box with `ActiveRecord` collections; for other collections (e.g. `mongoid`, etc.) you may need to override it in your controller, usually by simply removing the `:all` argument passed to `count`:

```ruby
#count = collection.count(:all)
count = collection.count
```

## Using the pagy_nav* helpers

These helpers take the Pagy object and returns the HTML string with the pagination links, which are wrapped in a `nav` tag and are ready to use in your view. For example:
Expand Down
4 changes: 2 additions & 2 deletions lib/config/pagy.rb
Expand Up @@ -41,11 +41,11 @@
# See https://ddnexus.github.io/pagy/extras/materialize
# require 'pagy/extras/materialize'

# Semantic: Nav helper for Semantic UI pagination
# Semantic: Nav, responsive and compact helpers for Semantic UI pagination
# See https://ddnexus.github.io/pagy/extras/semantic
# require 'pagy/extras/semantic'

# Breakoints var used by the responsive nav helpers
# Breakpoints var used by the responsive nav helpers
# See https://ddnexus.github.io/pagy/extras/navs#breakpoints
# Pagy::VARS[:breakpoints] = { 0 => [1,2,2,1], 350 => [2,3,3,2], 550 => [3,4,4,3] } # example of width/size pairs

Expand Down
1 change: 1 addition & 0 deletions lib/pagy/extras/bulma.rb
Expand Up @@ -6,6 +6,7 @@
class Pagy
module Frontend

# Pagination for Bulma: it returns the html with the series of links to the pages
def pagy_nav_bulma(pagy)
html, link, p_prev, p_next = +'', pagy_link_proc(pagy), pagy.prev, pagy.next

Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/foundation.rb
Expand Up @@ -6,7 +6,7 @@
class Pagy
module Frontend

# Pagination for foundation: it returns the html with the series of links to the pages
# Pagination for Foundation: it returns the html with the series of links to the pages
def pagy_nav_foundation(pagy)
html, link, p_prev, p_next = +'', pagy_link_proc(pagy), pagy.prev, pagy.next

Expand All @@ -23,7 +23,7 @@ def pagy_nav_foundation(pagy)
%(<nav class="pagy-nav-foundation" role="navigation" aria-label="Pagination"><ul class="pagination">#{html}</ul></nav>)
end

# Compact pagination for foundation: it returns the html with the series of links to the pages
# Compact pagination for Foundation: it returns the html with the series of links to the pages
# we use a numeric input tag to set the page and the Pagy.compact javascript to navigate
def pagy_nav_compact_foundation(pagy, id=caller(1,1)[0].hash)
html, link, p_prev, p_next, p_page, p_pages = +'', pagy_link_proc(pagy), pagy.prev, pagy.next, pagy.page, pagy.pages
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/extras/trim.rb
Expand Up @@ -5,7 +5,7 @@ class Pagy

module Frontend

# boolean used by the compact extra
# boolean used by the compact navs
TRIM = true

def pagy_trim_url(url, param_string)
Expand Down

0 comments on commit a8ad399

Please sign in to comment.