jordanyeo-simple-navigation 3.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/CHANGELOG +265 -0
  2. data/Gemfile +17 -0
  3. data/README +22 -0
  4. data/Rakefile +47 -0
  5. data/VERSION +1 -0
  6. data/generators/navigation_config/USAGE +1 -0
  7. data/generators/navigation_config/navigation_config_generator.rb +8 -0
  8. data/generators/navigation_config/templates/config/navigation.rb +76 -0
  9. data/lib/generators/navigation_config/navigation_config_generator.rb +12 -0
  10. data/lib/simple-navigation.rb +1 -0
  11. data/lib/simple_navigation.rb +167 -0
  12. data/lib/simple_navigation/adapters.rb +10 -0
  13. data/lib/simple_navigation/adapters/base.rb +37 -0
  14. data/lib/simple_navigation/adapters/nanoc.rb +45 -0
  15. data/lib/simple_navigation/adapters/padrino.rb +20 -0
  16. data/lib/simple_navigation/adapters/rails.rb +93 -0
  17. data/lib/simple_navigation/adapters/sinatra.rb +69 -0
  18. data/lib/simple_navigation/core.rb +5 -0
  19. data/lib/simple_navigation/core/configuration.rb +72 -0
  20. data/lib/simple_navigation/core/item.rb +144 -0
  21. data/lib/simple_navigation/core/item_adapter.rb +63 -0
  22. data/lib/simple_navigation/core/item_container.rb +147 -0
  23. data/lib/simple_navigation/core/items_provider.rb +35 -0
  24. data/lib/simple_navigation/rails_controller_methods.rb +144 -0
  25. data/lib/simple_navigation/rendering.rb +12 -0
  26. data/lib/simple_navigation/rendering/helpers.rb +123 -0
  27. data/lib/simple_navigation/rendering/renderer/base.rb +107 -0
  28. data/lib/simple_navigation/rendering/renderer/breadcrumbs.rb +59 -0
  29. data/lib/simple_navigation/rendering/renderer/json.rb +29 -0
  30. data/lib/simple_navigation/rendering/renderer/links.rb +32 -0
  31. data/lib/simple_navigation/rendering/renderer/list.rb +29 -0
  32. data/lib/simple_navigation/rendering/renderer/text.rb +26 -0
  33. data/rails/init.rb +1 -0
  34. data/spec/lib/simple_navigation/adapters/padrino_spec.rb +31 -0
  35. data/spec/lib/simple_navigation/adapters/rails_spec.rb +287 -0
  36. data/spec/lib/simple_navigation/adapters/sinatra_spec.rb +80 -0
  37. data/spec/lib/simple_navigation/core/configuration_spec.rb +128 -0
  38. data/spec/lib/simple_navigation/core/item_adapter_spec.rb +212 -0
  39. data/spec/lib/simple_navigation/core/item_container_spec.rb +451 -0
  40. data/spec/lib/simple_navigation/core/item_spec.rb +566 -0
  41. data/spec/lib/simple_navigation/core/items_provider_spec.rb +60 -0
  42. data/spec/lib/simple_navigation/rails_controller_methods_spec.rb +249 -0
  43. data/spec/lib/simple_navigation/rendering/helpers_spec.rb +276 -0
  44. data/spec/lib/simple_navigation/rendering/renderer/base_spec.rb +199 -0
  45. data/spec/lib/simple_navigation/rendering/renderer/breadcrumbs_spec.rb +101 -0
  46. data/spec/lib/simple_navigation/rendering/renderer/json_spec.rb +48 -0
  47. data/spec/lib/simple_navigation/rendering/renderer/links_spec.rb +64 -0
  48. data/spec/lib/simple_navigation/rendering/renderer/list_spec.rb +211 -0
  49. data/spec/lib/simple_navigation/rendering/renderer/text_spec.rb +41 -0
  50. data/spec/lib/simple_navigation_spec.rb +307 -0
  51. data/spec/spec_helper.rb +108 -0
  52. metadata +199 -0
