openstreetmap-website

https://github.com/openstreetmap/openstreetmap-website

Ruby

The Rails application that powers OpenStreetMap

ActionView::Helpers::PaginationHelper#pagination_links

Creates a basic HTML link bar for the given +paginator+.  Links will be created
for the next and/or previous page and for a number of other pages around the current
pages position. The +html_options+ hash is passed to +link_to+ when the links are created.

==== Options
<tt>:name</tt>::                 the routing name for this paginator
                                 (defaults to +page+)
<tt>:prefix</tt>::               prefix for pagination links
                                 (i.e. Older Pages: 1 2 3 4)
<tt>:suffix</tt>::               suffix for pagination links
                                 (i.e. 1 2 3 4 <- Older Pages)
<tt>:window_size</tt>::          the number of pages to show around
                                 the current page (defaults to <tt>2</tt>)
<tt>:always_show_anchors</tt>::  whether or not the first and last
                                 pages should always be shown
                                 (defaults to +true+)
<tt>:link_to_current_page</tt>:: whether or not the current page
                                 should be linked to (defaults to
                                 +false+)
<tt>:params</tt>::               any additional routing parameters
                                 for page URLs

==== Examples
 # We'll assume we have a paginator setup in @person_pages...

 pagination_links(@person_pages)
 # => 1 <a href="/?page=2/">2</a> <a href="/?page=3/">3</a>  ... <a href="/?page=10/">10</a>

 pagination_links(@person_pages, :link_to_current_page => true)
 # => <a href="/?page=1/">1</a> <a href="/?page=2/">2</a> <a href="/?page=3/">3</a>  ... <a href="/?page=10/">10</a>

 pagination_links(@person_pages, :always_show_anchors => false)
 # => 1 <a href="/?page=2/">2</a> <a href="/?page=3/">3</a>

 pagination_links(@person_pages, :window_size => 1)
 # => 1 <a href="/?page=2/">2</a>  ... <a href="/?page=10/">10</a>

 pagination_links(@person_pages, :params => { :viewer => "flash" })
 # => 1 <a href="/?page=2&amp;viewer=flash/">2</a> <a href="/?page=3&amp;viewer=flash/">3</a>  ...
 #    <a href="/?page=10&amp;viewer=flash/">10</a>

Source | Google | Stack overflow

Edit

git clone [email protected]:openstreetmap/openstreetmap-website.git

cd openstreetmap-website

open lib/classic_pagination/pagination_helper.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-ActionView--Helpers--PaginationHelper-pagination_links-for-pr


# Commit to git

git add lib/classic_pagination/pagination_helper.rbgit commit -m "better docs for ActionView::Helpers::PaginationHelper#pagination_links"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-ActionView--Helpers--PaginationHelper-pagination_links-for-pr

hub pull-request


# Celebrate!