simple-navigation 3.13.0 → 4.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +10 -3
  5. data/CHANGELOG.md +420 -0
  6. data/Guardfile +4 -2
  7. data/LICENSE +1 -1
  8. data/README.md +30 -7
  9. data/Rakefile +25 -2
  10. data/gemfiles/.bundle/config +2 -0
  11. data/gemfiles/rails-3-2-stable.gemfile +11 -0
  12. data/gemfiles/rails-4-1-stable.gemfile +7 -0
  13. data/gemfiles/rails-4-2-stable.gemfile +7 -0
  14. data/generators/navigation_config/navigation_config_generator.rb +0 -1
  15. data/generators/navigation_config/templates/config/navigation.rb +18 -15
  16. data/lib/simple_navigation.rb +25 -42
  17. data/lib/simple_navigation/adapters/padrino.rb +2 -2
  18. data/lib/simple_navigation/adapters/rails.rb +1 -24
  19. data/lib/simple_navigation/adapters/sinatra.rb +2 -11
  20. data/lib/simple_navigation/config_file.rb +36 -0
  21. data/lib/simple_navigation/config_file_finder.rb +42 -0
  22. data/lib/simple_navigation/{core/configuration.rb → configuration.rb} +7 -1
  23. data/lib/simple_navigation/{rendering/helpers.rb → helpers.rb} +0 -4
  24. data/lib/simple_navigation/{core/item.rb → item.rb} +76 -83
  25. data/lib/simple_navigation/{core/item_adapter.rb → item_adapter.rb} +3 -17
  26. data/lib/simple_navigation/{core/item_container.rb → item_container.rb} +23 -14
  27. data/lib/simple_navigation/{core/items_provider.rb → items_provider.rb} +0 -0
  28. data/lib/simple_navigation/railtie.rb +7 -0
  29. data/lib/simple_navigation/renderer.rb +12 -0
  30. data/lib/simple_navigation/{rendering/renderer → renderer}/base.rb +1 -1
  31. data/lib/simple_navigation/{rendering/renderer → renderer}/breadcrumbs.rb +0 -0
  32. data/lib/simple_navigation/{rendering/renderer → renderer}/json.rb +2 -0
  33. data/lib/simple_navigation/{rendering/renderer → renderer}/links.rb +0 -0
  34. data/lib/simple_navigation/{rendering/renderer → renderer}/list.rb +0 -0
  35. data/lib/simple_navigation/{rendering/renderer → renderer}/text.rb +0 -0
  36. data/lib/simple_navigation/version.rb +1 -1
  37. data/simple-navigation.gemspec +6 -5
  38. data/spec/fake_app/config/navigation.rb +6 -0
  39. data/spec/fake_app/rails_app.rb +35 -0
  40. data/spec/initializers/coveralls.rb +3 -0
  41. data/spec/initializers/have_css_matcher.rb +8 -3
  42. data/spec/initializers/memfs.rb +7 -0
  43. data/spec/initializers/rails.rb +4 -0
  44. data/spec/initializers/rspec.rb +7 -0
  45. data/spec/integration/rendering_navigation_spec.rb +14 -0
  46. data/spec/{lib/simple_navigation → simple_navigation}/adapters/padrino_spec.rb +0 -2
  47. data/spec/{lib/simple_navigation → simple_navigation}/adapters/rails_spec.rb +43 -94
  48. data/spec/{lib/simple_navigation → simple_navigation}/adapters/sinatra_spec.rb +4 -6
  49. data/spec/simple_navigation/config_file_finder_spec.rb +50 -0
  50. data/spec/simple_navigation/config_file_spec.rb +25 -0
  51. data/spec/{lib/simple_navigation/core → simple_navigation}/configuration_spec.rb +29 -19
  52. data/spec/{lib/simple_navigation/rendering → simple_navigation}/helpers_spec.rb +10 -13
  53. data/spec/{lib/simple_navigation/core → simple_navigation}/item_adapter_spec.rb +14 -11
  54. data/spec/{lib/simple_navigation/core → simple_navigation}/item_container_spec.rb +130 -42
  55. data/spec/simple_navigation/item_spec.rb +475 -0
  56. data/spec/{lib/simple_navigation/core → simple_navigation}/items_provider_spec.rb +1 -3
  57. data/spec/{lib/simple_navigation/rendering → simple_navigation}/renderer/base_spec.rb +34 -36
  58. data/spec/{lib/simple_navigation/rendering → simple_navigation}/renderer/breadcrumbs_spec.rb +4 -7
  59. data/spec/{lib/simple_navigation/rendering → simple_navigation}/renderer/json_spec.rb +5 -11
  60. data/spec/{lib/simple_navigation/rendering → simple_navigation}/renderer/links_spec.rb +5 -8
  61. data/spec/{lib/simple_navigation/rendering → simple_navigation}/renderer/list_spec.rb +4 -7
  62. data/spec/{lib/simple_navigation/rendering → simple_navigation}/renderer/text_spec.rb +4 -7
  63. data/spec/simple_navigation_spec.rb +190 -0
  64. data/spec/spec_helper.rb +29 -35
  65. metadata +128 -113
  66. data/CHANGELOG +0 -288
  67. data/lib/simple_navigation/core.rb +0 -5
  68. data/lib/simple_navigation/rails_controller_methods.rb +0 -164
  69. data/lib/simple_navigation/rendering.rb +0 -12
  70. data/rails/init.rb +0 -1
  71. data/spec/lib/simple_navigation/core/item_spec.rb +0 -703
  72. data/spec/lib/simple_navigation/rails_controller_methods_spec.rb +0 -270
  73. data/spec/lib/simple_navigation_spec.rb +0 -300
