Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

support will_paginate

  • Loading branch information...
commit f1c57bcc663fca4b37af1f1c0ea734e6dfcbb302 1 parent faf1e43
Yi-Ting Cheng xdite authored
2  Gemfile
View
@@ -3,4 +3,4 @@ source 'http://rubygems.org'
# Specify your gem's dependencies in bootstrap-rails.gemspec
gemspec
-gem "simple_form", :require => "simple_form"
+gem 'will_paginate', '3.0.pre4'
8 README.md
View
@@ -99,6 +99,14 @@ write notice message in your action, will generate bootstrap style notice messag
# ….
redirect_to posts_path, :notice => "Create Success!"
end
+
+### Pagination
+
+Support `will_paginate`, `3.0.pre4`
+
+in `config/application.rb`
+
+ WillPaginate::ViewHelpers.pagination_options[:renderer] = 'BootstrapHelper::PaginateRenderer'
## Example
2  bootstrap_helper.gemspec
View
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.name = "bootstrap_helper"
gem.require_paths = ["lib"]
- gem.version = "1.4.0"
+ gem.version = "1.4.1"
gem.add_dependency "railties", "~> 3.0"
gem.add_dependency "thor", "~> 0.14"
2  lib/bootstrap_helper/engine.rb
View
@@ -1,10 +1,12 @@
require "bootstrap_helper/helper"
require "bootstrap_helper/breadcrumb"
+require "bootstrap_helper/paginate_renderer"
module BootstrapHelper
module Rails
class Engine < ::Rails::Engine
initializer "bootstrap_helper.view_helpers" do
ActionView::Base.send :include, BootstrapHelper::Helper
+
end
config.to_prepare do
23 lib/bootstrap_helper/paginate_renderer.rb
View
@@ -0,0 +1,23 @@
+require 'will_paginate/view_helpers/link_renderer'
+require 'will_paginate/view_helpers/action_view'
+module BootstrapHelper
+ class PaginateRenderer < WillPaginate::ViewHelpers::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 previous_or_next_page(page, text, classname)
+ tag :li, link(text, page || '#'), :class => [classname[0..3], classname, ('disabled' unless page)].join(' ')
+ end
+
+ def gap
+ tag :li, link(super, '#'), :class => 'disabled'
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.