will_paginate-bootstrap4 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.md +23 -0
- data/Rakefile +1 -0
- data/config/initializers/will_paginate.rb +79 -0
- data/lib/will_paginate-bootstrap4.rb +9 -0
- data/lib/will_paginate-bootstrap4/version.rb +5 -0
- data/will_paginate-bootstrap4.gemspec +20 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a44065ff1466edd61b1643db17a0a00aa1942ab0
|
4
|
+
data.tar.gz: 78221261f5dde656580398a8ec66acdb6e48c1ec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1522e5df1b842622c0bf48156f480b44d66e48d9852607c64bb1aeb621a938f85a8572282ccd1b072c836af6d9f553e19f18eb0cc26e0fddda98a33cc5c1d8a0
|
7
|
+
data.tar.gz: 008c42d8e380af8607c4ba0ad4deec9f268ca753b19d108f0af926b54d70cd624bd49b657781e0819309fbf2c728e4848f77366ec675225e5aef059721107a55
|
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Nicholas Fine
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
## [Will Paginate][wp] link renderer styles for [Twitter Bootstrap 4][bs]
|
2
|
+
|
3
|
+
Rails Engine that extends [will_paginate][wp] stylings to match the pagination styling conventions
|
4
|
+
in Twitter's [Bootstrap][bs] 4 toolkit.
|
5
|
+
|
6
|
+
### Installation
|
7
|
+
|
8
|
+
Add to your Gemfile:
|
9
|
+
|
10
|
+
gem 'will_paginate-bootstrap4'
|
11
|
+
|
12
|
+
### Usage
|
13
|
+
|
14
|
+
Just like you would in the regular [will_paginate][wp]. If you've got a need to use the default will_paginate stylings,
|
15
|
+
pass an option like so:
|
16
|
+
|
17
|
+
<%= will_paginate @collection, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer %>
|
18
|
+
|
19
|
+
|
20
|
+
Copyright (c) 2016 [Ivan Palamarchuk](https://github.com/delef) released under the MIT license
|
21
|
+
|
22
|
+
[wp]: http://github.com/mislav/will_paginate
|
23
|
+
[bs]: http://v4-alpha.getbootstrap.com/
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'will_paginate/view_helpers/action_view'
|
2
|
+
|
3
|
+
module WillPaginate
|
4
|
+
module ActionView
|
5
|
+
def will_paginate(collection = nil, options = {})
|
6
|
+
options, collection = collection, nil if collection.is_a? Hash
|
7
|
+
collection ||= infer_collection_from_controller
|
8
|
+
|
9
|
+
options = options.symbolize_keys
|
10
|
+
options[:renderer] ||= BootstrapLinkRenderer
|
11
|
+
options[:previous_label] = '«'
|
12
|
+
options[:next_label] = '»'
|
13
|
+
options[:inner_window] = 2
|
14
|
+
|
15
|
+
super(collection, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
class BootstrapLinkRenderer < LinkRenderer
|
19
|
+
ELLIPSIS = '…'
|
20
|
+
|
21
|
+
def to_html
|
22
|
+
list_items = pagination.map do |item|
|
23
|
+
case item
|
24
|
+
when Fixnum
|
25
|
+
page_number(item)
|
26
|
+
else
|
27
|
+
send(item)
|
28
|
+
end
|
29
|
+
end.join(@options[:link_separator])
|
30
|
+
|
31
|
+
list_wrapper = tag :ul, list_items, class: 'pagination', role: 'group'
|
32
|
+
tag :nav, list_wrapper, class: @options[:class]
|
33
|
+
end
|
34
|
+
|
35
|
+
def container_attributes
|
36
|
+
super.except(*[:link_options])
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def page_number(page)
|
42
|
+
link_options = @options[:link_options] || {}
|
43
|
+
|
44
|
+
if page == current_page
|
45
|
+
tag :li, tag(:span, page, class: 'page-link'), class: 'page-item active'
|
46
|
+
else
|
47
|
+
link_options.merge! class: 'page-link', rel: rel_value(page)
|
48
|
+
tag :li, link(page, page, link_options), class: 'page-item'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def previous_or_next_page(page, text, classname)
|
53
|
+
link_options = @options[:link_options] || {}
|
54
|
+
|
55
|
+
if page
|
56
|
+
link_wrapper = link(text, page, link_options.merge(class: 'page-link'))
|
57
|
+
tag :li, link_wrapper, class: '%s page-item' % classname
|
58
|
+
else
|
59
|
+
span_wrapper = tag(:span, text, class: 'page-link')
|
60
|
+
tag :li, span_wrapper, class: '%s page-item disabled' % classname
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def gap
|
65
|
+
tag :li, tag(:i, ELLIPSIS, class: 'page-link'), class: 'page-item disabled'
|
66
|
+
end
|
67
|
+
|
68
|
+
def previous_page
|
69
|
+
num = @collection.current_page > 1 && @collection.current_page - 1
|
70
|
+
previous_or_next_page num, @options[:previous_label], 'previous'
|
71
|
+
end
|
72
|
+
|
73
|
+
def next_page
|
74
|
+
num = @collection.current_page < @collection.total_pages && @collection.current_page + 1
|
75
|
+
previous_or_next_page num, @options[:next_label], 'next'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'will_paginate-bootstrap4/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'will_paginate-bootstrap4'
|
7
|
+
s.version = Bootstrap::WillPaginate::VERSION
|
8
|
+
s.authors = ['Ivan Palamarchuk']
|
9
|
+
s.email = ['i.delef@gmail.com", "ikebowen@gmail.com']
|
10
|
+
s.summary = %q{Format will_paginate html to match Twitter Bootstrap 4 styling.}
|
11
|
+
s.description = %q{Hooks into will_paginate to format the html to match Twitter Bootstrap 4 styling.}
|
12
|
+
|
13
|
+
s.rubyforge_project = 'will_paginate-bootstrap4'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
s.add_runtime_dependency 'will_paginate'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: will_paginate-bootstrap4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ivan Palamarchuk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: will_paginate
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Hooks into will_paginate to format the html to match Twitter Bootstrap
|
28
|
+
4 styling.
|
29
|
+
email:
|
30
|
+
- i.delef@gmail.com", "ikebowen@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- Gemfile
|
37
|
+
- MIT-LICENSE
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- config/initializers/will_paginate.rb
|
41
|
+
- lib/will_paginate-bootstrap4.rb
|
42
|
+
- lib/will_paginate-bootstrap4/version.rb
|
43
|
+
- will_paginate-bootstrap4.gemspec
|
44
|
+
homepage:
|
45
|
+
licenses: []
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project: will_paginate-bootstrap4
|
63
|
+
rubygems_version: 2.5.1
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: Format will_paginate html to match Twitter Bootstrap 4 styling.
|
67
|
+
test_files: []
|