innetra-easy_navigation 1.0.8 → 2.0.0
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/Rakefile +2 -2
- data/easy_navigation.gemspec +4 -4
- data/lib/easy_navigation.rb +45 -24
- metadata +4 -4
data/Rakefile
CHANGED
@@ -2,8 +2,8 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('easy_navigation', '
|
6
|
-
e.description = "Easy navigation for
|
5
|
+
Echoe.new('easy_navigation', '2.0.0') do |e|
|
6
|
+
e.description = "Easy navigation for Ruby on Rails 2.2 (i18n)"
|
7
7
|
e.url = "http://github.com/innetra/easy_navigation"
|
8
8
|
e.author = "Ivan Torres"
|
9
9
|
e.email = "mexpolk@gmail.com"
|
data/easy_navigation.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{easy_navigation}
|
5
|
-
s.version = "
|
5
|
+
s.version = "2.0.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Ivan Torres"]
|
9
|
-
s.date = %q{2008-12-
|
10
|
-
s.description = %q{Easy navigation for
|
9
|
+
s.date = %q{2008-12-21}
|
10
|
+
s.description = %q{Easy navigation for Ruby on Rails 2.2 (i18n)}
|
11
11
|
s.email = %q{mexpolk@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc", "lib/easy_navigation.rb"]
|
13
13
|
s.files = ["Manifest", "README.rdoc", "Rakefile", "init.rb", "lib/easy_navigation.rb", "easy_navigation.gemspec"]
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
s.rubyforge_project = %q{easy_navigation}
|
19
19
|
s.rubygems_version = %q{1.3.1}
|
20
|
-
s.summary = %q{Easy navigation for
|
20
|
+
s.summary = %q{Easy navigation for Ruby on Rails 2.2 (i18n)}
|
21
21
|
|
22
22
|
if s.respond_to? :specification_version then
|
23
23
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
data/lib/easy_navigation.rb
CHANGED
@@ -2,44 +2,65 @@ module EasyNavigation
|
|
2
2
|
|
3
3
|
module Helper
|
4
4
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def easy_navigation(name, options = {})
|
6
|
+
|
7
|
+
navigation_class_name = (options[:navigation_class] || "navigation").to_s
|
8
|
+
tab_class_name = (options[:tab_class] || "tab").to_s
|
9
|
+
menu_class_name = (options[:menu_class] || "menu").to_s
|
10
|
+
separator_class_name = (options[:separator_class] || "separator").to_s
|
11
|
+
separator = options[:separator] || false
|
12
|
+
|
13
|
+
tabs_html = ""
|
9
14
|
|
10
15
|
EasyNavigation::Builder.navigation[name][:tabs].each do |tab|
|
11
16
|
menus_html = ""
|
12
17
|
current_tab = false
|
13
18
|
tab[:menus].each do |menu|
|
14
|
-
|
15
|
-
if current_menu?(menu)
|
16
|
-
class_name << " current"
|
19
|
+
if current = current_menu?(menu)
|
17
20
|
current_tab = true
|
18
|
-
end
|
19
|
-
menus_html <<
|
20
|
-
:
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
end
|
22
|
+
menus_html << self.render_menu(menu[:name], menu[:text],
|
23
|
+
menu[:url].merge!(:skip_relative_url_root => true),
|
24
|
+
("#{menu_class_name} current" if current) || menu_class_name)
|
25
|
+
if separator
|
26
|
+
menus_html << self.render_separator(separator_class_name)
|
27
|
+
end
|
24
28
|
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
"#{
|
29
|
-
:class => class_name, :id => tab[:name])
|
29
|
+
tabs_html << self.render_tab(tab[:name],
|
30
|
+
tab[:text],
|
31
|
+
tab[:url].merge!(:skip_relative_url_root => true),
|
32
|
+
menus_html, ("#{tab_class_name} current" if current_tab) || tab_class_name)
|
30
33
|
end
|
31
|
-
|
34
|
+
self.render_navigation("navigation_" << name.to_s, tabs_html, navigation_class_name)
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def render_separator(class_name)
|
40
|
+
content_tag("li", "|", :class => class_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
def render_menu(id, text, url, class_name)
|
44
|
+
content_tag("li", link_to(t(text), url), :id => id, :class => class_name)
|
45
|
+
end
|
46
|
+
|
47
|
+
def render_tab(id, text, url, menus_html, class_name)
|
48
|
+
content_tag("li",
|
49
|
+
"#{link_to(t(text), url)} #{content_tag("ul", menus_html)}",
|
50
|
+
:id => id, :class => class_name)
|
51
|
+
end
|
52
|
+
|
53
|
+
def render_navigation(id, tabs_html, class_name)
|
54
|
+
content_tag("ul", tabs_html, :id => id, :class => class_name)
|
32
55
|
end
|
33
56
|
|
34
|
-
private
|
35
|
-
|
36
57
|
def current_menu?(menu)
|
37
|
-
current = controller.
|
58
|
+
current = controller.params[:controller] == menu[:url][:controller].gsub(/^\//, "") &&
|
38
59
|
(controller.action_name == menu[:url][:action] || menu[:url][:action] == nil)
|
39
60
|
if menu.has_key?:on
|
40
61
|
(menu[:on].is_a?(Array) ? menu[:on] : [menu[:on]]).each do |controllers|
|
41
62
|
(controllers.is_a?(Array) ? controllers : [controllers]).each do |c|
|
42
|
-
current |= controller.
|
63
|
+
current |= controller.params[:controller] == c[:controller].gsub(/^\//, "")
|
43
64
|
if c.has_key?:only
|
44
65
|
current &= (c[:only].is_a?(Array) ? c[:only] : [c[:only]]).include?controller.action_name
|
45
66
|
end
|
@@ -79,7 +100,7 @@ module EasyNavigation
|
|
79
100
|
end
|
80
101
|
|
81
102
|
def navigation(name, options = {}, &block)
|
82
|
-
navigation = Navigation.new(name, options.merge!(:prefix => "
|
103
|
+
navigation = Navigation.new(name, options.merge!(:prefix => "navigation"))
|
83
104
|
yield navigation
|
84
105
|
self.navigations << navigation.build
|
85
106
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: innetra-easy_navigation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Torres
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-21 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description: Easy navigation for
|
16
|
+
description: Easy navigation for Ruby on Rails 2.2 (i18n)
|
17
17
|
email: mexpolk@gmail.com
|
18
18
|
executables: []
|
19
19
|
|
@@ -59,6 +59,6 @@ rubyforge_project: easy_navigation
|
|
59
59
|
rubygems_version: 1.2.0
|
60
60
|
signing_key:
|
61
61
|
specification_version: 2
|
62
|
-
summary: Easy navigation for
|
62
|
+
summary: Easy navigation for Ruby on Rails 2.2 (i18n)
|
63
63
|
test_files: []
|
64
64
|
|