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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 517a3078bcdee06d396acd50e301c2d595316ebb
4
+ data.tar.gz: b4da0b90ffa1a1996a6ce0ad5af542ae586f3936
5
+ SHA512:
6
+ metadata.gz: a976b0a7c53937f03c25cad0fb84cc004a09e1d5f0f71a23e298cf5c03ed3ffb74600132c46d8eb78de5c1b4266f81f16f83e0b517278aa330cd2db7f64028fd
7
+ data.tar.gz: 7a2e60a09ae9126e6a97349e3fe6118744b316acf5d797bb7432ebed49f02b3d326048e788db962988d7dafb8f162d548388c41f25f56e2203d3d2f0f943e38d
data/.gitignore CHANGED
@@ -4,3 +4,6 @@ pkg
4
4
  coverage
5
5
  Gemfile.lock
6
6
  .rvmrc
7
+ capybara-*
8
+ gemfiles/*.lock
9
+ log
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --color
2
2
  --format=documentation
3
+ --require spec_helper
data/.travis.yml CHANGED
@@ -1,4 +1,11 @@
1
+ before_install:
2
+ - gem install bundler
3
+
1
4
  rvm:
2
- - 1.9.3
3
- - 2.0.0
4
- - 2.1.1
5
+ - 2.2.6
6
+ - 2.3.3
7
+
8
+ gemfile:
9
+ - gemfiles/rails-4-2-stable.gemfile
10
+ - gemfiles/rails-4-1-stable.gemfile
11
+ - gemfiles/rails-3-2-stable.gemfile
data/CHANGELOG.md ADDED
@@ -0,0 +1,420 @@
1
+ # Changelog
2
+
3
+ ## 4.0.5
4
+
5
+ * Fix #188 Blank url and highligh_on_subpath = true causes error. Credits to Tristan Harmer (gondalez) and Ilia Pozhilov (ilyapoz).
6
+
7
+ ## 4.0.4
8
+
9
+ * Fix #184 uninitialized constant Rails::Railtie (NameError). Credits to n-rodriguez.
10
+
11
+ ## 4.0.3
12
+
13
+ * Fix #180 Check URL before invoking current_page?
14
+
15
+ ## 4.0.2
16
+
17
+ * fixing current_page? when url is nil
18
+
19
+ ## 4.0.1
20
+
21
+ * fixed padrino adapter
22
+
23
+ ## 4.0.0
24
+
25
+ * added two new configuration options ignore_query_params_on_auto_highlight and ignore_anchors_on_auto_highlight
26
+ * Remove dependency on classic-style Sinatra applications and enable use with modular-style apps. Credits to Stefan Kolb.
27
+ * Item can now receive a block as `name`
28
+ * It's now possible to set a global `highlight_on_subpath` option instead of adding it to every item
29
+ * Creating an Item doesn't remove options anymore
30
+ * Creating an Item no longer changed its container, only adding it to a container
31
+ does
32
+ * `Item#autogenerate_item_ids?` has been removed
33
+ * `SN.config_file_name`, `SN.config_file` and `SN.config_file?` have been
34
+ removed
35
+ * `ConfigFileFinder` and `ConfigFile` handle the configuration logic
36
+ * File organization was been changed to reflect the Ruby namespacing
37
+
38
+ ## 3.13.0
39
+
40
+ * consider_item_names_as_safe is now false by default. Removed deprecation warning
41
+
42
+ ## 3.12.2
43
+
44
+ * Fixing issue #154. Thanks to Simon Curtois.
45
+
46
+ ## 3.12.1
47
+
48
+ * bugfix (error in generator)
49
+
50
+ ## 3.12.0
51
+
52
+ * Relax hash constraint on item_adapter. Thanks to Ramon Tayag.
53
+ * Fixed hidden special character in navigation template. Credits to Stef
54
+ Lewandowski
55
+ * Added full MIT license text. Thanks to Ben Armstrong.
56
+ * Added license to gemspec. Thanks to Troy Thompson.
57
+ * Allow defining other html attributes than :id and :class on menu container.
58
+ Credits to Jacek Tomaszewski.
59
+ * Added new config option "consider_item_names_as_safe". Thanks to Alexey
60
+ Naumov.
61
+ * Big cleanup of specs, removed jeweler in favor of the "bundler" way. Huge
62
+ thank you to Simon Courtois.
63
+ * Added more powerful name generator which yields the item itself in addition to
64
+ the item's name. Credits to Simon Curtois.
65
+
66
+ ## 3.11.0
67
+
68
+ * Added Json renderer. Thanks to Alberto Avila.
69
+
70
+ ## 3.10.1
71
+
72
+ * Padrino adapter now returns "html_safe"d content_tag
73
+
74
+ ## 3.10.0
75
+
76
+ * Added ability to set selected_class on container level. Credits to Joost
77
+ Hietbrink.
78
+ * do not highlight items that are only partial matches. Thanks to Troy Thompson.
79
+ * adding support for rails 4. Credits to Samer Masry.
80
+
81
+ ## 3.9.0
82
+
83
+ * Added ability to pass a block to render_navigation for configuring dynamic
84
+ navigation items (instead of passing :items). Credits to Ronald Chan.
85
+
86
+ ## 3.8.0
87
+
88
+ * Changed the way the context is fetched. Fixes incompatibility with Gretel.
89
+ Thanks to Ivan Kasatenko.
90
+ * Added :join_with option to links renderer. Thanks to Stefan Melmuk.
91
+ * Added :prefix option to breadcrumb renderer. Credits to Rodrigo Manhães.
92
+ * Added :ordered option for allowing list renderer to render an `<ol>` rather
93
+ than a `<ul>`.
94
+ * Sinatra adapter no longer renders attributes with nil values as attributes
95
+ with empty strings in the output, instead electing not to render the attribute
96
+ at all. Thanks to revdan for pointing this out.
97
+
98
+ ## 3.7.0
99
+
100
+ * Added new adapater for working with the Nanoc static site generation
101
+ framework.
102
+ * Fix issue #22 - last link in a breadcrumb trail may now be rendered as static
103
+ text insted by supplying :static_leaf => true as an option
104
+ * Allow breadcrumbs to be provided with link id and classes by supplying
105
+ `:allow_classes_and_ids => true` as an option
106
+
107
+ ## 3.6.0
108
+
109
+ * Added linkless items functionality - the `url` parameter is now optional,
110
+ items which aren't links will be rendered within a 'span' element rather than
111
+ an 'a' element. `options` remain optional (defaults to an empty Hash).
112
+ `options` may be provided without providing a `url` (detected by checking if
113
+ the `url` parameter is a Hash or otherwise).
114
+
115
+ ## 3.5.1
116
+
117
+ * Fixed specs related to testing name_generator functionality - stub the
118
+ name_generator method rather than calling it to ensure subsequent tests aren't
119
+ affected.
120
+
121
+ ## 3.5.0
122
+
123
+ * Added (configurable) "simple-navigation-active-leaf" class to last selected
124
+ element and elements that have :highlights_on return true. Thanks to Frank
125
+ Schumacher (thenoseman).
126
+
127
+ ## 3.4.2
128
+
129
+ * Improve Gemfile dependencies with :development and :rails groups.
130
+
131
+ ## 3.4.1
132
+
133
+ * Rerelease using ruby-1.8.7 rather than ruby-1.9.2 in order that the
134
+ rubygems.org gemspec is generated in a compatible fashion.
135
+
136
+ ## 3.4.0
137
+
138
+ * Added Gemfile for easier development with Bundler. Thanks to Josep Jaume.
139
+ * modified :highlights_on option to accept a :subpath option (as well as Proc
140
+ and Regexp forms). This can be used to automatically highlight an item even
141
+ for items within a subpath. Thanks to Josep Jaume.
142
+
143
+ ## 3.3.4
144
+
145
+ * modified :highlights_on option to accept a Proc (as well as the existing
146
+ Regexp form). This can be used to provide specific highlighting conditions
147
+ inline. Thanks to superlou for sparking the idea for the concept.
148
+
149
+ ## 3.3.3
150
+
151
+ * Bugfix in Adapters::Sinatra#current_url? (compares unencoded URIs). Thanks to
152
+ Matthew Gast.
153
+
154
+ ## 3.3.2
155
+
156
+ * The patch listed in 3.3.1 somehow did not make it into the gem... sorry.
157
+ Re-releasing...
158
+
159
+ ## 3.3.1
160
+
161
+ * bugfix in sinatra adapter. Use Rack::Request#scheme instead of
162
+ `Rack::Request#protocol`. Credits to Matthew Gast.
163
+
164
+ ## 3.3.0
165
+
166
+ * add a new method `active_navigation_item_key` which returns the symbol for the
167
+ currently selected navigation item in a similar way to
168
+ `active_navigation_item_name` does for the name (useful for CSS class styling
169
+ for eg.)
170
+ * open up the helper API to provide `active_navigation_item` and
171
+ `active_navigation_item_container` methods to make it easy to access the
172
+ items/containers should it be necessary (came for free with the above
173
+ refactoring)
174
+ * isolate the apply_defaults and load_config private methods from
175
+ `ActionController` mixin leakage by refactoring to module class instance
176
+ methods
177
+ * addition of test coverage for the added helpers within helpers_spec.rb
178
+ * inclusion of new helpers within the rails adapter and minor refactoring to DRY
179
+ up the helper_method invocations
180
+ * addition of test coverage for the newly included helpers
181
+ * Credits to Mark J. Titorenko for all the changes in this release! Thanks.
182
+
183
+ ## 3.2.0
184
+
185
+ * Added Renderer::Text for rendering selected navigation items without markup
186
+ (useful for dynamic page titles). Credits to Tim Cowlishaw.
187
+ * Added ability to add custom markup around item names specifying a
188
+ `name_generator` in the config file. Thanks to Jack Dempsey.
189
+
190
+ ## 3.1.1
191
+
192
+ * `Item#selected_by_url?` now strips anchors from the item's url before
193
+ comparing it with the current request's url. Credits to opengovernment.
194
+
195
+ ## 3.1.0
196
+
197
+ * added new helper method `active_navigation_item_name` to render the name of
198
+ the currently active item
199
+
200
+ ## 3.0.2
201
+
202
+ * `dom_id` and `dom_class` can now be set as option in the item's definition
203
+ (useful for dynamic menu items).
204
+
205
+ ## 3.0.1
206
+
207
+ * allow controller instance variables named @template for rails3 apps. Credits
208
+ to cmartyn.
209
+ * added possibility to specify and item's URL as a block which is evaulated
210
+ after the :if and :unless conditions have been checked. Credits to Nicholas
211
+ Firth-McCoy.
212
+ * upgraded to rspec 2.0.0
213
+ * fixed cgi error in sinatra adapter. Credits to Jack Dempsey.
214
+
215
+ ## 3.0.0
216
+
217
+ * added ability to specify dynamic items using an array of hashes. Credits to
218
+ Anshul Khandelwal for input and discussion.
219
+ * added ability to specify attributes for the generated link-tag in list
220
+ renderer (up to now the attributes have been applied to the li-tag). Credits
221
+ to Anthony Navarre for input and discussion.
222
+
223
+ ## 3.0.0.beta2
224
+
225
+ * moving code for initializing plugin in sinatra to separate gem
226
+
227
+ ## 3.0.0.beta1
228
+
229
+ * moving deprecated rails controller methods (navigation, current_navigation) to
230
+ separate file 'rails_controller_methods'. Deprecations removed. File can be
231
+ required explicitly if controller methods should be still available.
232
+ * decoupling from Rails. Introducing the concept of adapters to work with
233
+ several frameworks.
234
+ * tested with Rails 3.0.0
235
+ * adding support for Sinatra and Padrino frameworks.
236
+ * cherry picking active_support stuff instead of requiring the whole bunch
237
+ (tested with active_support >= 2.3.2 and 3.0.0)
238
+ * created public sample project which includes demo for Rails2, Rails3, Sinatra
239
+ and Padrino (will be available on github soon)
240
+ * better src file organization (adapters/core/rendering folders)
241
+
242
+ ## 2.7.3
243
+
244
+ * initializing SimpleNavigation.config_file_path with empty array (was `nil`
245
+ before). Allows for adding paths before gem has been initialized.
246
+
247
+ ## 2.7.2
248
+
249
+ * added ability to have more than one config_file_path (useful if
250
+ simple-navigation is used as a part of another gem/plugin). Credits to Luke
251
+ Imhoff.
252
+
253
+ ## 2.7.1
254
+
255
+ * added SimpleNavigation.request and SimpleNavigation.request_uri as abstraction
256
+ for getting request_uri (rails2/rails3)
257
+ * use request.fullpath instead of request.request_uri for Rails3. Credits to Ben
258
+ Langfeld.
259
+
260
+ ## 2.7.0
261
+
262
+ * added new option :highlights_on to item definition in config-file. Specify a
263
+ regexp which is matched against the current_uri to determine if an item is
264
+ active or not. Replaces explicit highlighting in controllers.
265
+ * deprecated explicit highlighting in the controllers.
266
+
267
+ ## 2.6.0
268
+
269
+ * added rendering option 'skip_if_empty' to Renderer::List to avoid rendering of
270
+ empty ul-tags
271
+ * added breadcrumbs renderer incl. specs. A big thanks to Markus Schirp.
272
+ * added ability to register a renderer / specify your renderer as symbol in
273
+ render_navigation
274
+ * renderer can be specified in render_navigation. Credits to Andi Bade from
275
+ Galaxy Cats.
276
+
277
+ ## 2.5.4
278
+
279
+ * bugfix: SimpleNavigation.config_file? without params does not check for
280
+ `_navigation.rb` file anymore. Credits to Markus Schirp.
281
+
282
+ ## 2.5.3
283
+
284
+ * removed deprecated railtie_name from simple_navigation/railtie. Credits to
285
+ Markus Schirp.
286
+
287
+ ## 2.5.2
288
+
289
+ * added Rails3 generator for navigation_config.rb. Thanks to Josep Jaume Rey.
290
+
291
+ ## 2.5.1
292
+
293
+ * set template correctly for Rails3 (brings auto highlighting to life again).
294
+ Credits to Josep Jaume Rey.
295
+
296
+ ## 2.5.0
297
+
298
+ * added new renderer Renderer::Links to simply render the navigation as links
299
+ inside a div.
300
+ * also make item.name html_safe (in order you have html_code in the item's
301
+ name). Thanks again, Johan Svensson.
302
+
303
+ ## 2.4.2
304
+
305
+ * Rails 3.0.0.beta2 compatibility
306
+ * Renderer::List --> make content of ul-tag html_safe for rails 3.0.0.beta2 (due
307
+ to rails3 XSS protection). Credits to Johan Svensson and Disha Albaqui.
308
+ * updated copyright
309
+ * reduced visibility of 'sn_set_navigation' to protected
310
+
311
+ ## 2.4.1
312
+
313
+ * removing depencency to rails. It installs the newest rails, even if a matching
314
+ version is present. why is that?
315
+
316
+ ## 2.4.0
317
+
318
+ * added Rails3 compatibility
319
+ * added Jeweler::Gemcutter Tasks to Rakefile
320
+
321
+ ## 2.2.3
322
+
323
+ * changed error handling in config-file. Do not ignore errors in config-file
324
+ anymore.
325
+ * only load config-file if it is present. Needed when directly providing items
326
+ in render_navigation.
327
+
328
+ ## 2.2.2
329
+
330
+ * added lib/simple-navigation.rb to allow 'require simple-navigation' or
331
+ 'config.gem "simple-navigation"'
332
+
333
+ ## 2.2.1
334
+
335
+ * Corrected URL to API-Doc on rubyforge in README
336
+
337
+ ## 2.2.0
338
+
339
+ * Allow Ranges for :level option. Credits to Ying Tsen Hong.
340
+ * Changing the API of `Helpers#render_navigation`. Now supports Ranges for
341
+ `:level` option and :expand_all to render all levels as expanded. Old Api is
342
+ still supported, but deprecated.
343
+ * Deprecated `render_all_levels` in config-file.
344
+
345
+ ## 2.1.0
346
+
347
+ * included Ben Marini's commit which allows individual id-generators.
348
+ Thanks Ben!
349
+ * added ability to specify navigation items through items_provider. This is
350
+ useful for generating the navigation dynamically (e.g. from database)
351
+ * items can now even be passed directly into render_navigation method.
352
+
353
+ ## 2.0.1
354
+
355
+ * fixed handling of a non-existent explicit navigation item for a navigation
356
+ context
357
+
358
+ ## 2.0.0
359
+
360
+ * added auto_highlight feature. Active navigation is determined by comparing
361
+ urls, no need to explicitly set it in the controllers anymore. Thanks to Jack
362
+ Dempsey and Florian Hanke for the support on this.
363
+ * added ability to create multi-level navigations (not just limited to primary
364
+ and secondary navigation). Thanks again to Jack Dempsey for the motivation ;-)
365
+ * simplified the process to explicitly set the navigation in the controller
366
+ (where needed) - only deepest level has to be specified
367
+ * made auto_highlight feature configurable both on global and item_container's
368
+ level
369
+ * config file is now evaluated in template if ever possible (not in controller
370
+ anymore)
371
+
372
+ ## 1.4.2
373
+
374
+ * explicitly loading all source files when requiring 'simple_navigation'.
375
+
376
+ ## 1.4.0
377
+
378
+ * added the capability to have several navigation-contexts
379
+ * doc-fix
380
+
381
+ ## 1.3.1
382
+
383
+ * now compliant with ruby 1.9.1 (thanks to Gernot Kogler for the feedback)
384
+
385
+ ## 1.3.0
386
+
387
+ * `render_all_levels` option allows to render all subnavigation independent from
388
+ the active primary navigation ('full open tree'). Userful for javascript
389
+ menus. Thanks to Richard Hulse.
390
+ * ability to turn off automatic generation of dom_ids for the list items
391
+ (autogenerate_item_ids). Credits again to Richard Hulse.
392
+ * ability to specify dom_class for primary and secondary lists. Thanks Richard!
393
+
394
+ ## 1.2.2
395
+
396
+ * renderers now have access to request_forgery_protection stuff (this allows
397
+ delete-links as navigation-items)
398
+
399
+ ## 1.2.1
400
+
401
+ * changed way to include render_*-helper_methods into view (including them into
402
+ Controller and declaring them as helper_methods instead of adding whole module
403
+ as Helper). this seems to be more reliable under certain conditions. Credits
404
+ to Gernot Kogler.
405
+
406
+ ## 1.2.0
407
+
408
+ * added capability to add conditions to navigation-items
409
+ (`primary.item key, name, url, :if => Proc.new {current_user.admin?}`)
410
+
411
+ ## 1.1.2
412
+
413
+ * Bugfix: config now gets evaluated on every render_navigation call. Credits to
414
+ Joël Azémar.
415
+ * Config file gets reloaded on every render_navigation call in development mode.
416
+ Only load config file on server start in production mode.
417
+
418
+ ## 1.1.1
419
+
420
+ * Change plugin into a GemPlugin