data/CHANGELOG ADDED
@@ -0,0 +1,265 @@
1
+ *3.11.0
2
+
3
+ * Added Json renderer. Thanks to Alberto Avila.
4
+
5
+ *3.10.1
6
+
7
+ * Padrino adapter now returns "html_safe"d content_tag
8
+
9
+ *3.10.0
10
+
11
+ * Added ability to set selected_class on container level. Credits to Joost Hietbrink.
12
+ * do not highlight items that are only partial matches. Thanks to Troy Thompson.
13
+ * adding support for rails 4. Credits to Samer Masry.
14
+
15
+ *3.9.0
16
+
17
+ * Added ability to pass a block to render_navigation for configuring dynamic navigation items (instead of passing :items). Credits to Ronald Chan.
18
+
19
+ *3.8.0
20
+
21
+ * Changed the way the context is fetched. Fixes incompatibility with Gretel. Thanks to Ivan Kasatenko.
22
+ * Added :join_with option to links renderer. Thanks to Stefan Melmuk.
23
+ * Added :prefix option to breadcrumb renderer. Credits to Rodrigo Manhães.
24
+ * Added :ordered option for allowing list renderer to render an <ol> rather than a <ul>.
25
+ * Sinatra adapter no longer renders attributes with nil values as attributes with empty strings in the output, instead electing not to render the attribute at all. Thanks to revdan for pointing this out.
26
+
27
+ *3.7.0
28
+
29
+ * Added new adapater for working with the Nanoc static site generation framework.
30
+ * Fix issue #22 - last link in a breadcrumb trail may now be rendered as static text insted by supplying :static_leaf => true as an option
31
+ * Allow breadcrumbs to be provided with link id and classes by supplying :allow_classes_and_ids => true as an option
32
+
33
+ *3.6.0
34
+
35
+ * Added linkless items functionality - the `url` parameter is now optional, items which aren't links will be rendered within a 'span' element rather than an 'a' element. `options` remain optional (defaults to an empty Hash). `options` may be provided without providing a `url` (detected by checking if the '`url`' parameter is a Hash or otherwise).
36
+
37
+ *3.5.1
38
+
39
+ * Fixed specs related to testing name_generator functionality - stub the name_generator method rather than calling it to ensure subsequent tests aren't affected.
40
+
41
+ *3.5.0
42
+
43
+ * Added (configurable) "simple-navigation-active-leaf" class to last selected element and elements that have :highlights_on return true. Thanks to Frank Schumacher (thenoseman).
44
+
45
+ *3.4.2
46
+
47
+ * Improve Gemfile dependencies with :development and :rails groups.
48
+
49
+ *3.4.1
50
+
51
+ * Rerelease using ruby-1.8.7 rather than ruby-1.9.2 in order that the rubygems.org gemspec is generated in a compatible fashion.
52
+
53
+ *3.4.0
54
+
55
+ * Added Gemfile for easier development with Bundler. Thanks to Josep Jaume.
56
+ * modified :highlights_on option to accept a :subpath option (as well as Proc and Regexp forms). This can be used to automatically highlight an item even for items within a subpath. Thanks to Josep Jaume.
57
+
58
+ *3.3.4
59
+
60
+ * modified :highlights_on option to accept a Proc (as well as the existing Regexp form). This can be used to provide specific highlighting conditions inline. Thanks to superlou for sparking the idea for the concept.
61
+
62
+ *3.3.3
63
+
64
+ * Bugfix in Adapters::Sinatra#current_url? (compares unencoded URIs). Thanks to Matthew Gast.
65
+
66
+ *3.3.2
67
+
68
+ * The patch listed in 3.3.1 somehow did not make it into the gem... sorry. Re-releasing...
69
+
70
+ *3.3.1
71
+
72
+ * bugfix in sinatra adapter. Use Rack::Request#scheme instead of Rack::Request#protocol. Credits to Matthew Gast.
73
+
74
+ *3.3.0
75
+
76
+ * add a new method active_navigation_item_key which returns the symbol for the currently selected navigation item in a similar way to active_navigation_item_name does for the name (useful for CSS class styling for eg.)
77
+ * open up the helper API to provide active_navigation_item and active_navigation_item_container methods to make it easy to access the items/containers should it be necessary (came for free with the above refactoring)
78
+ * isolate the apply_defaults and load_config private methods from ActionController mixin leakage by refactoring to module class instance methods
79
+ * addition of test coverage for the added helpers within helpers_spec.rb
80
+ * inclusion of new helpers within the rails adapter and minor refactoring to DRY up the helper_method invocations
81
+ * addition of test coverage for the newly included helpers
82
+ * Credits to Mark J. Titorenko for all the changes in this release! Thanks.
83
+
84
+ *3.2.0
85
+
86
+ * Added Renderer::Text for rendering selected navigation items without markup (useful for dynamic page titles). Credits to Tim Cowlishaw.
87
+ * Added ability to add custom markup around item names specifying a name_generator in the config file. Thanks to Jack Dempsey.
88
+
89
+ *3.1.1
90
+
91
+ * Item#selected_by_url? now strips anchors from the item's url before comparing it with the current request's url. Credits to opengovernment.
92
+
93
+ *3.1.0
94
+
95
+ * added new helper method 'active_navigation_item_name' to render the name of the currently active item
96
+
97
+ *3.0.2
98
+
99
+ * dom_id and dom_class can now be set as option in the item's definition (useful for dynamic menu items).
100
+
101
+ *3.0.1
102
+
103
+ * allow controller instance variables named @template for rails3 apps. Credits to cmartyn.
104
+ * added possibility to specify and item's URL as a block which is evaulated after the :if and :unless conditions have been checked. Credits to Nicholas Firth-McCoy.
105
+ * upgraded to rspec 2.0.0
106
+ * fixed cgi error in sinatra adapter. Credits to Jack Dempsey.
107
+
108
+ *3.0.0
109
+
110
+ * added ability to specify dynamic items using an array of hashes. Credits to Anshul Khandelwal for input and discussion.
111
+ * added ability to specify attributes for the generated link-tag in list renderer (up to now the attributes have been applied to the li-tag). Credits to Anthony Navarre for input and discussion.
112
+
113
+ *3.0.0.beta2
114
+
115
+ * moving code for initializing plugin in sinatra to separate gem
116
+
117
+ *3.0.0.beta1
118
+
119
+ * moving deprecated rails controller methods (navigation, current_navigation) to separate file 'rails_controller_methods'. Deprecations removed. File can be required explicitly if controller methods should be still available.
120
+ * decoupling from Rails. Introducing the concept of adapters to work with several frameworks.
121
+ * tested with Rails 3.0.0
122
+ * adding support for Sinatra and Padrino frameworks.
123
+ * cherry picking active_support stuff instead of requiring the whole bunch (tested with active_support >= 2.3.2 and 3.0.0)
124
+ * created public sample project which includes demo for Rails2, Rails3, Sinatra and Padrino (will be available on github soon)
125
+ * better src file organization (adapters/core/rendering folders)
126
+
127
+ *2.7.3
128
+
129
+ * initializing SimpleNavigation.config_file_path with empty array (was nil before). Allows for adding paths before gem has been initialized.
130
+
131
+ *2.7.2
132
+
133
+ * added ability to have more than one config_file_path (useful if simple-navigation is used as a part of another gem/plugin). Credits to Luke Imhoff.
134
+
135
+ *2.7.1
136
+
137
+ * added SimpleNavigation.request and SimpleNavigation.request_uri as abstraction for getting request_uri (rails2/rails3)
138
+ * use request.fullpath instead of request.request_uri for Rails3. Credits to Ben Langfeld.
139
+
140
+ *2.7.0
141
+
142
+ * added new option :highlights_on to item definition in config-file. Specify a regexp which is matched against the current_uri to determine if an item is active or not. Replaces explicit highlighting in controllers.
143
+ * deprecated explicit highlighting in the controllers.
144
+
145
+ *2.6.0
146
+
147
+ * added rendering option 'skip_if_empty' to Renderer::List to avoid rendering of empty ul-tags
148
+ * added breadcrumbs renderer incl. specs. A big thanks to Markus Schirp.
149
+ * added ability to register a renderer / specify your renderer as symbol in render_navigation
150
+ * renderer can be specified in render_navigation. Credits to Andi Bade from Galaxy Cats.
151
+
152
+ *2.5.4
153
+
154
+ * bugfix: SimpleNavigation.config_file? without params does not check for _navigation.rb file anymore. Credits to Markus Schirp.
155
+
156
+ *2.5.3
157
+
158
+ * removed deprecated railtie_name from simple_navigation/railtie. Credits to Markus Schirp.
159
+
160
+ *2.5.2
161
+
162
+ * added Rails3 generator for navigation_config.rb. Thanks to Josep Jaume Rey.
163
+
164
+ *2.5.1
165
+
166
+ * set template correctly for Rails3 (brings auto highlighting to life again). Credits to Josep Jaume Rey.
167
+
168
+ *2.5.0
169
+
170
+ * added new renderer Renderer::Links to simply render the navigation as links inside a div.
171
+ * also make item.name html_safe (in order you have html_code in the item's name). Thanks again, Johan Svensson.
172
+
173
+ *2.4.2
174
+
175
+ * Rails 3.0.0.beta2 compatibility
176
+ * Renderer::List --> make content of ul-tag html_safe for rails 3.0.0.beta2 (due to rails3 XSS protection). Credits to Johan Svensson and Disha Albaqui.
177
+ * updated copyright
178
+ * reduced visibility of 'sn_set_navigation' to protected
179
+
180
+ *2.4.1
181
+
182
+ * removing depencency to rails. It installs the newest rails, even if a matching version is present. why is that?
183
+
184
+ *2.4.0
185
+
186
+ * added Rails3 compatibility
187
+ * added Jeweler::Gemcutter Tasks to Rakefile
188
+
189
+ *2.2.3
190
+
191
+ * changed error handling in config-file. Do not ignore errors in config-file anymore.
192
+ * only load config-file if it is present. Needed when directly providing items in render_navigation.
193
+
194
+ *2.2.2
195
+
196
+ * added lib/simple-navigation.rb to allow 'require simple-navigation' or 'config.gem "simple-navigation"'
197
+
198
+ *2.2.1
199
+
200
+ * Corrected URL to API-Doc on rubyforge in README
201
+
202
+ *2.2.0
203
+
204
+ * Allow Ranges for :level option. Credits to Ying Tsen Hong.
205
+ * Changing the API of Helpers#render_navigation. Now supports Ranges for :level option and :expand_all to render all levels as expanded. Old Api is still supported, but deprecated.
206
+ * Deprecated render_all_levels in config-file.
207
+
208
+ *2.1.0
209
+
210
+ * included Ben Marini's commit which allows individual id-generators. Thanks Ben!
211
+ * added ability to specify navigation items through items_provider. This is useful for generating the navigation dynamically (e.g. from database)
212
+ * items can now even be passed directly into render_navigation method.
213
+
214
+ *2.0.1
215
+
216
+ * fixed handling of a non-existent explicit navigation item for a navigation context
217
+
218
+ *2.0.0
219
+
220
+ * added auto_highlight feature. Active navigation is determined by comparing urls, no need to explicitly set it in the controllers anymore. Thanks to Jack Dempsey and Florian Hanke for the support on this.
221
+ * added ability to create multi-level navigations (not just limited to primary and secondary navigation). Thanks again to Jack Dempsey for the motivation ;-)
222
+ * simplified the process to explicitly set the navigation in the controller (where needed) - only deepest level has to be specified
223
+ * made auto_highlight feature configurable both on global and item_container's level
224
+ * config file is now evaluated in template if ever possible (not in controller anymore)
225
+
226
+ *1.4.2
227
+
228
+ * explicitly loading all source files when requiring 'simple_navigation'.
229
+
230
+ *1.4.0
231
+
232
+ * added the capability to have several navigation-contexts
233
+ * doc-fix
234
+
235
+ *1.3.1
236
+
237
+ * now compliant with ruby 1.9.1 (thanks to Gernot Kogler for the feedback)
238
+
239
+ *1.3.0
240
+
241
+ * render_all_levels-option allows to render all subnavigation independent from the active primary navigation ('full open tree'). Userful for javascript menus. Thanks to Richard Hulse.
242
+ * ability to turn off automatic generation of dom_ids for the list items (autogenerate_item_ids). Credits again to Richard Hulse.
243
+ * ability to specify dom_class for primary and secondary lists. Thanks Richard!
244
+
245
+ *1.2.2
246
+
247
+ * renderers now have access to request_forgery_protection stuff (this allows delete-links as navigation-items)
248
+
249
+ *1.2.1
250
+
251
+ * changed way to include render_*-helper_methods into view (including them into Controller and declaring them as helper_methods instead of adding whole module as Helper). this seems to be more reliable under certain conditions. Credits to Gernot Kogler.
252
+
253
+ *1.2.0
254
+
255
+ * added capability to add conditions to navigation-items (primary.item key, name, url, :if => Proc.new {current_user.admin?})
256
+
257
+ *1.1.2
258
+
259
+ * Bugfix: config now gets evaluated on every render_navigation call. Credits to Joël Azémar.
260
+ * Config file gets reloaded on every render_navigation call in development mode. Only load config file on server start in production mode.
261
+
262
+
263
+ *1.1.1
264
+
265
+ * Change plugin into a GemPlugin
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'activesupport', '>= 2.3.2'
4
+
5
+ # install the rails group if you want to ensure rails compatibility -
6
+ # but you've already got rails installed anyway, right? :-)
7
+ group :rails do
8
+ gem 'actionpack', '>= 2.3.2'
9
+ end
10
+
11
+ group :development do
12
+ gem 'rspec', '>= 2.0.1'
13
+ gem 'json_spec', '~> 1.1.1'
14
+ gem 'rake'
15
+ gem 'rdoc'
16
+ gem 'jeweler'
17
+ end
data/README ADDED
@@ -0,0 +1,22 @@
1
+
2
+ == Simple Navigation
3
+
4
+ Simple Navigation is a ruby library for creating navigations (with multiple levels) for your Rails 2, Rails 3, Sinatra or Padrino applications.
5
+
6
+ Source code:
7
+ git://github.com/andi/simple-navigation.git
8
+
9
+ Documentation:
10
+ http://wiki.github.com/andi/simple-navigation
11
+
12
+ RDoc:
13
+ Please checkout the repository and execute 'rake rdoc'.
14
+
15
+ Online Demo:
16
+ http://simple-navigation-demo.andischacke.com
17
+
18
+ Discussion Group for Feedback and Questions
19
+ http://groups.google.com/group/simple-navigation
20
+
21
+ Copyright (c) 2013 Andi Schacke, released under the MIT license
22
+
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ require 'rake'
2
+ require 'rspec/core/rake_task'
3
+ require 'rdoc/task'
4
+
5
+ desc 'Default: run specs.'
6
+ task :default => :spec
7
+
8
+ desc 'Run the specs'
9
+ RSpec::Core::RakeTask.new(:spec) do |t|
10
+ t.rspec_opts = ['--colour --format progress']
11
+ end
12
+
13
+ namespace :spec do
14
+ desc "Run all specs with RCov"
15
+ RSpec::Core::RakeTask.new(:rcov) do |t|
16
+ t.rspec_opts = ['--colour --format progress']
17
+ t.rcov = true
18
+ t.rcov_opts = ['--exclude', 'spec,/Users/']
19
+ end
20
+ end
21
+
22
+ desc 'Generate documentation for the simple_navigation plugin.'
23
+ RDoc::Task.new(:rdoc) do |rdoc|
24
+ rdoc.rdoc_dir = 'rdoc'
25
+ rdoc.title = 'SimpleNavigation'
26
+ rdoc.options << '--line-numbers' << '--inline-source'
27
+ rdoc.rdoc_files.include('README')
28
+ rdoc.rdoc_files.include('lib/**/*.rb')
29
+ end
30
+
31
+ begin
32
+ require 'jeweler'
33
+ Jeweler::Tasks.new do |gemspec|
34
+ gemspec.name = "simple-navigation"
35
+ gemspec.summary = "simple-navigation is a ruby library for creating navigations (with multiple levels) for your Rails2, Rails3, Sinatra or Padrino application."
36
+ gemspec.email = "andreas.schacke@gmail.com"
37
+ gemspec.homepage = "http://github.com/andi/simple-navigation"
38
+ gemspec.description = "With the simple-navigation gem installed you can easily create multilevel navigations for your Rails, Sinatra or Padrino applications. The navigation is defined in a single configuration file. It supports automatic as well as explicit highlighting of the currently active navigation through regular expressions."
39
+ gemspec.authors = ["Andi Schacke", "Mark J. Titorenko"]
40
+ gemspec.rdoc_options = ["--inline-source", "--charset=UTF-8"]
41
+ gemspec.files = FileList["[A-Z]*", "{lib,spec,rails,generators}/**/*"] - FileList["**/*.log", "Gemfile.lock"]
42
+ gemspec.rubyforge_project = 'andi'
43
+ end
44
+ Jeweler::GemcutterTasks.new
45
+ rescue LoadError => e
46
+ puts "Jeweler not available (#{e}). Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
47
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 3.11.0
@@ -0,0 +1 @@
1
+ Creates a template config file for the simple-navigation plugin. You will find the generated file in config/navigation.rb.
@@ -0,0 +1,8 @@
1
+ class NavigationConfigGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.file "config/navigation.rb", "config/navigation.rb"
5
+ m.readme "../../../README"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,76 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Configures your navigation
3
+ SimpleNavigation::Configuration.run do |navigation|
4
+ # Specify a custom renderer if needed.
5
+ # The default renderer is SimpleNavigation::Renderer::List which renders HTML lists.
6
+ # The renderer can also be specified as option in the render_navigation call.
7
+ # navigation.renderer = Your::Custom::Renderer
8
+
9
+ # Specify the class that will be applied to active navigation items. Defaults to 'selected'
10
+ # navigation.selected_class = 'your_selected_class'
11
+
12
+ # Specify the class that will be applied to the current leaf of
13
+ # active navigation items. Defaults to 'simple-navigation-active-leaf'
14
+ # navigation.active_leaf_class = 'your_active_leaf_class'
15
+
16
+ # Item keys are normally added to list items as id.
17
+ # This setting turns that off
18
+ # navigation.autogenerate_item_ids = false
19
+
20
+ # You can override the default logic that is used to autogenerate the item ids.
21
+ # To do this, define a Proc which takes the key of the current item as argument.
22
+ # The example below would add a prefix to each key.
23
+ # navigation.id_generator = Proc.new {|key| "my-prefix-#{key}"}
24
+
25
+ # If you need to add custom html around item names, you can define a proc that will be called with the name you pass in to the navigation.
26
+ # The example below shows how to wrap items spans.
27
+ # navigation.name_generator = Proc.new {|name| "<span>#{name}</span>"}
28
+
29
+ # The auto highlight feature is turned on by default.
30
+ # This turns it off globally (for the whole plugin)
31
+ # navigation.auto_highlight = false
32
+
33
+ # Define the primary navigation
34
+ navigation.items do |primary|
35
+ # Add an item to the primary navigation. The following params apply:
36
+ # key - a symbol which uniquely defines your navigation item in the scope of the primary_navigation
37
+ # name - will be displayed in the rendered navigation. This can also be a call to your I18n-framework.
38
+ # url - the address that the generated item links to. You can also use url_helpers (named routes, restful routes helper, url_for etc.)
39
+ # options - can be used to specify attributes that will be included in the rendered navigation item (e.g. id, class etc.)
40
+ # some special options that can be set:
41
+ # :if - Specifies a proc to call to determine if the item should
42
+ # be rendered (e.g. <tt>:if => Proc.new { current_user.admin? }</tt>). The
43
+ # proc should evaluate to a true or false value and is evaluated in the context of the view.
44
+ # :unless - Specifies a proc to call to determine if the item should not
45
+ # be rendered (e.g. <tt>:unless => Proc.new { current_user.admin? }</tt>). The
46
+ # proc should evaluate to a true or false value and is evaluated in the context of the view.
47
+ # :method - Specifies the http-method for the generated link - default is :get.
48
+ # :highlights_on - if autohighlighting is turned off and/or you want to explicitly specify
49
+ # when the item should be highlighted, you can set a regexp which is matched
50
+ # against the current URI. You may also use a proc, or the symbol <tt>:subpath</tt>.
51
+ #
52
+ primary.item :key_1, 'name', url, options
53
+
54
+ # Add an item which has a sub navigation (same params, but with block)
55
+ primary.item :key_2, 'name', url, options do |sub_nav|
56
+ # Add an item to the sub navigation (same params again)
57
+ sub_nav.item :key_2_1, 'name', url, options
58
+ end
59
+
60
+ # You can also specify a condition-proc that needs to be fullfilled to display an item.
61
+ # Conditions are part of the options. They are evaluated in the context of the views,
62
+ # thus you can use all the methods and vars you have available in the views.
63
+ primary.item :key_3, 'Admin', url, :class => 'special', :if => Proc.new { current_user.admin? }
64
+ primary.item :key_4, 'Account', url, :unless => Proc.new { logged_in? }
65
+
66
+ # you can also specify a css id or class to attach to this particular level
67
+ # works for all levels of the menu
68
+ # primary.dom_id = 'menu-id'
69
+ # primary.dom_class = 'menu-class'
70
+
71
+ # You can turn off auto highlighting for a specific level
72
+ # primary.auto_highlight = false
73
+
74
+ end
75
+
76
+ end