data/CHANGELOG DELETED
@@ -1,288 +0,0 @@
1
- *3.13.0
2
-
3
- * consider_item_names_as_safe is now false by default. Removed deprecation warning
4
-
5
- *3.12.2
6
-
7
- * Fixing issue #154. Thanks to Simon Curtois.
8
-
9
- *3.12.1
10
-
11
- * bugfix (error in generator)
12
-
13
- *3.12.0
14
-
15
- * Relax hash constraint on item_adapter. Thanks to Ramon Tayag.
16
- * Fixed hidden special character in navigation template. Credits to Stef Lewandowski
17
- * Added full MIT license text. Thanks to Ben Armstrong.
18
- * Added license to gemspec. Thanks to Troy Thompson.
19
- * Allow defining other html attributes than :id and :class on menu container. Credits to Jacek Tomaszewski.
20
- * Added new config option "consider_item_names_as_safe". Thanks to Alexey Naumov.
21
- * Big cleanup of specs, removed jeweler in favor of the "bundler" way. Huge thank you to Simon Courtois.
22
- * Added more powerful name generator which yields the item itself in addition to the item's name. Credits to Simon Curtois.
23
-
24
- *3.11.0
25
-
26
- * Added Json renderer. Thanks to Alberto Avila.
27
-
28
- *3.10.1
29
-
30
- * Padrino adapter now returns "html_safe"d content_tag
31
-
32
- *3.10.0
33
-
34
- * Added ability to set selected_class on container level. Credits to Joost Hietbrink.
35
- * do not highlight items that are only partial matches. Thanks to Troy Thompson.
36
- * adding support for rails 4. Credits to Samer Masry.
37
-
38
- *3.9.0
39
-
40
- * Added ability to pass a block to render_navigation for configuring dynamic navigation items (instead of passing :items). Credits to Ronald Chan.
41
-
42
- *3.8.0
43
-
44
- * Changed the way the context is fetched. Fixes incompatibility with Gretel. Thanks to Ivan Kasatenko.
45
- * Added :join_with option to links renderer. Thanks to Stefan Melmuk.
46
- * Added :prefix option to breadcrumb renderer. Credits to Rodrigo Manhães.
47
- * Added :ordered option for allowing list renderer to render an <ol> rather than a <ul>.
48
- * 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.
49
-
50
- *3.7.0
51
-
52
- * Added new adapater for working with the Nanoc static site generation framework.
53
- * 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
54
- * Allow breadcrumbs to be provided with link id and classes by supplying :allow_classes_and_ids => true as an option
55
-
56
- *3.6.0
57
-
58
- * 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).
59
-
60
- *3.5.1
61
-
62
- * Fixed specs related to testing name_generator functionality - stub the name_generator method rather than calling it to ensure subsequent tests aren't affected.
63
-
64
- *3.5.0
65
-
66
- * Added (configurable) "simple-navigation-active-leaf" class to last selected element and elements that have :highlights_on return true. Thanks to Frank Schumacher (thenoseman).
67
-
68
- *3.4.2
69
-
70
- * Improve Gemfile dependencies with :development and :rails groups.
71
-
72
- *3.4.1
73
-
74
- * 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.
75
-
76
- *3.4.0
77
-
78
- * Added Gemfile for easier development with Bundler. Thanks to Josep Jaume.
79
- * 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.
80
-
81
- *3.3.4
82
-
83
- * 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.
84
-
85
- *3.3.3
86
-
87
- * Bugfix in Adapters::Sinatra#current_url? (compares unencoded URIs). Thanks to Matthew Gast.
88
-
89
- *3.3.2
90
-
91
- * The patch listed in 3.3.1 somehow did not make it into the gem... sorry. Re-releasing...
92
-
93
- *3.3.1
94
-
95
- * bugfix in sinatra adapter. Use Rack::Request#scheme instead of Rack::Request#protocol. Credits to Matthew Gast.
96
-
97
- *3.3.0
98
-
99
- * 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.)
100
- * 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)
101
- * isolate the apply_defaults and load_config private methods from ActionController mixin leakage by refactoring to module class instance methods
102
- * addition of test coverage for the added helpers within helpers_spec.rb
103
- * inclusion of new helpers within the rails adapter and minor refactoring to DRY up the helper_method invocations
104
- * addition of test coverage for the newly included helpers
105
- * Credits to Mark J. Titorenko for all the changes in this release! Thanks.
106
-
107
- *3.2.0
108
-
109
- * Added Renderer::Text for rendering selected navigation items without markup (useful for dynamic page titles). Credits to Tim Cowlishaw.
110
- * Added ability to add custom markup around item names specifying a name_generator in the config file. Thanks to Jack Dempsey.
111
-
112
- *3.1.1
113
-
114
- * Item#selected_by_url? now strips anchors from the item's url before comparing it with the current request's url. Credits to opengovernment.
115
-
116
- *3.1.0
117
-
118
- * added new helper method 'active_navigation_item_name' to render the name of the currently active item
119
-
120
- *3.0.2
121
-
122
- * dom_id and dom_class can now be set as option in the item's definition (useful for dynamic menu items).
123
-
124
- *3.0.1
125
-
126
- * allow controller instance variables named @template for rails3 apps. Credits to cmartyn.
127
- * 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.
128
- * upgraded to rspec 2.0.0
129
- * fixed cgi error in sinatra adapter. Credits to Jack Dempsey.
130
-
131
- *3.0.0
132
-
133
- * added ability to specify dynamic items using an array of hashes. Credits to Anshul Khandelwal for input and discussion.
134
- * 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.
135
-
136
- *3.0.0.beta2
137
-
138
- * moving code for initializing plugin in sinatra to separate gem
139
-
140
- *3.0.0.beta1
141
-
142
- * 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.
143
- * decoupling from Rails. Introducing the concept of adapters to work with several frameworks.
144
- * tested with Rails 3.0.0
145
- * adding support for Sinatra and Padrino frameworks.
146
- * cherry picking active_support stuff instead of requiring the whole bunch (tested with active_support >= 2.3.2 and 3.0.0)
147
- * created public sample project which includes demo for Rails2, Rails3, Sinatra and Padrino (will be available on github soon)
148
- * better src file organization (adapters/core/rendering folders)
149
-
150
- *2.7.3
151
-
152
- * initializing SimpleNavigation.config_file_path with empty array (was nil before). Allows for adding paths before gem has been initialized.
153
-
154
- *2.7.2
155
-
156
- * 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.
157
-
158
- *2.7.1
159
-
160
- * added SimpleNavigation.request and SimpleNavigation.request_uri as abstraction for getting request_uri (rails2/rails3)
161
- * use request.fullpath instead of request.request_uri for Rails3. Credits to Ben Langfeld.
162
-
163
- *2.7.0
164
-
165
- * 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.
166
- * deprecated explicit highlighting in the controllers.
167
-
168
- *2.6.0
169
-
170
- * added rendering option 'skip_if_empty' to Renderer::List to avoid rendering of empty ul-tags
171
- * added breadcrumbs renderer incl. specs. A big thanks to Markus Schirp.
172
- * added ability to register a renderer / specify your renderer as symbol in render_navigation
173
- * renderer can be specified in render_navigation. Credits to Andi Bade from Galaxy Cats.
174
-
175
- *2.5.4
176
-
177
- * bugfix: SimpleNavigation.config_file? without params does not check for _navigation.rb file anymore. Credits to Markus Schirp.
178
-
179
- *2.5.3
180
-
181
- * removed deprecated railtie_name from simple_navigation/railtie. Credits to Markus Schirp.
182
-
183
- *2.5.2
184
-
185
- * added Rails3 generator for navigation_config.rb. Thanks to Josep Jaume Rey.
186
-
187
- *2.5.1
188
-
189
- * set template correctly for Rails3 (brings auto highlighting to life again). Credits to Josep Jaume Rey.
190
-
191
- *2.5.0
192
-
193
- * added new renderer Renderer::Links to simply render the navigation as links inside a div.
194
- * also make item.name html_safe (in order you have html_code in the item's name). Thanks again, Johan Svensson.
195
-
196
- *2.4.2
197
-
198
- * Rails 3.0.0.beta2 compatibility
199
- * 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.
200
- * updated copyright
201
- * reduced visibility of 'sn_set_navigation' to protected
202
-
203
- *2.4.1
204
-
205
- * removing depencency to rails. It installs the newest rails, even if a matching version is present. why is that?
206
-
207
- *2.4.0
208
-
209
- * added Rails3 compatibility
210
- * added Jeweler::Gemcutter Tasks to Rakefile
211
-
212
- *2.2.3
213
-
214
- * changed error handling in config-file. Do not ignore errors in config-file anymore.
215
- * only load config-file if it is present. Needed when directly providing items in render_navigation.
216
-
217
- *2.2.2
218
-
219
- * added lib/simple-navigation.rb to allow 'require simple-navigation' or 'config.gem "simple-navigation"'
220
-
221
- *2.2.1
222
-
223
- * Corrected URL to API-Doc on rubyforge in README
224
-
225
- *2.2.0
226
-
227
- * Allow Ranges for :level option. Credits to Ying Tsen Hong.
228
- * 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.
229
- * Deprecated render_all_levels in config-file.
230
-
231
- *2.1.0
232
-
233
- * included Ben Marini's commit which allows individual id-generators. Thanks Ben!
234
- * added ability to specify navigation items through items_provider. This is useful for generating the navigation dynamically (e.g. from database)
235
- * items can now even be passed directly into render_navigation method.
236
-
237
- *2.0.1
238
-
239
- * fixed handling of a non-existent explicit navigation item for a navigation context
240
-
241
- *2.0.0
242
-
243
- * 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.
244
- * added ability to create multi-level navigations (not just limited to primary and secondary navigation). Thanks again to Jack Dempsey for the motivation ;-)
245
- * simplified the process to explicitly set the navigation in the controller (where needed) - only deepest level has to be specified
246
- * made auto_highlight feature configurable both on global and item_container's level
247
- * config file is now evaluated in template if ever possible (not in controller anymore)
248
-
249
- *1.4.2
250
-
251
- * explicitly loading all source files when requiring 'simple_navigation'.
252
-
253
- *1.4.0
254
-
255
- * added the capability to have several navigation-contexts
256
- * doc-fix
257
-
258
- *1.3.1
259
-
260
- * now compliant with ruby 1.9.1 (thanks to Gernot Kogler for the feedback)
261
-
262
- *1.3.0
263
-
264
- * 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.
265
- * ability to turn off automatic generation of dom_ids for the list items (autogenerate_item_ids). Credits again to Richard Hulse.
266
- * ability to specify dom_class for primary and secondary lists. Thanks Richard!
267
-
268
- *1.2.2
269
-
270
- * renderers now have access to request_forgery_protection stuff (this allows delete-links as navigation-items)
271
-
272
- *1.2.1
273
-
274
- * 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.
275
-
276
- *1.2.0
277
-
278
- * added capability to add conditions to navigation-items (primary.item key, name, url, :if => Proc.new {current_user.admin?})
279
-
280
- *1.1.2
281
-
282
- * Bugfix: config now gets evaluated on every render_navigation call. Credits to Joël Azémar.
283
- * Config file gets reloaded on every render_navigation call in development mode. Only load config file on server start in production mode.
284
-
285
-
286
- *1.1.1
287
-
288
- * Change plugin into a GemPlugin
@@ -1,5 +0,0 @@
1
- require 'simple_navigation/core/configuration'
2
- require 'simple_navigation/core/item_adapter'
3
- require 'simple_navigation/core/item'
4
- require 'simple_navigation/core/item_container'
5
- require 'simple_navigation/core/items_provider'
@@ -1,164 +0,0 @@
1
- module SimpleNavigation
2
- def self.explicit_navigation_args
3
- adapter.controller.instance_variable_get(:'@sn_current_navigation_args')
4
- end
5
-
6
- # Reads the current navigation for the specified level from the controller.
7
- # Returns nil if there is no current navigation set for level.
8
- def self.current_navigation_for(level)
9
- adapter.controller.instance_variable_get(:"@sn_current_navigation_#{level}")
10
- end
11
-
12
- # If any navigation has been explicitely set in the controller this method
13
- # evaluates the specified args set in the controller and sets the correct
14
- # instance variable in the controller.
15
- def self.handle_explicit_navigation
16
- return unless explicit_navigation_args
17
- level, navigation = parse_explicit_navigation_args
18
- navigation_level = :"@sn_current_navigation_#{level}"
19
- adapter.controller.instance_variable_set(navigation_level, navigation)
20
- end
21
-
22
- def self.parse_explicit_navigation_args
23
- args = if explicit_navigation_args.empty?
24
- [{}]
25
- else
26
- explicit_navigation_args
27
- end
28
- indexed_args = args_indexed_by_level(args)
29
- deepest = deepest_level_and_item(indexed_args)
30
-
31
- if deepest.first.zero?
32
- fail ArgumentError, 'Invalid level specified or item key not found'
33
- end
34
-
35
- deepest
36
- end
37
-
38
- private
39
-
40
- def self.deepest_level_and_item(navigation_args)
41
- navigation_args.map { |k, v| [k.to_s[/level_(\d)/, 1].to_i, v] }
42
- .max
43
- end
44
-
45
- def self.args_indexed_by_level(navigation_args)
46
- if navigation_args.first.is_a?(Hash)
47
- navigation_args.first
48
- elsif navigation_args.size == 1
49
- level = primary_navigation.level_for_item(navigation_args.first)
50
- level ? { :"level_#{level}" => navigation_args.first } : {}
51
- else
52
- navigation_args.each_with_index
53
- .with_object({}) do |(arg, i), h|
54
- h[:"level_#{i + 1}"] = arg
55
- end
56
- end
57
- end
58
-
59
- # Adds methods for explicitely setting the current 'active' navigation to
60
- # the controllers.
61
- # Since version 2.0.0 the simple_navigation plugin determines the active
62
- # navigation based on the current url by default (auto highlighting),
63
- # so explicitely defining the active navigation in the controllers is only
64
- # needed for edge cases where automatic highlighting does not work.
65
- #
66
- # On the controller class level, use the <tt>navigation</tt> method to set the
67
- # active navigation for all actions in the controller.
68
- # Let's assume that we have a primary navigation item :account which in turn
69
- # has a sub navigation item :settings.
70
- #
71
- # ==== Examples
72
- # class AccountController << ActionController
73
- # navigation :account
74
- # ...
75
- # end
76
- #
77
- # class AccountSettingsController << ActionController
78
- # navigation :settings
79
- # ...
80
- # end
81
- #
82
- # The first example sets the current primary navigation to :account for all
83
- # actions. No active sub_navigation.
84
- # The second example sets the current sub navigation to :settings and since
85
- # it is a child of :account the current primary navigation is set to :account.
86
- #
87
- # On the controller instance level, use the <tt>current_navigation</tt> method
88
- # to define the active navigation for a specific action.
89
- # The navigation item that is set in <tt>current_navigation</tt> overrides the
90
- # one defined on the controller class level (see <tt>navigation</tt> method).
91
- # Thus if you have an :account primary item with a :special
92
- # sub navigation item:
93
- #
94
- # ==== Example
95
- # class AccountController << ActionController
96
- # navigation :account
97
- #
98
- # def your_special_action
99
- # ...
100
- # current_navigation :special
101
- # end
102
- # end
103
- #
104
- # The code above still sets the active primary navigation to :account for all
105
- # actions, but sets the sub_navigation to :account -> :special for
106
- # 'your_special_action'.
107
- #
108
- # Note 1: As you can see above you just have to set the navigation item of
109
- # your 'deepest' navigation level as active and all its parents are
110
- # marked as active, too.
111
- #
112
- # Note 2: The specified symbols must match the keys for your navigation
113
- # items in your config/navigation.rb file.
114
- module ControllerMethods
115
- def self.included(base) #:nodoc:
116
- base.class_eval do
117
- extend ClassMethods
118
- include InstanceMethods
119
- end
120
- end
121
-
122
- module ClassMethods
123
- # Sets the active navigation for all actions in this controller.
124
- #
125
- # The specified symbol must match the keys for your navigation items
126
- # in your config/navigation.rb file.
127
- def navigation(*args)
128
- class_eval do
129
- define_method :sn_set_navigation do
130
- current_navigation(*args)
131
- end
132
- protected :sn_set_navigation
133
- before_filter :sn_set_navigation
134
- end
135
- end
136
- end
137
-
138
- module InstanceMethods
139
- # Sets the active navigation. Call this method in any action to override
140
- # the controller-wide active navigation specified by navigation.
141
- #
142
- # The specified symbol must match the keys for your navigation items in
143
- # your config/navigation.rb file.
144
- def current_navigation(*args)
145
- @sn_current_navigation_args = args
146
- end
147
- end
148
- end
149
-
150
- class Item
151
- def selected_by_config?
152
- key == SimpleNavigation.current_navigation_for(container.level)
153
- end
154
- end
155
-
156
- class ItemContainer
157
- def selected_item
158
- self[SimpleNavigation.current_navigation_for(level)] ||
159
- items.find(&:selected?)
160
- end
161
- end
162
- end
163
-
164
- ActionController::Base.send(:include, SimpleNavigation::ControllerMethods)