will_paginate-materialize 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.mod +3 -0
- data/README.md +26 -15
- data/lib/materialize_pagination/materialize_renderer.rb +16 -7
- data/lib/materialize_pagination/version.rb +1 -1
- data/lib/will_paginate/materialize.rb +42 -0
- data/will_paginate-materialize.gemspec +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3f59ca8d9a01f2b8fc3fce26e88e0c6d297a51b
|
4
|
+
data.tar.gz: 3fbec2a23ef76f792ba6e0af7bf7d9ceb000ff64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae36ab57fb1004e95e1378d66f1fd06578dccc1659fa343ebb22ddea1902e896e3dc531a3438a61869a2caaed935c72c3e837a5d435c3d5605f69ebe2de22d47
|
7
|
+
data.tar.gz: 4d0da25986148d96dee9a6fe9cfef2e5b10252259c807eb7a201c4db42bd81e00f309b6b68a203fbabe5fb0235dfc09170fb7827afd90e373a659e5831afd9ed
|
data/CHANGELOG.mod
CHANGED
data/README.md
CHANGED
@@ -7,37 +7,48 @@ This gem integrates the [MaterializeCSS](https://github.com/Dogfalo/materialize)
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem 'will_paginate-materialize'
|
10
|
+
gem 'will_paginate-materialize', git: 'https://github.com/mldoscar/will_paginate-materialize', branch: 'master'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
14
14
|
|
15
15
|
$ bundle
|
16
16
|
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install will_paginate-materialize
|
20
|
-
|
21
17
|
## Usage
|
22
18
|
|
23
19
|
1. Install [Materialize-sass](https://github.com/mkhairi/materialize-sass) (if you haven't already)
|
24
|
-
2.
|
25
|
-
|
26
|
-
.
|
27
|
-
|
28
|
-
|
20
|
+
2. Create a file named `will-paginate-materialize.rb` inside `config/initializers` and configure the iconset you want to use.
|
21
|
+
```ruby
|
22
|
+
WillPaginate::Materialize.configure do |config|
|
23
|
+
# Select one of the iconset you want to use
|
24
|
+
# Material Design Icons
|
25
|
+
config.iconset = :material_design
|
26
|
+
# FontAwesome Icons
|
27
|
+
config.iconset = :font_awesome
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
3. Add the following to your application.scss file
|
32
|
+
```css
|
33
|
+
.pagination li.active a {
|
34
|
+
color: #fff;
|
35
|
+
}
|
36
|
+
```
|
37
|
+
4. **For Material Design iconset use:** Follow the instructions for installing this gem in order to have this icon style in the left or right arrows: https://github.com/Angelmmiguel/material_icons
|
38
|
+
|
39
|
+
5. **For FontAwesome iconset use:** Follow the instructions for installing this gem in order to have this icon style in the left or right arrows: https://github.com/bokmann/font-awesome-rails
|
40
|
+
|
41
|
+
You're done! Use the will_paginate helper as you would otherwise.
|
42
|
+
```ruby
|
43
|
+
<%= will_paginate @collection %>
|
29
44
|
```
|
30
|
-
3. You're done! Use the will_paginate helper as you would otherwise.
|
31
|
-
```ruby
|
32
|
-
<%= will_paginate @collection %>
|
33
|
-
```
|
34
45
|
|
35
46
|
## Contributing
|
36
47
|
|
37
48
|
Bug reports and pull requests are welcome on GitHub at https://github.com/patricklindsay/will_paginate-materialize. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
38
49
|
|
39
50
|
### Further works
|
40
|
-
* Add specs
|
51
|
+
* Add additional specs
|
41
52
|
|
42
53
|
## License
|
43
54
|
|
@@ -11,10 +11,8 @@ module MaterializePagination
|
|
11
11
|
|
12
12
|
# @return [String] rendered pagination link
|
13
13
|
def page_number(page)
|
14
|
-
classes =
|
15
|
-
|
16
|
-
list_item = tag :li, page, :class => classes
|
17
|
-
link(list_item, page, :rel => rel_value(page))
|
14
|
+
classes = page == current_page ? 'active' : 'waves-effect'
|
15
|
+
tag :li, link(page, page, :rel => rel_value(page)), :class => classes
|
18
16
|
end
|
19
17
|
|
20
18
|
# @return [String] rendered gap between pagination links
|
@@ -24,10 +22,21 @@ module MaterializePagination
|
|
24
22
|
|
25
23
|
# @return [String] rendered previous and next arrow links
|
26
24
|
def previous_or_next_page(page, text, classname)
|
27
|
-
classes = [(classname if @options[:page_links]), ('
|
28
|
-
|
25
|
+
classes = [(classname if @options[:page_links]), (page ? 'waves-effect' : 'disabled')].join(' ')
|
26
|
+
direction = classname == 'previous_page' ? :left : :right
|
27
|
+
|
28
|
+
# Evaluate iconset selection and set the proper content for the link
|
29
|
+
case WillPaginate::Materialize.configuration.iconset
|
30
|
+
when :material_design
|
31
|
+
link_structure = "<i class='material-icons'>chevron_#{direction}</i>"
|
32
|
+
when :font_awesome
|
33
|
+
link_structure = "<i class='fas fa-chevron-#{direction}'></i>"
|
34
|
+
else
|
35
|
+
link_structure = ""
|
36
|
+
raise 'Iconset not found'
|
37
|
+
end
|
29
38
|
|
30
|
-
tag :li, link(
|
39
|
+
tag :li, link(link_structure.html_safe, page || '#!'), class: classes
|
31
40
|
end
|
32
41
|
end
|
33
42
|
end
|
@@ -2,3 +2,45 @@ require 'will_paginate'
|
|
2
2
|
|
3
3
|
require "materialize_pagination/action_view" if defined?(ActionView)
|
4
4
|
require 'materialize_pagination/railtie' if defined?(Rails)
|
5
|
+
|
6
|
+
module WillPaginate::Materialize
|
7
|
+
class Configuration
|
8
|
+
def initialize
|
9
|
+
@iconset = :material_design
|
10
|
+
end
|
11
|
+
|
12
|
+
def valid_iconsets
|
13
|
+
[
|
14
|
+
:material_design, :font_awesome
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
def iconset
|
19
|
+
@iconset
|
20
|
+
end
|
21
|
+
|
22
|
+
def iconset=(value)
|
23
|
+
if self.valid_iconsets.include? value.to_sym
|
24
|
+
@iconset = value.to_sym
|
25
|
+
else
|
26
|
+
raise "Iconset not valid. Valid options are: #{self.valid_iconsets.to_s}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class << self
|
32
|
+
attr_accessor :configuration
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.configuration
|
36
|
+
@configuration ||= Configuration.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.reset
|
40
|
+
@configuration = Configuration.new
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.configure
|
44
|
+
yield(configuration)
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: will_paginate-materialize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Lindsay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.
|
61
|
+
version: 3.1.6
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.
|
68
|
+
version: 3.1.6
|
69
69
|
description: This gem integrates the MaterializeCSS pagination component with the
|
70
70
|
will_paginate pagination gem.
|
71
71
|
email:
|
@@ -112,9 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.6.11
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: MaterializeCSS pagination renderer for the will_paginate pagination gem.
|
119
119
|
test_files: []
|
120
|
-
has_rdoc:
|