simple-navigation-materialize 1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8eb4b960ceb7b3c765aff4897c39153c2367f5fc5e249929c74911684a78331c
4
+ data.tar.gz: 2bfdc8c87a68395fe516c863fc700853261199603395996b39d36bf21ea04941
5
+ SHA512:
6
+ metadata.gz: 73c050e6400ee44ea60cb5e7b7ec743bb09a1869041782377fae776db9a8a0c1e53405335a291aa4064464089e97937d79c055552324c1d6c14ccd1070898cf7
7
+ data.tar.gz: 80be5c747b81f3cac9ed98a674bc4a2d73111e75e1ab034f142af37089bd02e2a5f24089972870b7cdeb62ad33cc97b5f754401b62cc82a4c65e78f497f41c35
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .ruby-version
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ simple-navigation-bootstrap
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in simple-navigation-bootstrap.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Peter Fern
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # Simple Navigation for Bootstrap
2
+ This gem adds a renderer for [Simple Navigation](http://github.com/andi/simple-navigation) to output markup compatible
3
+ with [materialize](https://materializecss.com).
4
+
5
+ ## Getting Started
6
+ For Rails >= 3, simply add this gem to your `Gemfile`:
7
+ ```ruby
8
+ gem 'simple-navigation-materialize'
9
+ ```
10
+ and run
11
+ ```
12
+ bundle install
13
+ ```
14
+ Follow the [configuration instructions](https://github.com/andi/simple-navigation/wiki/Configuration) on the Simple Navigation wiki for initial configuration.
15
+
16
+ To use the Materialize renderer, specify it in your view:
17
+ ```ruby
18
+ render_navigation :renderer => :materialize
19
+ ```
20
+
21
+ See below for a more complete example.
22
+
23
+ ## Additional Functionality
24
+
25
+ ### Icons
26
+ In addition you may specify an `:icon` attribute on your navigation items, either as an array
27
+ or string, containing materialize [icon names](https://materializecss.com/icons.html), to add an icon to the item.
28
+
29
+ ### Dropdowns
30
+ If you wish to use dropdowns in your navbar, don't forget to set `expand_all: true` on your `render_navigation`.
31
+
32
+ ## Examples
33
+ To create a navigation menu, you might do something like this:
34
+ ```ruby
35
+ SimpleNavigation::Configuration.run do |navigation|
36
+ navigation.items do |primary|
37
+ primary.item :music, 'Music', musics_path
38
+ primary.item :dvds, 'Dvds', dvds_path, :split => true do |dvds|
39
+ dvds.item :action, 'Action', dvds_action_path
40
+ dvds.item :drama, 'Drama', dvds_drama_path
41
+ end
42
+ primary.item :books, 'Books', :icon => 'book' do |books|
43
+ books.item :fiction, 'Fiction', books_fiction_path
44
+ books.item :history, 'History', books_history_path
45
+ end
46
+ end
47
+ end
48
+ ```
49
+
50
+ ## Further Reading
51
+ * [materialize Documentation](https://materializecss.com)
52
+ * [Simple Navigation Wiki](https://github.com/andi/simple-navigation/wiki/)
53
+
54
+ ## Contributions
55
+ * [Simple Navigation for Bootstrap](https://github.com/pdf/simple-navigation-bootstrap) for the base of this code
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,5 @@
1
+ module SimpleNavigationMaterialize
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
5
+
@@ -0,0 +1,3 @@
1
+ module SimpleNavigationMaterialize
2
+ VERSION = "1.0.1"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "simple-navigation"
2
+ require "simple_navigation/core_ext/item_container.rb"
3
+ require "simple_navigation/rendering/renderer/materialize"
4
+ require "simple-navigation-materialize/engine"
5
+ require "simple-navigation-materialize/version"
6
+ SimpleNavigation.register_renderer :materialize => SimpleNavigation::Renderer::Materialize
Binary file
@@ -0,0 +1,6 @@
1
+ module SimpleNavigation
2
+ # ItemContainer monkey-patch to add some Bootstrap configuration attributes
3
+ class ItemContainer
4
+ attr_accessor :type
5
+ end
6
+ end
@@ -0,0 +1,63 @@
1
+ module SimpleNavigation
2
+ module Renderer
3
+ class Materialize < SimpleNavigation::Renderer::Base
4
+ def render(item_container)
5
+ return '' if respond_to?(:skip_if_empty?) && skip_if_empty? && item_container.empty?
6
+ config_selected_class = SimpleNavigation.config.selected_class
7
+ SimpleNavigation.config.selected_class = 'active'
8
+ type = options[:type] ? options[:type] : :navbar
9
+ hide_icons = options[:hide_icons]
10
+ list_content = item_container.items.inject([]) do |list, item|
11
+ li_options = item.html_options.reject {|k, v| k == :link}
12
+ if hide_icons
13
+ li_options.delete(:icon)
14
+ icon = nil
15
+ else
16
+ icon = li_options.delete(:icon)
17
+ end
18
+ li_content = tag_for(item, item.name, icon, type)
19
+ if include_sub_navigation?(item)
20
+ item.sub_navigation.dom_class = [item.sub_navigation.dom_class, type == :navbar ? 'dropdown-content' : nil].flatten.compact.join(' ')
21
+ if type == :navbar
22
+ item.sub_navigation.dom_id = "#{item.key.to_s}-dropdown"
23
+ else
24
+ item.sub_navigation.dom_id = nil
25
+ end
26
+ li_content << render_sub_navigation_for(item)
27
+ li_options[:class] = [li_options[:class]].flatten.compact.join(' ')
28
+ end
29
+ list << content_tag(:li, li_content, li_options)
30
+ end.join
31
+ SimpleNavigation.config.selected_class = config_selected_class
32
+ dom_id = item_container.dom_id ? item_container.dom_id : options[:dom_attributes][:id]
33
+ dom_class = item_container.dom_class ? item_container.dom_class : options[:dom_attributes][:class]
34
+ dom_attributes = {id: dom_id, class: dom_class}
35
+ content_tag(:ul, list_content, dom_attributes)
36
+ end
37
+
38
+ protected
39
+
40
+ def tag_for(item, name = '', icon = nil, type = :navbar)
41
+ unless item.url or include_sub_navigation?(item)
42
+ return item.name
43
+ end
44
+ url = item.url
45
+ link = Array.new
46
+ link << content_tag(:i, icon, :class => ['material-icons', 'left'].flatten.compact.join(' ')) unless icon.nil?
47
+ link << name
48
+ if include_sub_navigation?(item)
49
+ item_options = item.html_options
50
+ item_options[:link] = Hash.new if item_options[:link].nil?
51
+ item_options[:link][:class] = Array.new if item_options[:link][:class].nil?
52
+ if type == :navbar
53
+ item_options[:link][:class] << 'dropdown-trigger'
54
+ item_options[:link][:'data-target'] = "#{item.key.to_s}-dropdown"
55
+ end
56
+ item.html_options = item_options
57
+ end
58
+ link_to(link.join(" ").html_safe, url, options_for(item))
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "simple-navigation-materialize/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "simple-navigation-materialize"
7
+ s.version = SimpleNavigationMaterialize::VERSION
8
+ s.authors = ["Sebastian Binder"]
9
+ s.homepage = "https://gitlab.com/sebastianbinder/simple-navigation-materialize"
10
+ s.summary = %q{simple-navigation-bootstrap is a simple-navigation renderer for twitter-bootstrap navigation and dropdowns.}
11
+ s.description = %q{simple-navigation-bootstrap is a simple-navigation renderer for twitter-bootstrap navigation and dropdowns.}
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.require_paths = ["lib"]
17
+
18
+ # specify any dependencies here; for example:
19
+ s.add_development_dependency "rake"
20
+ s.add_runtime_dependency "simple-navigation", ">= 3.7.0", "< 4.0.0"
21
+ s.add_runtime_dependency "railties", ">= 3.1"
22
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple-navigation-materialize
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sebastian Binder
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-01-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: simple-navigation
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.7.0
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: 4.0.0
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 3.7.0
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: 4.0.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: railties
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '3.1'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '3.1'
61
+ description: simple-navigation-bootstrap is a simple-navigation renderer for twitter-bootstrap
62
+ navigation and dropdowns.
63
+ email:
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - ".DS_Store"
69
+ - ".gitignore"
70
+ - ".ruby-gemset"
71
+ - Gemfile
72
+ - LICENSE
73
+ - README.md
74
+ - Rakefile
75
+ - lib/.DS_Store
76
+ - lib/simple-navigation-materialize.rb
77
+ - lib/simple-navigation-materialize/engine.rb
78
+ - lib/simple-navigation-materialize/version.rb
79
+ - lib/simple_navigation/.DS_Store
80
+ - lib/simple_navigation/core_ext/item_container.rb
81
+ - lib/simple_navigation/rendering/renderer/materialize.rb
82
+ - simple-navigation-materialize.gemspec
83
+ homepage: https://gitlab.com/sebastianbinder/simple-navigation-materialize
84
+ licenses: []
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubygems_version: 3.2.3
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: simple-navigation-bootstrap is a simple-navigation renderer for twitter-bootstrap
105
+ navigation and dropdowns.
106
+ test_files: []