xebec 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +17 -13
- data/VERSION +1 -1
- data/doc/example_app/app/views/layouts/application.html.erb +20 -15
- data/doc/example_app/config/environment.rb +1 -0
- data/generators/xebec_stylesheet/templates/xebec.css.erb +35 -0
- data/generators/xebec_stylesheet/xebec_stylesheet_generator.rb +7 -0
- data/lib/xebec.rb +3 -2
- data/lib/xebec/html5.rb +63 -0
- data/lib/xebec/nav_bar_helper.rb +15 -0
- data/lib/xebec/nav_bar_proxy.rb +22 -7
- data/lib/xebec/stylesheet_generator.rb +45 -0
- data/test/html5_test.rb +78 -0
- data/test/nav_bar_proxy_test.rb +30 -14
- data/test/test_helper.rb +2 -0
- metadata +11 -4
data/README.md
CHANGED
@@ -45,8 +45,10 @@ Add this to your `ApplicationController`:
|
|
45
45
|
class ApplicationController < ActionController::Base
|
46
46
|
helper Xebec::NavBarHelper
|
47
47
|
end
|
48
|
+
|
49
|
+
### Building and Rendering Navigation Bars ###
|
48
50
|
|
49
|
-
|
51
|
+
#### Rendering a Navigation Bar ####
|
50
52
|
|
51
53
|
To render a navigation bar, render `nav_bar` in your view, passing the name of the bar:
|
52
54
|
|
@@ -62,7 +64,7 @@ If you only have one navigation bar on your site, you can leave off the name, li
|
|
62
64
|
|
63
65
|
Xebec will assign this navigation bar the name `:default` in case you need to refer to it elsewhere, but you probably won't.
|
64
66
|
|
65
|
-
|
67
|
+
#### Populating a Navigation Bar ####
|
66
68
|
|
67
69
|
To add items to your navigation bar in a view, call `nav_bar` with a block containing any number of `nav_item` calls:
|
68
70
|
|
@@ -73,23 +75,25 @@ To add items to your navigation bar in a view, call `nav_bar` with a block conta
|
|
73
75
|
end
|
74
76
|
%>
|
75
77
|
|
76
|
-
|
78
|
+
#### Setting the "Current" Element of a Navigation Bar ####
|
77
79
|
|
78
|
-
|
80
|
+
A navigation bar will automatically set an item as selected if its URL matches the current page URL. That will work for pages like "FAQ" above, but what if you want "Projects" to be highlighted not only for the projects list page but also for any page in the "Projects" area, such as an individual project's "Budget" tab? You can manually set the *current* item in a navigation bar like so:
|
79
81
|
|
80
|
-
|
81
|
-
ul.navbar li.current { color: purple; }
|
82
|
+
<% nav_bar(:area).current = :projects %>
|
82
83
|
|
83
|
-
|
84
|
+
### Styling Navigation Bars ###
|
84
85
|
|
85
|
-
|
86
|
-
ul.navbar.area { color: white; background-color: green; }
|
87
|
-
|
88
|
-
### Setting the "Current" Element of a Navigation Bar ###
|
86
|
+
Xebec provides a stylesheet generator to build you some reasonably sane default styles. Call it from the command line with a list of the names of your navigation bars:
|
89
87
|
|
90
|
-
|
88
|
+
script/generate xebec_stylesheet site area tabs footer
|
91
89
|
|
92
|
-
|
90
|
+
Then you'll have to add the `xebec` stylesheet to your layout:
|
91
|
+
|
92
|
+
<head>
|
93
|
+
<%= stylesheet_link_tag :xebec, :media => :screen %>
|
94
|
+
</head>
|
95
|
+
|
96
|
+
See `Xebec::StylesheetGenerator` for more information about how to customize the generated stylesheet.
|
93
97
|
|
94
98
|
### Example Application ###
|
95
99
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
@@ -1,15 +1,20 @@
|
|
1
|
-
<
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<%= add_html5_dom_elements_to_ie -%>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
<div id='header'>
|
7
|
+
<h1>My Site</h1>
|
8
|
+
<%= render :partial => '/layouts/site_nav_bar' %>
|
9
|
+
</div>
|
10
|
+
<%= nav_bar_unless_empty :area %>
|
11
|
+
<div id='content'>
|
12
|
+
<%= nav_bar_unless_empty :tabs %>
|
13
|
+
<%= yield %>
|
14
|
+
</div>
|
15
|
+
<div id='footer'>
|
16
|
+
© 2293 My Happy Company
|
17
|
+
<%= nav_bar :footer %>
|
18
|
+
</div>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
Xebec.html5_for_all_browsers!
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/*
|
2
|
+
Note the use of both <nav> and <div class='navbar'> elements.
|
3
|
+
<nav> is an HTML5 tag that browsers except IE suppor. By default,
|
4
|
+
Xebec will generate a <div class='navbar'> instead of a <nav>
|
5
|
+
element if it detects IE.
|
6
|
+
|
7
|
+
@see Xebec::HTML5 for more information
|
8
|
+
*/
|
9
|
+
|
10
|
+
nav, div.navbar {
|
11
|
+
background-color: white;
|
12
|
+
color: blue;
|
13
|
+
}
|
14
|
+
|
15
|
+
nav :hover, nav .current,
|
16
|
+
div.navbar :hover, div.navbar .current {
|
17
|
+
background-color: blue;
|
18
|
+
color: white;
|
19
|
+
}
|
20
|
+
|
21
|
+
<% navigation_bars.each do |bar| %>
|
22
|
+
nav.<%= bar -%>, div.navbar.<%= bar -%> {
|
23
|
+
/* styles specific to the <%= bar -%> navigation bar here */
|
24
|
+
}
|
25
|
+
|
26
|
+
nav.<%= bar -%> .current, div.navbar.<%= bar -%> .current {
|
27
|
+
/* styles specific to the currently-selected element in
|
28
|
+
the <%= bar -%> navigation bar here */
|
29
|
+
}
|
30
|
+
|
31
|
+
nav.<%= bar -%> :hover, div.navbar.<%= bar -%> :hover {
|
32
|
+
/* styles specific to a hovered-over element in
|
33
|
+
the <%= bar -%> navigation bar here */
|
34
|
+
}
|
35
|
+
<% end %>
|
data/lib/xebec.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Xebec
|
2
2
|
|
3
|
-
autoload :NavBarHelper,
|
4
|
-
autoload :ControllerSupport,
|
3
|
+
autoload :NavBarHelper, 'xebec/nav_bar_helper'
|
4
|
+
autoload :ControllerSupport, 'xebec/controller_support'
|
5
|
+
autoload :StylesheetGenerator, 'xebec/stylesheet_generator'
|
5
6
|
|
6
7
|
end
|
data/lib/xebec/html5.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
module Xebec
|
2
|
+
|
3
|
+
def self.html5_for_all_browsers!
|
4
|
+
Xebec::HTML5.force = true
|
5
|
+
end
|
6
|
+
|
7
|
+
# Xebec will help you transition your site to HTML 5
|
8
|
+
# by using the <tt><nav></tt> element like so:
|
9
|
+
#
|
10
|
+
# <nav class='my_navbar_name'>
|
11
|
+
# <ul>
|
12
|
+
# <li><a href='/home'>Home</a></li>
|
13
|
+
# ...
|
14
|
+
# </ul>
|
15
|
+
# </nav>
|
16
|
+
#
|
17
|
+
# Most browsers are perfectly happy with the <tt><nav></tt>
|
18
|
+
# element, but Internet Explorer (all current versions)
|
19
|
+
# behaves... *oddly*. Specifically, IE will treat the
|
20
|
+
# above HTML as though it were really this:
|
21
|
+
#
|
22
|
+
# <nav class='my_navbar_name'>
|
23
|
+
# </nav>
|
24
|
+
# <ul>
|
25
|
+
# <li><a href='/home'>Home</a></li>
|
26
|
+
# ...
|
27
|
+
# </ul>
|
28
|
+
#
|
29
|
+
# That, unfortunately messes with your CSS selectors. Xebec,
|
30
|
+
# therefore, has a slightly more intelligent default behavior.
|
31
|
+
# If it detects a browser that does not support HTML5 elements,
|
32
|
+
# it will replace the <tt><nav></tt> element with a
|
33
|
+
# <tt><div class='navbar'></tt>.
|
34
|
+
#
|
35
|
+
# Some enterprising folks have found a workaround for IE, however.
|
36
|
+
# If you *really* want to use the <tt><nav></tt> element for
|
37
|
+
# all browsers, do two things:
|
38
|
+
#
|
39
|
+
# 1. in config/environment.rb, call <tt>Xebec.html5_for_all_browsers!</tt>
|
40
|
+
#
|
41
|
+
# 2. in the <tt><head></tt> tag in your site layout,
|
42
|
+
# call <tt><%= add_html5_dom_elements_to_ie %></tt>
|
43
|
+
#
|
44
|
+
# @see Xebec.html5_for_all_browsers!
|
45
|
+
# @see Xebec::NavBarHelper.add_html5_dom_elements_to_ie
|
46
|
+
# See also the example application.
|
47
|
+
module HTML5
|
48
|
+
|
49
|
+
class <<self
|
50
|
+
attr_accessor :force
|
51
|
+
end
|
52
|
+
self.force = false
|
53
|
+
|
54
|
+
NON_HTML_5_USER_AGENTS = /msie/i
|
55
|
+
|
56
|
+
def user_agent_supports_html5?
|
57
|
+
return true if Xebec::HTML5.force
|
58
|
+
return !(NON_HTML_5_USER_AGENTS === request.user_agent)
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/lib/xebec/nav_bar_helper.rb
CHANGED
@@ -7,6 +7,7 @@ module Xebec
|
|
7
7
|
module NavBarHelper
|
8
8
|
|
9
9
|
include Xebec::HasNavBars
|
10
|
+
include Xebec::HTML5
|
10
11
|
|
11
12
|
# If called in an output expression ("<%= navbar %>" in ERB
|
12
13
|
# or "=navbar" in HAML), renders the navigation bar.
|
@@ -44,6 +45,20 @@ module Xebec
|
|
44
45
|
bar.empty? ? '' : bar
|
45
46
|
end
|
46
47
|
|
48
|
+
# Renders a <tt><script></tt> tag that preloads HTML5
|
49
|
+
# tags in IE. Useful if you called
|
50
|
+
# <tt>Xebec.html5_for_all_browsers!</tt> in your
|
51
|
+
# <tt>environment.rb</tt>.
|
52
|
+
#
|
53
|
+
# @see Xebec::HTML5
|
54
|
+
def add_html5_dom_elements_to_ie
|
55
|
+
return <<-EOS
|
56
|
+
<!--[if IE]>
|
57
|
+
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
58
|
+
<![endif]-->
|
59
|
+
EOS
|
60
|
+
end
|
61
|
+
|
47
62
|
protected
|
48
63
|
|
49
64
|
# Override HasNavBars#look_up_nav_bar to replace with a
|
data/lib/xebec/nav_bar_proxy.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'xebec/nav_bar'
|
2
|
+
require 'xebec/html5'
|
2
3
|
|
3
4
|
module Xebec
|
4
5
|
|
@@ -36,13 +37,15 @@ module Xebec
|
|
36
37
|
# defined, use that value
|
37
38
|
# * else, use <tt>nav_item.name.titleize</tt>
|
38
39
|
def to_s
|
39
|
-
|
40
|
+
root_element, options = *root_navbar_element
|
40
41
|
if bar.empty?
|
41
|
-
helper.tag(
|
42
|
+
helper.tag(root_element, options, false)
|
42
43
|
else
|
43
|
-
helper.content_tag
|
44
|
-
|
45
|
-
|
44
|
+
helper.content_tag(root_element, options) do
|
45
|
+
helper.content_tag :ul do
|
46
|
+
bar.items.map do |item|
|
47
|
+
render_nav_item item
|
48
|
+
end
|
46
49
|
end
|
47
50
|
end
|
48
51
|
end
|
@@ -66,6 +69,16 @@ module Xebec
|
|
66
69
|
|
67
70
|
attr_reader :bar, :helper
|
68
71
|
|
72
|
+
def root_navbar_element
|
73
|
+
klass = "#{bar.name}"
|
74
|
+
if helper.user_agent_supports_html5?
|
75
|
+
return :nav, { :class => klass }
|
76
|
+
else
|
77
|
+
klass << ' navbar'
|
78
|
+
return :div, { :class => klass }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
69
82
|
def render_nav_item(item)
|
70
83
|
text = text_for_nav_item item
|
71
84
|
href = href_for_nav_item item
|
@@ -76,7 +89,8 @@ module Xebec
|
|
76
89
|
end
|
77
90
|
|
78
91
|
def text_for_nav_item(item)
|
79
|
-
|
92
|
+
item_name = item.name
|
93
|
+
I18n.t "navbar.#{bar.name}.#{item_name}", :default => item_name.to_s.titleize
|
80
94
|
end
|
81
95
|
|
82
96
|
def href_for_nav_item(item)
|
@@ -84,7 +98,8 @@ module Xebec
|
|
84
98
|
end
|
85
99
|
|
86
100
|
def is_current_nav_item?(item, href)
|
87
|
-
|
101
|
+
current = bar.current
|
102
|
+
current == item.name || current.blank? && helper.current_page?(href)
|
88
103
|
end
|
89
104
|
|
90
105
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Xebec
|
2
|
+
|
3
|
+
# The `nav_bar` helper method will add the "current" class to the
|
4
|
+
# currently-selected item of each navigation bar. Highlighting the
|
5
|
+
# item requires just some basic CSS:
|
6
|
+
#
|
7
|
+
# nav { color: green; }
|
8
|
+
# nav .current { color: purple; }
|
9
|
+
#
|
10
|
+
# Each rendered navigation bar will include its name as a CSS class
|
11
|
+
# if you want to style them differently:
|
12
|
+
#
|
13
|
+
# nav.site { color: green; }
|
14
|
+
# nav.area { color: white; background-color: green; }
|
15
|
+
#
|
16
|
+
# (In case you were wondering about those `nav` elements, they're
|
17
|
+
# part of [the HTML5 specification](http://dev.w3.org/html5/spec/Overview.html#the-nav-element).
|
18
|
+
#
|
19
|
+
# @see Xebec::HTML5
|
20
|
+
class StylesheetGenerator < Rails::Generator::Base
|
21
|
+
|
22
|
+
def manifest
|
23
|
+
record do |m|
|
24
|
+
m.directory File.join('public', 'stylesheets')
|
25
|
+
m.template 'xebec.css.erb', File.join('public', 'stylesheets', 'xebec.css')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def after_generate
|
32
|
+
puts "Generated a stylesheet with navigation bars #{navigation_bars.to_sentence}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def navigation_bars
|
36
|
+
args
|
37
|
+
end
|
38
|
+
|
39
|
+
def banner
|
40
|
+
%{Usage: #{$0} #{spec.name} [nav_bar_name [nav_bar_name ...]]\nGenerates navigation bar stylesheets in public/stylesheets/}
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
data/test/html5_test.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
require 'xebec'
|
3
|
+
require 'xebec/html5'
|
4
|
+
|
5
|
+
class HTML5Test < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@helper = new_nav_bar_helper
|
9
|
+
end
|
10
|
+
|
11
|
+
def internet_explorer_8
|
12
|
+
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MDDC)'
|
13
|
+
end
|
14
|
+
|
15
|
+
def internet_explorer_7
|
16
|
+
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.1; MS-RTC LM 8)'
|
17
|
+
end
|
18
|
+
|
19
|
+
def firefox
|
20
|
+
'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.2pre) Gecko/20100225 Ubuntu/9.10 (karmic) Namoroka/3.6.2pre'
|
21
|
+
end
|
22
|
+
|
23
|
+
def safari
|
24
|
+
'Mozilla/5.0 (iPod; U; CPU iPhone OS 2_2_1 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5H11a Safari/525.20'
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'HTML5#user_agent_supports_html5?' do
|
28
|
+
setup { Xebec::HTML5.force = false }
|
29
|
+
|
30
|
+
context 'when Xebec::HTML5.force is false' do
|
31
|
+
should 'return false for Internet Explorer 8' do
|
32
|
+
@helper.request.user_agent = internet_explorer_8
|
33
|
+
assert !@helper.user_agent_supports_html5?
|
34
|
+
end
|
35
|
+
|
36
|
+
should 'return false for Internet Explorer 7' do
|
37
|
+
@helper.request.user_agent = internet_explorer_7
|
38
|
+
assert !@helper.user_agent_supports_html5?
|
39
|
+
end
|
40
|
+
|
41
|
+
should 'return true for Firefox' do
|
42
|
+
@helper.request.user_agent = firefox
|
43
|
+
assert @helper.user_agent_supports_html5?
|
44
|
+
end
|
45
|
+
|
46
|
+
should 'return true for Safari' do
|
47
|
+
@helper.request.user_agent = safari
|
48
|
+
assert @helper.user_agent_supports_html5?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when Xebec::HTML5.force is true' do
|
53
|
+
setup { Xebec::HTML5.force = true }
|
54
|
+
|
55
|
+
should 'return false for Internet Explorer 8' do
|
56
|
+
@helper.request.user_agent = internet_explorer_8
|
57
|
+
assert @helper.user_agent_supports_html5?
|
58
|
+
end
|
59
|
+
|
60
|
+
should 'return false for Internet Explorer 7' do
|
61
|
+
@helper.request.user_agent = internet_explorer_7
|
62
|
+
assert @helper.user_agent_supports_html5?
|
63
|
+
end
|
64
|
+
|
65
|
+
should 'return true for Firefox' do
|
66
|
+
@helper.request.user_agent = firefox
|
67
|
+
assert @helper.user_agent_supports_html5?
|
68
|
+
end
|
69
|
+
|
70
|
+
should 'return true for Safari' do
|
71
|
+
@helper.request.user_agent = safari
|
72
|
+
assert @helper.user_agent_supports_html5?
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
data/test/nav_bar_proxy_test.rb
CHANGED
@@ -37,16 +37,32 @@ class NavBarProxyTest < Test::Unit::TestCase
|
|
37
37
|
assert !@proxy.respond_to?(:cromulize)
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
context 'for a browser that supports HTML5' do
|
41
|
+
setup { @proxy.stubs(:user_agent_supports_html5?).returns(true) }
|
42
|
+
|
43
|
+
should "render a navigation bar with the bar's name" do
|
44
|
+
assert_select_from @proxy.to_s, "nav.elephants"
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with an empty NavBar' do
|
48
|
+
should 'render an empty navigation bar' do
|
49
|
+
assert_select_from @proxy.to_s, 'nav', /$^/
|
50
|
+
end
|
51
|
+
end
|
42
52
|
end
|
43
53
|
|
44
|
-
context '
|
45
|
-
|
46
|
-
|
47
|
-
|
54
|
+
context 'for a browser that does not support HTML5' do
|
55
|
+
setup { @helper.stubs(:user_agent_supports_html5?).returns(false) }
|
56
|
+
|
57
|
+
should "render a div.navbar the bar's name" do
|
58
|
+
assert_select_from @proxy.to_s, "div.navbar.elephants"
|
48
59
|
end
|
49
60
|
|
61
|
+
context 'with an empty NavBar' do
|
62
|
+
should 'render an empty navigation bar' do
|
63
|
+
assert_select_from @proxy.to_s, 'div.navbar', /$^/
|
64
|
+
end
|
65
|
+
end
|
50
66
|
end
|
51
67
|
|
52
68
|
context 'with a NavBar that has a navigation item declared as a name' do
|
@@ -55,7 +71,7 @@ class NavBarProxyTest < Test::Unit::TestCase
|
|
55
71
|
@bar.nav_item :foo
|
56
72
|
end
|
57
73
|
should 'render a navigation bar with the appropriate items' do
|
58
|
-
assert_select_from @proxy.to_s, 'ul
|
74
|
+
assert_select_from @proxy.to_s, 'ul' do
|
59
75
|
assert_select 'li' do
|
60
76
|
assert_select 'a[href="/foo"]', 'Foo'
|
61
77
|
end
|
@@ -69,7 +85,7 @@ class NavBarProxyTest < Test::Unit::TestCase
|
|
69
85
|
@bar.current = :foo
|
70
86
|
end
|
71
87
|
should 'render a navigation bar with the item marked as current' do
|
72
|
-
assert_select_from @proxy.to_s, 'ul
|
88
|
+
assert_select_from @proxy.to_s, 'ul' do
|
73
89
|
assert_select 'li.current', 'Foo'
|
74
90
|
end
|
75
91
|
end
|
@@ -81,7 +97,7 @@ class NavBarProxyTest < Test::Unit::TestCase
|
|
81
97
|
@bar.current = :baz
|
82
98
|
end
|
83
99
|
should 'render a navigation bar with the item not marked as current' do
|
84
|
-
assert_select_from @proxy.to_s, 'ul
|
100
|
+
assert_select_from @proxy.to_s, 'ul' do
|
85
101
|
assert_select 'li', 'Foo'
|
86
102
|
assert_select 'li.current', { :count => 0, :text=> 'Foo' }
|
87
103
|
end
|
@@ -96,7 +112,7 @@ class NavBarProxyTest < Test::Unit::TestCase
|
|
96
112
|
@bar.nav_item :foo, 'http://foo.com'
|
97
113
|
end
|
98
114
|
should 'render a navigation bar with the appropriate items' do
|
99
|
-
assert_select_from @proxy.to_s, 'ul
|
115
|
+
assert_select_from @proxy.to_s, 'ul' do
|
100
116
|
assert_select 'li' do
|
101
117
|
assert_select 'a[href="http://foo.com"]', 'Foo'
|
102
118
|
end
|
@@ -111,21 +127,21 @@ class NavBarProxyTest < Test::Unit::TestCase
|
|
111
127
|
@bar.nav_item :sign_up, '/sign_up'
|
112
128
|
end
|
113
129
|
should 'render a non-link navigation item' do
|
114
|
-
assert_select_from @proxy.to_s, 'ul
|
130
|
+
assert_select_from @proxy.to_s, 'ul' do
|
115
131
|
assert_select 'li', 'Home' do
|
116
132
|
assert_select 'a', 0
|
117
133
|
end
|
118
134
|
end
|
119
135
|
end
|
120
136
|
should 'render other items as links' do
|
121
|
-
assert_select_from @proxy.to_s, 'ul
|
137
|
+
assert_select_from @proxy.to_s, 'ul' do
|
122
138
|
assert_select 'li' do
|
123
139
|
assert_select 'a[href="/sign_up"]', 'Sign Up'
|
124
140
|
end
|
125
141
|
end
|
126
142
|
end
|
127
143
|
should 'add the "current" class to the current item' do
|
128
|
-
assert_select_from @proxy.to_s, 'ul
|
144
|
+
assert_select_from @proxy.to_s, 'ul' do
|
129
145
|
assert_select 'li.current', 'Home'
|
130
146
|
end
|
131
147
|
end
|
@@ -138,7 +154,7 @@ class NavBarProxyTest < Test::Unit::TestCase
|
|
138
154
|
@bar.nav_item :foo
|
139
155
|
end
|
140
156
|
should 'render a navigation bar using the internationalized text' do
|
141
|
-
assert_select_from @proxy.to_s, 'ul
|
157
|
+
assert_select_from @proxy.to_s, 'ul' do
|
142
158
|
assert_select 'li' do
|
143
159
|
assert_select 'a', 'My Foos'
|
144
160
|
end
|
data/test/test_helper.rb
CHANGED
@@ -7,6 +7,7 @@ require 'activesupport'
|
|
7
7
|
require 'actionpack'
|
8
8
|
require 'action_view'
|
9
9
|
require 'action_controller'
|
10
|
+
require 'action_controller/test_process'
|
10
11
|
|
11
12
|
begin
|
12
13
|
require 'redgreen/unicode'
|
@@ -32,6 +33,7 @@ Test::Unit::TestCase.class_eval do
|
|
32
33
|
def new_nav_bar_helper
|
33
34
|
ActionView::Base.new.tap do |helper|
|
34
35
|
helper.extend Xebec::NavBarHelper
|
36
|
+
helper.request = ActionController::TestRequest.new
|
35
37
|
helper.stubs(:current_page?).returns(false)
|
36
38
|
end
|
37
39
|
end
|
metadata
CHANGED
@@ -3,10 +3,10 @@ name: xebec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
|
-
-
|
7
|
-
- 3
|
6
|
+
- 2
|
8
7
|
- 0
|
9
|
-
|
8
|
+
- 0
|
9
|
+
version: 2.0.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- James A. Rosen
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-13 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -92,19 +92,25 @@ files:
|
|
92
92
|
- doc/example_app/app/views/projects/history.html.erb
|
93
93
|
- doc/example_app/app/views/projects/index.html.erb
|
94
94
|
- doc/example_app/app/views/projects/show.html.erb
|
95
|
+
- doc/example_app/config/environment.rb
|
95
96
|
- doc/example_app/config/locales/en.yml
|
96
97
|
- doc/example_app/config/routes.rb
|
98
|
+
- generators/xebec_stylesheet/templates/xebec.css.erb
|
99
|
+
- generators/xebec_stylesheet/xebec_stylesheet_generator.rb
|
97
100
|
- init.rb
|
98
101
|
- lib/xebec.rb
|
99
102
|
- lib/xebec/controller_support.rb
|
100
103
|
- lib/xebec/has_nav_bars.rb
|
104
|
+
- lib/xebec/html5.rb
|
101
105
|
- lib/xebec/nav_bar.rb
|
102
106
|
- lib/xebec/nav_bar_helper.rb
|
103
107
|
- lib/xebec/nav_bar_proxy.rb
|
104
108
|
- lib/xebec/nav_item.rb
|
109
|
+
- lib/xebec/stylesheet_generator.rb
|
105
110
|
- rails/init.rb
|
106
111
|
- tasks/README.md
|
107
112
|
- test/controller_support_test.rb
|
113
|
+
- test/html5_test.rb
|
108
114
|
- test/nav_bar_helper_test.rb
|
109
115
|
- test/nav_bar_proxy_test.rb
|
110
116
|
- test/nav_bar_test.rb
|
@@ -146,6 +152,7 @@ specification_version: 3
|
|
146
152
|
summary: Navigation helpers
|
147
153
|
test_files:
|
148
154
|
- test/controller_support_test.rb
|
155
|
+
- test/html5_test.rb
|
149
156
|
- test/nav_bar_helper_test.rb
|
150
157
|
- test/nav_bar_proxy_test.rb
|
151
158
|
- test/nav_bar_test.rb
|