will_paginate-bootstrap 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .idea/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in will_paginate-bootstrap.gemspec
4
+ gemspec
data/README.markdown ADDED
@@ -0,0 +1,37 @@
1
+ # will_paginate-bootstrap
2
+
3
+ ![Bootstrap Pagination Component](//github.com/nickpad/will_paginate-bootstrap/raw/master/pagination.png)
4
+
5
+ This gem integrates the [Twitter Bootstrap](http://twitter.github.com/bootstrap/) [pagination component](http://twitter.github.com/bootstrap/components.html#pagination) with the [will_paginate](https://github.com/mislav/will_paginate) pagination gem.
6
+
7
+ As with will_paginate itself, Rails and Sinatra are supported.
8
+
9
+ ## Usage
10
+
11
+ ### Rails
12
+
13
+ 1. Load the Bootstrap CSS in your template.
14
+ 3. `require "will_paginate/bootstrap"` (`config/initializers/will_paginate.rb` would be a good place to put this).
15
+ 2. In your view, `<%= will_paginate @collection, :renderer => WillPaginate::Rails %>`
16
+ 3. Done!
17
+
18
+ ### Sinatra
19
+
20
+ TODO: Add instructions for Sinatra!
21
+
22
+ ## Compatibility
23
+
24
+ <table>
25
+ <tr>
26
+ <th>Ruby</th>
27
+ <td>>= 1.9.2</td>
28
+ </tr>
29
+ <tr>
30
+ <th>will_paginate</th>
31
+ <td>>= 3.0.3</td>
32
+ </tr>
33
+ <tr>
34
+ <th>Bootstrap</th>
35
+ <td>>= 2.0.0</td>
36
+ </tr>
37
+ </table>
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,9 @@
1
+ require "will_paginate/view_helpers/action_view"
2
+ require "bootstrap_pagination/link_renderer"
3
+
4
+ module BootstrapPagination
5
+ # A custom renderer class for WillPaginate that produces markup suitable for use with Twitter Bootstrap.
6
+ class Rails < WillPaginate::ActionView::LinkRenderer
7
+ include LinkRenderer
8
+ end
9
+ end
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ require "bootstrap_pagination/version"
4
+
5
+ module BootstrapPagination
6
+ # Contains functionality shared by all renderer classes.
7
+ module LinkRenderer
8
+ ELLIPSIS = '…'
9
+
10
+ def to_html
11
+ list_items = pagination.map do |item|
12
+ case item
13
+ when Fixnum
14
+ page_number(item)
15
+ else
16
+ send(item)
17
+ end
18
+ end
19
+
20
+ html_container(tag('ul', list_items.join(@options[:link_separator])))
21
+ end
22
+
23
+ protected
24
+
25
+ def page_number(page)
26
+ if page == current_page
27
+ tag('li', link(page, page), :class => 'active')
28
+ else
29
+ tag('li', link(page, page, :rel => rel_value(page)))
30
+ end
31
+ end
32
+
33
+ def gap
34
+ tag('li', link(ELLIPSIS, '#'), :class => 'disabled')
35
+ end
36
+
37
+ def previous_page
38
+ num = @collection.current_page > 1 && @collection.current_page - 1
39
+ previous_or_next_page(num, @options[:previous_label], 'prev')
40
+ end
41
+
42
+ def next_page
43
+ num = @collection.current_page < @collection.total_pages && @collection.current_page + 1
44
+ previous_or_next_page(num, @options[:next_label], 'next')
45
+ end
46
+
47
+ def previous_or_next_page(page, text, classname)
48
+ if page
49
+ tag('li', link(text, page), :class => classname)
50
+ else
51
+ tag('li', link(text, '#'), :class => "%s disabled" % classname)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,9 @@
1
+ require "will_paginate/view_helpers/action_view"
2
+ require "bootstrap_pagination/link_renderer"
3
+
4
+ module BootstrapPagination
5
+ # A custom renderer class for WillPaginate that produces markup suitable for use with Twitter Bootstrap.
6
+ class Sinatra < WillPaginate::Sinatra::LinkRenderer
7
+ include LinkRenderer
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module BootstrapPagination
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ if defined?(ActionView)
2
+ require "bootstrap_pagination/action_view"
3
+ end
4
+
5
+ if defined?(Sinatra)
6
+ require "bootstrap_pagination/sinatra"
7
+ end
data/pagination.png ADDED
Binary file
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "bootstrap_pagination/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "will_paginate-bootstrap"
7
+ s.version = BootstrapPagination::VERSION
8
+ s.authors = ["Nick Dainty"]
9
+ s.email = ["nick@npad.co.uk"]
10
+ s.homepage = "https://github.com/nickpad/will_paginate-bootstrap"
11
+ s.summary = %q{Integrates the Twitter Bootstrap pagination component with will_paginate}
12
+ s.description = %q{This gem integrates the Twitter Bootstrap pagination component with the will_paginate pagination gem. Supports Rails and Sinatra.}
13
+
14
+ s.rubyforge_project = "will_paginate-bootstrap"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency "will_paginate", ">= 3.0.3"
22
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: will_paginate-bootstrap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nick Dainty
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: will_paginate
16
+ requirement: &70134158075500 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70134158075500
25
+ description: This gem integrates the Twitter Bootstrap pagination component with the
26
+ will_paginate pagination gem. Supports Rails and Sinatra.
27
+ email:
28
+ - nick@npad.co.uk
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - README.markdown
36
+ - Rakefile
37
+ - lib/bootstrap_pagination/action_view.rb
38
+ - lib/bootstrap_pagination/link_renderer.rb
39
+ - lib/bootstrap_pagination/sinatra.rb
40
+ - lib/bootstrap_pagination/version.rb
41
+ - lib/will_paginate/bootstrap.rb
42
+ - pagination.png
43
+ - will_paginate-bootstrap.gemspec
44
+ homepage: https://github.com/nickpad/will_paginate-bootstrap
45
+ licenses: []
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project: will_paginate-bootstrap
64
+ rubygems_version: 1.8.11
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Integrates the Twitter Bootstrap pagination component with will_paginate
68
+ test_files: []