Sha256: c0881d0fdd269708510f9847673ef962bbef478e571809a47416d6e819276b95

Contents?: true

Size: 1.56 KB

Versions: 18

Compression:

Stored size: 1.56 KB

Contents

module Paginate
  module ViewHelpers
    # default options that can be overridden on the global level
    @@pagination_options = {
      :class          => 'pagination',
      :previous_label => '« Previous',
      :next_label     => 'Next »',
      :inner_window   => 4, # links around the current page
      :outer_window   => 1, # links around beginning and end
      :separator      => ' ', # single space is friendly to spiders and non-graphic browsers
      :param_name     => :page,
      :params         => {},
      :page_links     => true,
      :container      => true,
      :debug          => false
    }
    mattr_reader :pagination_options

    def paginate(collection, options={})
      #Collection => :current_page, :per_page, :total_entries, :total_pages
      opt = @@pagination_options
      opt.update(options)
      out=[]
      if opt[:debug]
        out.push("current_page:#{collection.current_page} / ")
        out.push("per_page:#{collection.per_page} / ")
        out.push("total_entries:#{collection.total_entries} / ")
        out.push("total_pages:#{collection.total_pages} <br />")
      end
      out.push("<div class=\"pagination_container\">") if opt[:container]
      out.push(link(opt[:previous_label], {:page=>collection.previous_page}.update(opt[:params]), {:class=>opt[:class]}) ) if collection.previous_page
      out.push(link(opt[:next_label], {:page=>collection.next_page}.update(opt[:params]), {:class=>opt[:class]}) ) if collection.next_page
      out.push("</div>") if opt[:container]
      return out.join(opt[:separator])
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
grippy-doozer-0.1.0 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
grippy-doozer-0.1.1 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
grippy-doozer-0.1.2 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
grippy-doozer-0.1.3 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
grippy-doozer-0.1.4 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
grippy-doozer-0.1.5 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
doozer-0.4.4 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
doozer-0.4.3 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
doozer-0.4.2 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
doozer-0.4.1 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
doozer-0.4.0 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
doozer-0.3.1 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
doozer-0.3.0 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
doozer-0.2.6 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
doozer-0.2.5 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
doozer-0.2.2 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
doozer-0.2.1 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb
doozer-0.2.0 lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb