simple-navigation 2.7.0 → 2.7.1
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.
- data/CHANGELOG +6 -2
- data/VERSION.yml +1 -1
- data/generators/navigation_config/templates/config/navigation.rb +1 -1
- data/lib/simple_navigation.rb +14 -0
- data/lib/simple_navigation/item.rb +1 -1
- data/lib/simple_navigation/item_container.rb +1 -1
- data/spec/lib/simple_navigation/item_spec.rb +1 -2
- data/spec/lib/simple_navigation_spec.rb +38 -0
- metadata +3 -3
data/CHANGELOG
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
+
*2.7.1
|
2
|
+
|
3
|
+
* added SimpleNavigation.request and SimpleNavigation.request_uri as abstraction for getting request_uri (rails2/rails3)
|
4
|
+
* use request.fullpath instead of request.request_uri for Rails3. Credits to Ben Langfeld.
|
5
|
+
|
1
6
|
*2.7.0
|
2
7
|
|
3
8
|
* 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.
|
4
9
|
* deprecated explicit highlighting in the controllers.
|
5
10
|
|
6
|
-
|
7
11
|
*2.6.0
|
8
12
|
|
9
13
|
* added rendering option 'skip_if_empty' to Renderer::List to avoid rendering of empty ul-tags
|
@@ -17,7 +21,7 @@
|
|
17
21
|
|
18
22
|
*2.5.3
|
19
23
|
|
20
|
-
* removed
|
24
|
+
* removed deprecated railtie_name from simple_navigation/railtie. Credits to Markus Schirp.
|
21
25
|
|
22
26
|
*2.5.2
|
23
27
|
|
data/VERSION.yml
CHANGED
@@ -35,7 +35,7 @@ SimpleNavigation::Configuration.run do |navigation|
|
|
35
35
|
# :unless - Specifies a proc to call to determine if the item should not
|
36
36
|
# be rendered (e.g. <tt>:unless => Proc.new { current_user.admin? }</tt>). The
|
37
37
|
# proc should evaluate to a true or false value and is evaluated in the context of the view.
|
38
|
-
# :method -
|
38
|
+
# :method - Specifies the http-method for the generated link - default is :get.
|
39
39
|
# :highlights_on - if autohighlighting is turned off and/or you want to explicitly specify
|
40
40
|
# when the item should be highlighted, you can set a regexp which is matched
|
41
41
|
# against the current URI.
|
data/lib/simple_navigation.rb
CHANGED
@@ -149,6 +149,20 @@ module SimpleNavigation
|
|
149
149
|
self.registered_renderers.merge!(renderer_hash)
|
150
150
|
end
|
151
151
|
|
152
|
+
# Returns the current request.
|
153
|
+
#
|
154
|
+
def request
|
155
|
+
SimpleNavigation.template.request if SimpleNavigation.template
|
156
|
+
end
|
157
|
+
|
158
|
+
# Returns the current request's URI.
|
159
|
+
#
|
160
|
+
def request_uri
|
161
|
+
return '' unless SimpleNavigation.request
|
162
|
+
return SimpleNavigation.request.fullpath if SimpleNavigation.request.respond_to?(:fullpath)
|
163
|
+
SimpleNavigation.request.request_uri
|
164
|
+
end
|
165
|
+
|
152
166
|
private
|
153
167
|
|
154
168
|
|
@@ -66,7 +66,7 @@ module SimpleNavigation
|
|
66
66
|
def selected_by_url?
|
67
67
|
if highlights_on
|
68
68
|
raise ArgumentError, ':highlights_on must be a regexp' unless highlights_on.instance_of?(Regexp)
|
69
|
-
SimpleNavigation.
|
69
|
+
SimpleNavigation.request_uri =~ highlights_on
|
70
70
|
elsif auto_highlight?
|
71
71
|
!!(root_path_match? || (SimpleNavigation.template && SimpleNavigation.template.current_page?(url)))
|
72
72
|
else
|
@@ -29,7 +29,7 @@ module SimpleNavigation
|
|
29
29
|
# * <tt>:unless</tt> - Specifies a proc to call to determine if the item should not
|
30
30
|
# be rendered (e.g. <tt>:unless => Proc.new { current_user.admin? }</tt>). The
|
31
31
|
# proc should evaluate to a true or false value and is evaluated in the context of the view.
|
32
|
-
# * <tt>:method</tt> -
|
32
|
+
# * <tt>:method</tt> - Specifies the http-method for the generated link - default is :get.
|
33
33
|
# * <tt>:highlights_on</tt> - if autohighlighting is turned off and/or you want to explicitly specify
|
34
34
|
# when the item should be highlighted, you can set a regexp which is matched againstthe current URI.
|
35
35
|
#
|
@@ -282,8 +282,7 @@ describe SimpleNavigation::Item do
|
|
282
282
|
context ':highlights_on option is set' do
|
283
283
|
before(:each) do
|
284
284
|
@item.stub!(:highlights_on => /^\/current/)
|
285
|
-
|
286
|
-
SimpleNavigation.stub!(:template => @template)
|
285
|
+
SimpleNavigation.stub!(:request_uri => '/current_url')
|
287
286
|
end
|
288
287
|
it "should not check for autohighlighting" do
|
289
288
|
@item.should_not_receive(:auto_highlight?)
|
@@ -325,6 +325,44 @@ describe SimpleNavigation do
|
|
325
325
|
end
|
326
326
|
end
|
327
327
|
|
328
|
+
describe 'request' do
|
329
|
+
context 'template is set' do
|
330
|
+
before(:each) do
|
331
|
+
@request = stub(:request)
|
332
|
+
SimpleNavigation.stub!(:template => stub(:template, :request => @request))
|
333
|
+
end
|
334
|
+
it {SimpleNavigation.request.should == @request}
|
335
|
+
end
|
336
|
+
context 'template is not set' do
|
337
|
+
it {SimpleNavigation.request.should be_nil}
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
describe 'request_uri' do
|
342
|
+
context 'request is set' do
|
343
|
+
context 'fullpath is defined on request' do
|
344
|
+
before(:each) do
|
345
|
+
@request = stub(:request, :fullpath => '/fullpath')
|
346
|
+
SimpleNavigation.stub!(:request => @request)
|
347
|
+
end
|
348
|
+
it {SimpleNavigation.request_uri.should == '/fullpath'}
|
349
|
+
end
|
350
|
+
context 'fullpath is not defined on request' do
|
351
|
+
before(:each) do
|
352
|
+
@request = stub(:request, :request_uri => '/request_uri')
|
353
|
+
SimpleNavigation.stub!(:request => @request)
|
354
|
+
end
|
355
|
+
it {SimpleNavigation.request_uri.should == '/request_uri'}
|
356
|
+
end
|
357
|
+
end
|
358
|
+
context 'request is not set' do
|
359
|
+
before(:each) do
|
360
|
+
SimpleNavigation.stub!(:request => nil)
|
361
|
+
end
|
362
|
+
it {SimpleNavigation.request_uri.should == ''}
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
328
366
|
describe 'config' do
|
329
367
|
it {SimpleNavigation.config.should == SimpleNavigation::Configuration.instance}
|
330
368
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 2.7.
|
8
|
+
- 1
|
9
|
+
version: 2.7.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Andi Schacke
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-08-12 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|