will_paginate_bootstrp 0.2.7 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d77b811a2039238534164bb4765a8011e0e225a72fae600da86632deaa2ff6f1
4
- data.tar.gz: df1dd89a5d9b898f15d7bd64817ebf8541bbc342cc429e53692612befbe4065b
3
+ metadata.gz: 92a91975867d22d43c9eaa95a3f335ada735bffa06e5ef2f58a3682b03c271fb
4
+ data.tar.gz: 03ed72070dee6d67eec0b0e464e5e1a1865f734233feb2ec862e16799183e7d4
5
5
  SHA512:
6
- metadata.gz: 34fe16529da58661a9a06d8318259246c0515039d4e7da9925ed42c1781365bd2211da938cbef84327bad786b5054ddd9248ef8e395b7e3822266a213353612e
7
- data.tar.gz: 33a689d9131c877ad9397500d061e31dfaa0d18ec485a766105e38220d15ded2f7bc8eb7fab0675b39118abc108b7b9a952c92b368417839d19f9be43aa7a66e
6
+ metadata.gz: a6621f5a8d054778a8ba7487e43267b8bbe82c77218328df50dd13f2e6b0b490ef35c7055358306fc84ffebeb8e71c4e2a0f8d23210649f231aa2c0aa4ce785c
7
+ data.tar.gz: 34d8b4e77eaf6668ac23995c899585f2f54b05a18d21b5d4b0b24a9cacabf504144401a1d4def050e43df2c03f89c22a62c4cd67aaa9d6df26e663d4d04483d8
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'will_paginate/view_helpers/action_view'
4
+ require 'will_paginate_bootstrp/renderer'
5
+
6
+ module WillPaginate
7
+ module ActionView
8
+ def will_paginate(collection = nil, options = {})
9
+ options, collection = collection, nil if collection.is_a? Hash
10
+ collection ||= infer_collection_from_controller
11
+
12
+ options = options.symbolize_keys
13
+ options[:renderer] ||= WillPaginateBootstrp::Renderer
14
+ options[:list_classes] ||= ['pagination']
15
+ options[:previous_label] ||= WillPaginateBootstrp::Renderer::PREVIOUS_LABEL
16
+ options[:next_label] ||= WillPaginateBootstrp::Renderer::NEXT_LABEL
17
+
18
+ super(collection, options)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'will_paginate/view_helpers/action_view'
4
+
5
+ module WillPaginateBootstrp
6
+ class Renderer < ::WillPaginate::ActionView::LinkRenderer
7
+ ELLIPSIS = "&hellip;" # hellip means horizontal ellipsis and is used to denote … (i.e. three dots)
8
+ NEXT_LABEL = "&rarr;" # →
9
+ PREVIOUS_LABEL = "&larr;" # ←
10
+
11
+ def to_html
12
+ html = pagination.map do |item|
13
+ item.is_a?(Integer) ?
14
+ page_number(item) :
15
+ send(item)
16
+ end.join(@options[:link_separator])
17
+
18
+ tag(:nav, tag(:ul, html, class: @options[:list_classes].join(' ')))
19
+ end
20
+
21
+ def container_attributes
22
+ super.except(*[:link_options])
23
+ end
24
+
25
+ protected
26
+
27
+ def page_number(page)
28
+ if page == current_page
29
+ tag(:li, tag(:span, page, class: 'page-link'), class: 'page-item active')
30
+ else
31
+ tag(:li, link(page, page, link_options.merge(class: 'page-link', rel: rel_value(page))), class: 'page-item')
32
+ end
33
+ end
34
+
35
+ def previous_or_next_page(page, text, classname)
36
+ if page
37
+ tag(:li, link(text, page, link_options.merge(class: classname)), class: 'page-item')
38
+ else
39
+ tag(:li, tag(:span, text, class: classname), class: 'page-item disabled')
40
+ end
41
+ end
42
+
43
+ def gap
44
+ tag(:li, tag(:i, ELLIPSIS, class: 'page-link'), class: 'page-item disabled')
45
+ end
46
+
47
+ def previous_page
48
+ num = @collection.current_page > 1 && @collection.current_page - 1
49
+ previous_or_next_page(num, @options[:previous_label], 'page-link')
50
+ end
51
+
52
+ def next_page
53
+ num = @collection.current_page < @collection.total_pages && @collection.current_page + 1
54
+ previous_or_next_page(num, @options[:next_label], 'page-link')
55
+ end
56
+
57
+ def link_options
58
+ @options[:link_options] || {}
59
+ end
60
+ end
61
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WillPaginateBootstrp
4
- VERSION = '0.2.7'
4
+ VERSION = '0.2.9'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: will_paginate_bootstrp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergii Demianchuk
@@ -24,14 +24,16 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.3.1
27
- description: " Gem will_paginate_bootstrp integrates the Twitter Bootstrap pagination
28
- component with the Gem will_paginate\n"
27
+ description: will_paginate_bootstrp provides Twitter Bootstrap pagination like design
28
+ on top of will_paginate gem
29
29
  email: sergeydemjanchyk@gmail.com
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - config/initializers/will_paginate.rb
34
35
  - lib/will_paginate_bootstrp.rb
36
+ - lib/will_paginate_bootstrp/renderer.rb
35
37
  - lib/will_paginate_bootstrp/version.rb
36
38
  homepage: https://github.com/systemu-net/will_paginate_bootstrp
37
39
  licenses:
@@ -55,5 +57,5 @@ requirements: []
55
57
  rubygems_version: 3.0.3
56
58
  signing_key:
57
59
  specification_version: 4
58
- summary: Integrates the Twitter Bootstrap pagination component with will_paginate
60
+ summary: Integrates Twitter Bootstrap pagination component with will_paginate gem
59
61
  test_files: []