From fe6505862486500f34019d8aee08c522013d5bdf Mon Sep 17 00:00:00 2001 From: Diaspora Europe Date: Thu, 15 Mar 2012 12:26:47 +0100 Subject: [PATCH] use will paginate, added renderer for bootstrap --- Gemfile | 2 +- config/initializers/will_paginate.rb | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 2c60443ac..753f41d90 100644 --- a/Gemfile +++ b/Gemfile @@ -105,7 +105,7 @@ gem 'typhoeus' gem 'haml' gem 'mobile-fu' gem 'sass' -gem 'bootstrap-will_paginate' +gem 'will_paginate' gem 'client_side_validations' # web diff --git a/config/initializers/will_paginate.rb b/config/initializers/will_paginate.rb index b10133edc..69626fd72 100644 --- a/config/initializers/will_paginate.rb +++ b/config/initializers/will_paginate.rb @@ -8,5 +8,25 @@ module WillPaginate def will_paginate(collection = nil, options = { :renderer => WillPaginate::ActionView::LinkRenderer } ) super.try :html_safe end + + class BootstrapLinkRenderer < LinkRenderer + protected + + def html_container(html) + tag :div, tag(:ul, html), container_attributes + end + + def page_number(page) + tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page) + end + + def gap + tag :li, link(super, '#'), :class => 'disabled' + end + + def previous_or_next_page(page, text, classname) + tag :li, link(text, page || '#'), :class => [classname[0..3], classname, ('disabled' unless page)].join(' ') + end + end end end