innetra-easy_navigation 1.0.0 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -17
- data/Rakefile +1 -1
- data/easy_navigation.gemspec +1 -1
- data/lib/easy_navigation.rb +13 -18
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -29,31 +29,23 @@ this:
|
|
29
29
|
tab.menu :index, :url => { :controller => "dashboard", :action => "index" } do |menu|
|
30
30
|
menu.connect :except => "new" # if :controller not specified it asumes is the same from tab
|
31
31
|
end
|
32
|
-
|
33
|
-
navigation.tab :post, :url => { :controller => "posts", :action => "index" } do |tab|
|
34
|
-
tab.menu :index, :url => { :controller => "posts", :action => "index" } do |menu|
|
35
|
-
menu.connect :except => "new"
|
36
|
-
end
|
37
|
-
tab.menu :new, :url => { :controller => "posts", :action => "new" } do |menu|
|
32
|
+
tab.menu :new, :url => { :controller => "dashboard", :action => "index" } do |menu|
|
38
33
|
menu.connect :only => "new"
|
39
34
|
end
|
40
|
-
tab.menu :rss, :url => { :controller => "post_rss", :action => "atom" } do |menu|
|
41
|
-
menu.connect :only => "show"
|
42
|
-
end
|
43
35
|
end
|
44
36
|
end
|
45
37
|
end
|
46
38
|
|
47
39
|
For internationalization, edit your "en-US.easy_navigation.yml" file lique this:
|
48
40
|
|
49
|
-
en-US:
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
41
|
+
en-US:
|
42
|
+
easy_navigation:
|
43
|
+
default:
|
44
|
+
home:
|
45
|
+
title: "Home"
|
46
|
+
menus:
|
47
|
+
index: "Dashboard"
|
48
|
+
new: "New Page"
|
57
49
|
|
58
50
|
|
59
51
|
As an example, to render you newly created menu called :default in your
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('easy_navigation', '1.0.
|
5
|
+
Echoe.new('easy_navigation', '1.0.8') do |e|
|
6
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"
|
data/easy_navigation.gemspec
CHANGED
data/lib/easy_navigation.rb
CHANGED
@@ -90,17 +90,16 @@ module EasyNavigation
|
|
90
90
|
|
91
91
|
class Navigation
|
92
92
|
|
93
|
-
attr_accessor :tabs, :name, :options
|
93
|
+
attr_accessor :tabs, :name, :options
|
94
94
|
|
95
95
|
def initialize(name, options = {})
|
96
96
|
self.tabs = []
|
97
97
|
self.name = name
|
98
98
|
self.options = options
|
99
|
-
self.prefix = options[:prefix]
|
100
99
|
end
|
101
100
|
|
102
101
|
def tab(name, options = {}, &block)
|
103
|
-
tab = Tab.new(name, options.merge!(:prefix => [self.prefix, self.name]))
|
102
|
+
tab = Tab.new(name, options.merge!(:prefix => [self.options[:prefix], self.name]))
|
104
103
|
yield tab
|
105
104
|
self.tabs << tab.build
|
106
105
|
end
|
@@ -112,47 +111,43 @@ module EasyNavigation
|
|
112
111
|
|
113
112
|
class Tab
|
114
113
|
|
115
|
-
attr_accessor :menus, :name, :
|
114
|
+
attr_accessor :menus, :name, :options
|
116
115
|
|
117
116
|
def initialize(name, options = {})
|
118
117
|
self.menus = []
|
119
118
|
self.name = name
|
120
|
-
self.url = options[:url]
|
121
119
|
self.options = options
|
122
|
-
self.prefix = options[:prefix]
|
123
120
|
end
|
124
121
|
|
125
122
|
def menu(name, options = {}, &block)
|
126
|
-
menu = Menu.new(name, options.merge!(:prefix => [self.prefix, self.name, "menus"]))
|
123
|
+
menu = Menu.new(name, options.merge!(:prefix => [self.options[:prefix], self.name, "menus"]))
|
127
124
|
yield menu
|
128
125
|
self.menus << menu.build
|
129
126
|
end
|
130
127
|
|
131
128
|
def build
|
132
|
-
{ :name => [self.prefix, self.name].join("_").to_sym,
|
133
|
-
:text => [self.prefix, self.name, "title"].join("."),
|
134
|
-
:url => self.url,
|
129
|
+
{ :name => [self.options[:prefix], self.name].join("_").to_sym,
|
130
|
+
:text => [self.options[:prefix], self.name, "title"].join("."),
|
131
|
+
:url => self.options[:url],
|
135
132
|
:options => self.options,
|
136
133
|
:menus => self.menus }
|
137
134
|
end
|
138
135
|
|
139
136
|
class Menu
|
140
137
|
|
141
|
-
attr_accessor :name, :
|
138
|
+
attr_accessor :name, :options, :active_urls
|
142
139
|
|
143
140
|
def initialize(name, params = {})
|
144
141
|
self.active_urls = []
|
145
142
|
self.name = name
|
146
|
-
self.url = params[:url]
|
147
143
|
self.options = params
|
148
|
-
self.prefix = params[:prefix]
|
149
144
|
end
|
150
145
|
|
151
146
|
def build
|
152
|
-
self.prefix << self.name
|
153
|
-
{ :name => self.prefix.join("_").to_sym,
|
154
|
-
:text => self.prefix.join("."),
|
155
|
-
:url => self.url,
|
147
|
+
self.options[:prefix] << self.name
|
148
|
+
{ :name => self.options[:prefix].join("_").to_sym,
|
149
|
+
:text => self.options[:prefix].join("."),
|
150
|
+
:url => self.options[:url],
|
156
151
|
:on => self.active_urls }
|
157
152
|
end
|
158
153
|
|
@@ -169,6 +164,6 @@ module EasyNavigation
|
|
169
164
|
|
170
165
|
Builder = Configuration.new
|
171
166
|
|
172
|
-
end# EasyNavigation
|
167
|
+
end # EasyNavigation
|
173
168
|
|
174
169
|
ActionView::Base.send :include, EasyNavigation::Helper
|