navGATE 0.1.23 → 0.1.24
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 +4 -4
- data/Rakefile +1 -1
- data/lib/navgate.rb +15 -6
- data/lib/readme.rdoc +9 -7
- data/navGATE.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b486930a82ec515b354bdba6204f06d72cf199c
|
4
|
+
data.tar.gz: f3449613e5c25aeb8da60459e5365043f2412e5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8e3d25f36a480c7114c8b35a1de08dc1a4f42deb2b2314ef1d3e1b366c8916f612f792f938881281faf381874676ff0e4a514a5c7abe392de32b314a663de32
|
7
|
+
data.tar.gz: de7388e3031a146023c896c309933834a333c4a2a795cfda5bd1e66ca6dd614914519c90a6d25b4cb09804095ebfcbd972ef46a74c4ff726efd9ba375c4dafbb
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rake'
|
|
3
3
|
require 'echoe'
|
4
4
|
|
5
5
|
|
6
|
-
Echoe.new('navGATE','0.1.
|
6
|
+
Echoe.new('navGATE','0.1.24') do |p|
|
7
7
|
p.summary = "Allows the easy creation of navigation with config files"
|
8
8
|
p.description = "Can create navigation from objects using the nav builder,from database tables or from a yaml file"
|
9
9
|
p.url = "https://github.com/Thermatix/navGATE"
|
data/lib/navgate.rb
CHANGED
@@ -96,7 +96,7 @@ class Navgate
|
|
96
96
|
|
97
97
|
end
|
98
98
|
|
99
|
-
attr_accessor :controllers, :navs
|
99
|
+
attr_accessor :controllers, :navs, :ignoring
|
100
100
|
|
101
101
|
def initialize
|
102
102
|
self.controllers = Rails.application.routes.routes.map do |route|
|
@@ -125,17 +125,26 @@ class Navgate
|
|
125
125
|
|
126
126
|
|
127
127
|
def render_nav selection, controller, options
|
128
|
-
|
129
|
-
|
128
|
+
if ignoring.include?(selection)
|
129
|
+
nav = nav_cache(controller.split('/').last).render_it_with(options,selection).html_safe
|
130
|
+
nav
|
131
|
+
else
|
132
|
+
nil
|
133
|
+
end
|
130
134
|
end
|
131
135
|
|
132
136
|
def select selection, controller
|
133
|
-
if selection
|
134
|
-
|
137
|
+
if ignoring.include?(selection)
|
138
|
+
if selection
|
139
|
+
selection
|
140
|
+
else
|
141
|
+
nav_cache(controller.split('/').last).default.to_s
|
142
|
+
end
|
135
143
|
else
|
136
|
-
|
144
|
+
nil
|
137
145
|
end
|
138
146
|
end
|
147
|
+
|
139
148
|
private
|
140
149
|
|
141
150
|
def nav_cache controller
|
data/lib/readme.rdoc
CHANGED
@@ -4,11 +4,10 @@ This gem is provided as is.
|
|
4
4
|
|
5
5
|
This gem allows for the ease of navigation building, from preset lists, from active model databases (eg, categories), from yaml files; but it's not just
|
6
6
|
for the ease of use it's also that you can have multiple navigation menus for differant controllers, or the same menu for differant controllers.
|
7
|
-
|
7
|
+
However you want it, it's up to you.
|
8
8
|
|
9
9
|
This gem was built with Rails in mind.
|
10
10
|
|
11
|
-
note: this is my first gem.
|
12
11
|
|
13
12
|
lastly the gem is up on rubygems.org
|
14
13
|
|
@@ -31,7 +30,7 @@ For non rails version of NavGATE the helpers change, instead they work like so:
|
|
31
30
|
render_navigation(selection, controller, options = nil)
|
32
31
|
|
33
32
|
You have to pass the controller (or page it matches) and the current selection,
|
34
|
-
in rails they would pass automatically as <tt> params[:controller] </tt> and <tt> params[:selection] </tt>
|
33
|
+
in rails they would pass automatically as <tt> params[:controller] </tt> and <tt> params[:selection] </tt> respectively (selection being the currently selected nav item).
|
35
34
|
|
36
35
|
==Building the menus
|
37
36
|
|
@@ -47,7 +46,7 @@ There are two ways to use this, the first is to use an array of strings containi
|
|
47
46
|
|
48
47
|
<b>Default</b>: This is used to give the menu a default selection for when the user has not selected anything. Pass a string containing the name of the default selection, if no string is passed then the first item from selection is used.
|
49
48
|
|
50
|
-
<b>prefix</b>: This is used when you have a prefix before the target in the URL, eg: if your links render out as "host.com/books" without a prefix; with a prefix of 'shelf' it will render out as "host.com/shelf/books". Namespacing is ignored within this gem, it only looks at the controller's name and nothing else when controller
|
49
|
+
<b>prefix</b>: This is used when you have a prefix before the target in the URL, eg: if your links render out as "host.com/books" without a prefix; with a prefix of 'shelf' it will render out as "host.com/shelf/books". Namespacing is ignored within this gem, it only looks at the controller's name and nothing else when controller matching.
|
51
50
|
|
52
51
|
<b>controller</b>: This is used to match the menu to a controller, when deciding which menu to render, it can also be an array of strings; it matches this attribute to the current controller.
|
53
52
|
|
@@ -55,7 +54,7 @@ There are two ways to use this, the first is to use an array of strings containi
|
|
55
54
|
|
56
55
|
<b>css_class</b>: This is used when you want to hard code the CSS class selector into the menu rather then from the view.
|
57
56
|
|
58
|
-
<b>css_selected</b>: the css
|
57
|
+
<b>css_selected</b>: the css override for the selected that's currently selected. if no override is passed then the link is simply not rendered out, as with css_class it overrides the one passed in the view, but only for the selected link
|
59
58
|
|
60
59
|
examples:
|
61
60
|
|
@@ -127,10 +126,13 @@ The yaml file:
|
|
127
126
|
controller: admin_panel
|
128
127
|
|
129
128
|
|
129
|
+
==Ignoring Controllers
|
130
|
+
Sometimes you're going to want to ignore controllers that don't any gui. Doing that is simple, when you're building the menu just pass an Array to build like so
|
131
|
+
build.ignoring = ['controllers','to','ignore']
|
132
|
+
before or after you pass through the navs.
|
130
133
|
|
131
134
|
==Rendering the menu
|
132
135
|
|
133
|
-
|
134
136
|
To render the menu use the provided helper <tt>render_navigation(options)</tt>;
|
135
137
|
options is a hash that is used to build any html options you might want such as
|
136
138
|
'class='some_css_class', it can also take two extra options, 'styling:' and 'wrap:'.
|
@@ -166,7 +168,7 @@ resulting url
|
|
166
168
|
host.com/books
|
167
169
|
host.com/games
|
168
170
|
|
169
|
-
routes to the root but the
|
171
|
+
routes to the root but the partials rendered would be respectively
|
170
172
|
_books.html.erb
|
171
173
|
_games.html.erb
|
172
174
|
|
data/navGATE.gemspec
CHANGED