will_paginate-bootstrap4 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ac5bbc4bb333226f95df09a1278f91ffc7c9b00
4
- data.tar.gz: e82a7d2fa7771a4cea05869fad13844af6e47feb
3
+ metadata.gz: b4cfcdf415a80364c269a1c72bb194a819b718b4
4
+ data.tar.gz: b8e3e63142d886637d2e66434dd72c24d3ab6e22
5
5
  SHA512:
6
- metadata.gz: fd0ea7b04fcd7dc05f09be38f13ce9f98c1bfdf9fff5fed6a7ea48a4f1d9a029333113be30c80b6fd6aa684035992940a31b977617a40f11517f4304b3438c31
7
- data.tar.gz: 833bb96900205e7332c5019b18a88f84886f75891b7810040ac9999faf64553797788c5b40b55f180a58c195b6a78ffd858f1035737a0f6957e878b3407a62a2
6
+ metadata.gz: 06a14dc22ee4a81eecacbcc74417185babcb509dc67afbd53acdbd63d0260fe0b555a178b4cb6dac2b54dbdb05ce518268d3b358c39e8e209b610c6adee41361
7
+ data.tar.gz: 210db8b83ff03aef3be027f911b7c0cc06f57e2b6fa7b6a62a66a040e03162cdfd99bb3684e4289c126fe3b5f08e95d530bd55cbf214f29b65f8f7a49d1f4f43
data/README.md CHANGED
@@ -1,25 +1,32 @@
1
- ## [Will Paginate][wp] link renderer styles for [Twitter Bootstrap 4][bs]
2
-
3
- ![ex](https://cloud.githubusercontent.com/assets/2103263/18925649/74eeb836-85bd-11e6-9be1-593a076e684c.png)
4
-
5
- Rails Engine that extends [will_paginate][wp] stylings to match the pagination styling conventions
6
- in Twitter's [Bootstrap][bs] 4 toolkit.
7
-
8
- ### Installation
9
-
10
- Add to your Gemfile:
11
-
12
- gem 'will_paginate-bootstrap4'
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
-
22
- Copyright (c) 2016 [Ivan Palamarchuk](https://github.com/delef) released under the MIT license
23
-
24
- [wp]: http://github.com/mislav/will_paginate
25
- [bs]: http://v4-alpha.getbootstrap.com/
1
+ ## [Will Paginate][wp] link renderer styles for [Twitter Bootstrap 4][bs]
2
+
3
+ ![ex](https://cloud.githubusercontent.com/assets/2103263/18925649/74eeb836-85bd-11e6-9be1-593a076e684c.png)
4
+
5
+ Rails Engine that extends [will_paginate][wp] stylings to match the pagination styling conventions
6
+ in Twitter's [Bootstrap][bs] 4 toolkit.
7
+
8
+ ### Installation
9
+
10
+ Add to your Gemfile:
11
+
12
+ gem 'will_paginate-bootstrap4'
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
+ CSS:
22
+ .pagination {
23
+ margin-top: 10px;
24
+ align-items: center;
25
+ justify-content: center;
26
+ }
27
+
28
+
29
+ Copyright (c) 2016-2017 [Ivan Palamarchuk](https://github.com/delef) released under the MIT license
30
+
31
+ [wp]: http://github.com/mislav/will_paginate
32
+ [bs]: http://v4-alpha.getbootstrap.com/
@@ -1,79 +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] = '&laquo;'
12
- options[:next_label] = '&raquo;'
13
- options[:inner_window] = 2
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 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
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] = '&laquo;'
12
+ options[:next_label] = '&raquo;'
13
+ options[:inner_window] = 2
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 (1.class == Integer ? Integer : 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
@@ -1,5 +1,5 @@
1
- module Bootstrap
2
- module WillPaginate
3
- VERSION = '0.1.2'
4
- end
5
- end
1
+ module Bootstrap
2
+ module WillPaginate
3
+ VERSION = '0.1.3'
4
+ end
5
+ end
@@ -20,5 +20,5 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_paths = ['lib']
22
22
 
23
- s.add_runtime_dependency 'will_paginate', '~> 3.0', '>= 3.0.9'
23
+ s.add_runtime_dependency 'will_paginate', '~> 3.0', '>= 3.0.0'
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: will_paginate-bootstrap4
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Palamarchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-29 00:00:00.000000000 Z
11
+ date: 2017-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: will_paginate
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '3.0'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 3.0.9
22
+ version: 3.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '3.0'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 3.0.9
32
+ version: 3.0.0
33
33
  description: Hooks into will_paginate to format the html to match Twitter Bootstrap
34
34
  4 styling.
35
35
  email: i.delef@gmail.com
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  version: '0'
68
68
  requirements: []
69
69
  rubyforge_project: will_paginate-bootstrap4
70
- rubygems_version: 2.5.1
70
+ rubygems_version: 2.6.14
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: Format will_paginate html to match Twitter Bootstrap 4 styling.