semantic_navigation 0.0.3 → 0.0.4
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.
- data/Changelog.md +6 -0
- data/README.md +10 -9
- data/lib/semantic_navigation/configuration.rb +4 -0
- data/lib/semantic_navigation/core/render.rb +13 -5
- data/lib/semantic_navigation/item.rb +11 -3
- data/lib/semantic_navigation/version.rb +1 -1
- data/lib/tasks/semantic_navigation.rake +0 -5
- data/lib/tasks/templates/semantic_navigation.rb +5 -2
- data/semantic_navigation.gemspec +1 -1
- metadata +8 -8
data/Changelog.md
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
This is
|
2
|
-
|
1
|
+
This is semantic_navigation
|
2
|
+
|
3
|
+
Current version: 0.0.4
|
3
4
|
|
4
5
|
###Purpose
|
5
6
|
The purpose of this gem is to generate simple and usefull navigation. You can define different menus and render them separately, specify root nodes, setup your own renderers and other.
|
@@ -7,18 +8,18 @@ The purpose of this gem is to generate simple and usefull navigation. You can de
|
|
7
8
|
###How to install
|
8
9
|
|
9
10
|
Write the gem dependency in your Gemfile:
|
10
|
-
|
11
|
+
<pre><code>
|
11
12
|
gem 'semantic_navigation'
|
12
|
-
|
13
|
+
</code></pre>
|
13
14
|
|
14
15
|
Make the install by bundler
|
15
|
-
|
16
|
+
<pre><code>
|
16
17
|
$ bundle install
|
17
|
-
|
18
|
+
</code></pre>
|
18
19
|
|
19
20
|
Generate the config file:
|
20
|
-
|
21
|
+
<pre><code>
|
21
22
|
$ rake semantic_navigation:install
|
22
|
-
|
23
|
-
|
23
|
+
</code></pre>
|
24
24
|
|
25
|
+
For the information of how to configure and render your menus read the <a href='https://github.com/fr33z3/semantic_navigation/wiki'>Wiki</a>
|
@@ -37,8 +37,12 @@ module SemanticNavigation
|
|
37
37
|
!item.nil? && !item.parent.nil? ? item.parent.name : ''
|
38
38
|
elsif command == :breadcrumb
|
39
39
|
return @menus[name.to_sym].render_breadcrumb
|
40
|
+
elsif command == :root
|
41
|
+
return @menus[name.to_sym].render_levels 1
|
40
42
|
elsif command.is_a?(Hash) && command.keys == [:levels]
|
41
43
|
return @menus[name.to_sym].render_levels command[:levels]
|
44
|
+
elsif command.is_a?(Hash) && command.keys == [:from_level]
|
45
|
+
return @menus[name.to_sym].render_from command[:from_level]
|
42
46
|
else
|
43
47
|
raise NoMethodError.new("Wrong menu render parameter:`#{command.to_s}`")
|
44
48
|
end
|
@@ -7,7 +7,7 @@ module SemanticNavigation
|
|
7
7
|
if @parent
|
8
8
|
level_condition = last_level.nil? ? true : @level < last_level
|
9
9
|
sub = (@active || show_submenu?) && level_condition ? render_submenu(last_level) : nil
|
10
|
-
view_object.content_tag(:li, item_link + sub, :id => li_id, :class => classes)
|
10
|
+
view_object.content_tag(:li, item_link(classes) + sub, :id => li_id, :class => classes)
|
11
11
|
else
|
12
12
|
render_submenu
|
13
13
|
end
|
@@ -42,7 +42,7 @@ module SemanticNavigation
|
|
42
42
|
breadcrumb = nil
|
43
43
|
if @active
|
44
44
|
if @name
|
45
|
-
breadcrumb = view_object.content_tag(:li, item_link +
|
45
|
+
breadcrumb = view_object.content_tag(:li, item_link(breadcrumb_classes) + breadcrumb_divider, :id => li_id) if @name
|
46
46
|
end
|
47
47
|
buff = @sub_items.map{|s| s.render_breadcrumb}.find{|s| !s.nil?}
|
48
48
|
if !breadcrumb.nil?
|
@@ -51,7 +51,7 @@ module SemanticNavigation
|
|
51
51
|
breadcrumb = buff
|
52
52
|
end
|
53
53
|
end
|
54
|
-
breadcrumb = view_object.content_tag(:ul, breadcrumb, :id => ul_id, :class =>
|
54
|
+
breadcrumb = view_object.content_tag(:ul, breadcrumb, :id => ul_id, :class => breadcrumb_menu_classes) if !@parent
|
55
55
|
breadcrumb
|
56
56
|
end
|
57
57
|
|
@@ -64,14 +64,22 @@ module SemanticNavigation
|
|
64
64
|
item.level == levels.first-1 ? item.render_submenu(levels.last) : nil
|
65
65
|
end
|
66
66
|
|
67
|
+
def render_from level_num
|
68
|
+
item = find_active_item
|
69
|
+
while item.level > level_num-1 && item.level != 0
|
70
|
+
item = item.parent
|
71
|
+
end
|
72
|
+
item.level == level_num-1 ? item.render_submenu : nil
|
73
|
+
end
|
74
|
+
|
67
75
|
private
|
68
76
|
|
69
77
|
def active?
|
70
78
|
!@parent.nil? ? view_object.current_page?(@url_options) : false
|
71
79
|
end
|
72
80
|
|
73
|
-
def item_link
|
74
|
-
view_object.link_to @name, @url_options, :class =>
|
81
|
+
def item_link(classes_string)
|
82
|
+
view_object.link_to @name, @url_options, :class => classes_string, :id => a_id
|
75
83
|
end
|
76
84
|
|
77
85
|
end
|
@@ -17,6 +17,7 @@ module SemanticNavigation
|
|
17
17
|
|
18
18
|
#Breadcrumb variables
|
19
19
|
@@breadcrumb_divider = "/"
|
20
|
+
@@breadcrumb_active_class = 'active'
|
20
21
|
|
21
22
|
|
22
23
|
|
@@ -78,6 +79,13 @@ module SemanticNavigation
|
|
78
79
|
class_array.flatten.join(' ')
|
79
80
|
end
|
80
81
|
|
82
|
+
def breadcrumb_classes
|
83
|
+
class_array = []
|
84
|
+
class_array += item_classes.to_a
|
85
|
+
class_array.push(@@breadcrumb_active_class) if active?
|
86
|
+
class_array
|
87
|
+
end
|
88
|
+
|
81
89
|
def view_object
|
82
90
|
@@view_object
|
83
91
|
end
|
@@ -86,11 +94,11 @@ module SemanticNavigation
|
|
86
94
|
@show_submenu.nil? ? @@show_submenu : @show_submenu
|
87
95
|
end
|
88
96
|
|
89
|
-
def
|
90
|
-
@@breadcrumb_divider.html_safe
|
97
|
+
def breadcrumb_divider
|
98
|
+
@@breadcrumb_divider.html_safe if !active?
|
91
99
|
end
|
92
100
|
|
93
|
-
def
|
101
|
+
def breadcrumb_menu_classes
|
94
102
|
if @@breadcrumb_classes.is_a? Array
|
95
103
|
return @@breadcrumb_classes.join(' ')
|
96
104
|
else
|
@@ -5,9 +5,4 @@ namespace :semantic_navigation do
|
|
5
5
|
task :install => :environment do
|
6
6
|
File.copy("#{File.dirname(__FILE__)}/templates/semantic_navigation.rb", "#{Rails.root}/config")
|
7
7
|
end
|
8
|
-
|
9
|
-
desc "Shows the menu hierarchy"
|
10
|
-
task :show => :environment do
|
11
|
-
puts "Here will be the navigation printout"
|
12
|
-
end
|
13
8
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#Wiki pages link: https://github.com/fr33z3/semantic_navigation/wiki/_pages
|
4
4
|
SemanticNavigation::Configuration.run do |config|
|
5
5
|
|
6
|
-
#What's the name of the active
|
6
|
+
#What's the name of the active item class will be (the dafault is 'active')
|
7
7
|
#config.active_class = 'active';
|
8
8
|
|
9
9
|
#Do you want to show active class? (default = true)
|
@@ -33,9 +33,12 @@ SemanticNavigation::Configuration.run do |config|
|
|
33
33
|
#Define breadcrumb divider
|
34
34
|
#config.breadcrumb_divider = "<span class ='divider'>/</span>"
|
35
35
|
|
36
|
-
#Define
|
36
|
+
#Define breadcrumb classes
|
37
37
|
#config.breadcrumb_classes = "breadcrumb"
|
38
38
|
|
39
|
+
#Define breadcrumb active class name (default = 'active')
|
40
|
+
#config.breadcrumb_active_class = 'active'
|
41
|
+
|
39
42
|
#That's the creation of the `navigation` menu
|
40
43
|
#config.navigation {|n|
|
41
44
|
# n.dashboard 'Dashboard', :controller => :dashboard, :action => :index do |d|
|
data/semantic_navigation.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: semantic_navigation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sergey Gribovski
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-06 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec
|
@@ -39,14 +39,14 @@ dependencies:
|
|
39
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
44
|
+
hash: 7
|
45
45
|
segments:
|
46
46
|
- 3
|
47
|
-
- 1
|
48
47
|
- 0
|
49
|
-
|
48
|
+
- 0
|
49
|
+
version: 3.0.0
|
50
50
|
type: :runtime
|
51
51
|
version_requirements: *id002
|
52
52
|
description: Simply and customizable navigation in the Rails application
|