will_paginate-bootstrap-style 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0f525156733915a395e9c9ad887c8210b66701013e5c4dd8c9dbb8cf069d6767
4
+ data.tar.gz: 659821a94320ee8e0be665213a842234025a677af1d2b8259613d4025dd9a3a1
5
+ SHA512:
6
+ metadata.gz: 499deb19337f89b7ea7aca3ff5ec5648fe028bf281e2033b0044567d70b17a2330415b6c55b4c9421e674075d3c43dc57069b3edb403e2eac63c07062c7cb2e3
7
+ data.tar.gz: 82f1249e2c8cc2f59e02d9413d49f649db760ec0034a644bb1f8587e2bd38a4be5cca8e3f276ae8b24552a5be11f9a744d5c144e41c1acd91c02e0f3d0e8ef6e
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *.swp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in bootstrap-will_paginate.gemspec
4
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,19 @@
1
+
2
+ Copyright (c) 2016 Ivan Palamarchuk
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ this software and associated documentation files (the "Software"), to deal in
6
+ the Software without restriction, including without limitation the rights to
7
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
+ the Software, and to permit persons to whom the Software is furnished to do so,
9
+ subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ ## [Will Paginate][wp] link renderer styles for [Twitter Bootstrap 4][bs4] and [Twitter Bootstrap 5][bs]
2
+
3
+ ![ex](https://user-images.githubusercontent.com/2103263/117255171-01761800-ae52-11eb-9950-cf9e22772325.png)
4
+
5
+ Rails Engine that extends [will_paginate][wp] stylings to match the pagination styling conventions
6
+ in Twitter's [Bootstrap][bs] toolkit.
7
+
8
+ ### Installation
9
+
10
+ Add to your Gemfile:
11
+
12
+ gem 'will_paginate-bootstrap-style'
13
+
14
+ ### Usage
15
+
16
+ Just like you would in the regular [will_paginate][wp]. If you've got a need to use the default will_paginate stylings,
17
+ pass an option like so:
18
+
19
+ <%= will_paginate @collection, renderer: WillPaginate::ActionView::BootstrapLinkRenderer %>
20
+
21
+ The following options are available (in addition to the options available in will_paginate):
22
+
23
+ :list_classes = ['pagination'] # Array of classes
24
+ :aria_label = 'Page Navigation' # The aria label to use in the Nav tag
25
+ :previous_label = '&laquo;' # Previous page label
26
+ :next_label = '&raquo;' # Next page label
27
+
28
+ For example, to place the navigation section to the far right of the page, use this in your view:
29
+
30
+ <%= will_paginate @clients, list_classes: %w(pagination justify-content-end) %>
31
+
32
+ [wp]: http://github.com/mislav/will_paginate
33
+ [bs]: http://getbootstrap.com/
34
+ [bs4]: http://getbootstrap.com/docs/4.0/
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[:list_classes] ||= ['pagination']
12
+ options[:previous_label] ||= '&larr;'
13
+ options[:next_label] ||= '&rarr;'
14
+
15
+ super(collection, options)
16
+ end
17
+
18
+ class BootstrapLinkRenderer < LinkRenderer
19
+ ELLIPSIS = '&hellip;'
20
+
21
+ def to_html
22
+ list_items = pagination.map do |item|
23
+ case item
24
+ when Integer
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: @options[:list_classes].join(' ').to_s
32
+ tag :nav, list_wrapper
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: 'page-item'
58
+ else
59
+ span_wrapper = tag(:span, text, class: 'page-link')
60
+ tag :li, span_wrapper, class: 'page-item disabled'
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,5 @@
1
+ module Bootstrap
2
+ module WillPaginate
3
+ VERSION = '0.2.4'
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ require 'will_paginate-bootstrap-style/version'
2
+ require 'will_paginate'
3
+
4
+ module Bootstrap
5
+ module WillPaginate
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'will_paginate-bootstrap-style/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'will_paginate-bootstrap-style'
7
+ s.version = Bootstrap::WillPaginate::VERSION
8
+ s.authors = ['Ivan Palamarchuk']
9
+ s.email = 'i.delef@gmail.com'
10
+ s.summary = %q{Format will_paginate html to match Twitter Bootstrap styling.}
11
+ s.description = %q{Hooks into will_paginate to format the html to match Twitter Bootstrap styling.}
12
+ s.homepage = 'https://github.com/delef/will_paginate-bootstrap-style'
13
+ s.license = 'MIT'
14
+
15
+ s.required_ruby_version = '>= 1.9.2'
16
+ s.rubyforge_project = 'will_paginate-bootstrap-style'
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ['lib']
22
+
23
+ s.add_runtime_dependency 'will_paginate', '~> 3.0', '>= 3.0.0'
24
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: will_paginate-bootstrap-style
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.4
5
+ platform: ruby
6
+ authors:
7
+ - Ivan Palamarchuk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-08-29 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: '3.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
+ description: Hooks into will_paginate to format the html to match Twitter Bootstrap
34
+ styling.
35
+ email: i.delef@gmail.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - ".gitignore"
41
+ - Gemfile
42
+ - LICENSE.md
43
+ - README.md
44
+ - Rakefile
45
+ - config/initializers/will_paginate.rb
46
+ - lib/will_paginate-bootstrap-style.rb
47
+ - lib/will_paginate-bootstrap-style/version.rb
48
+ - will_paginate_bootstrap.gemspec
49
+ homepage: https://github.com/delef/will_paginate-bootstrap-style
50
+ licenses:
51
+ - MIT
52
+ metadata: {}
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.9.2
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubygems_version: 3.2.22
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: Format will_paginate html to match Twitter Bootstrap styling.
72
+ test_files: []