rails_bootstrap_navbar 0.1.5.beta → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -1
- data/README.md +18 -0
- data/lib/rails_bootstrap_navbar.rb +2 -3
- data/lib/rails_bootstrap_navbar/railtie.rb +17 -4
- data/lib/rails_bootstrap_navbar/version.rb +1 -1
- data/rails_bootstrap_navbar.gemspec +5 -3
- data/spec/spec_helper.rb +8 -1
- metadata +61 -28
- data/lib/rails_bootstrap_navbar/view_helpers.rb +0 -144
- data/spec/lib/rails_bootstrap_navbar/view_helpers_spec.rb +0 -302
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 08a294d3504e41c43dd27f4c183bf58243cd57f4
|
4
|
+
data.tar.gz: e82098543b1fb6913381ecd4b37b8492985f0774
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0f129dd18542a02ec490426e1e5ad535c984d5b510f842974478d0fd5409beb7c633ecf3c5ce089908df71e8d1c3bdd3b6ecf2e29bbcf9e2ff1e4642a138269c
|
7
|
+
data.tar.gz: 79bc00ac03b4848f3844c71ffcf4051e234f735ed5295dadcb85e3a0f8cd32feb64403bee035c549f0c4d8ca9a11d19716f95d0dd8fd42ad747712e4892878ad
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## v0.2.0
|
2
|
+
|
3
|
+
* Use gem 'bootstrap_navbar' for HTML rendering
|
4
|
+
|
1
5
|
## v0.1.0
|
2
6
|
|
3
7
|
* Initial release
|
@@ -26,4 +30,4 @@ These allow you to add dividers and headers into your dropdowns. Surprisingly en
|
|
26
30
|
## v0.1.5.beta
|
27
31
|
|
28
32
|
* Minor fix - make menu_item link default to "#"
|
29
|
-
* Readme updates
|
33
|
+
* Readme updates
|
data/README.md
CHANGED
@@ -90,6 +90,23 @@ To render:
|
|
90
90
|
</div>
|
91
91
|
</div>
|
92
92
|
|
93
|
+
### Static navbar
|
94
|
+
|
95
|
+
If you want a full-width navbar that scrolls away with the page, pass in the option like this:
|
96
|
+
|
97
|
+
````
|
98
|
+
<%= nav_bar :static => :top %>
|
99
|
+
````
|
100
|
+
|
101
|
+
To render:
|
102
|
+
|
103
|
+
<div class="navbar navbar-static-top">
|
104
|
+
<div class="navbar-inner">
|
105
|
+
<div class="container">
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
|
93
110
|
|
94
111
|
### Brand name
|
95
112
|
|
@@ -187,6 +204,7 @@ For multi-level list options, where it makes logical sense to group menu items,
|
|
187
204
|
<%= drop_down "Products" do %>
|
188
205
|
<%= menu_item "Latest", latest_products_path %>
|
189
206
|
<%= menu_item "Top Sellers", popular_products_path %>
|
207
|
+
<%= drop_down_divider %>
|
190
208
|
<%= menu_item "Discount Items", discounted_products_path %>
|
191
209
|
<% end %>
|
192
210
|
|
@@ -1,3 +1,2 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require 'rails_bootstrap_navbar/railtie' if defined?(Rails)
|
1
|
+
require 'rails_bootstrap_navbar/version'
|
2
|
+
require 'rails_bootstrap_navbar/railtie' if defined?(Rails)
|
@@ -1,8 +1,21 @@
|
|
1
|
-
require '
|
1
|
+
require 'bootstrap_navbar'
|
2
|
+
|
3
|
+
BootstrapNavbar.current_url_method = if Rails.version >= '3.2'
|
4
|
+
'request.original_url'
|
5
|
+
else
|
6
|
+
'[request.protocol, request.host_with_port, request.fullpath].join'
|
7
|
+
end
|
8
|
+
|
9
|
+
module BootstrapNavbar::Helpers
|
10
|
+
def prepare_html(html)
|
11
|
+
html.html_safe
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
2
15
|
module RailsBootstrapNavbar
|
3
16
|
class Railtie < Rails::Railtie
|
4
|
-
initializer
|
5
|
-
ActionView::Base.send :include,
|
17
|
+
initializer 'rails_bootstrap_navbar.view_helpers' do
|
18
|
+
ActionView::Base.send :include, BootstrapNavbar::Helpers
|
6
19
|
end
|
7
20
|
end
|
8
|
-
end
|
21
|
+
end
|
@@ -15,8 +15,10 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = RailsBootstrapNavbar::VERSION
|
17
17
|
|
18
|
-
gem.add_development_dependency
|
19
|
-
gem.add_development_dependency
|
18
|
+
gem.add_development_dependency 'rake', '>= 10.0.0'
|
19
|
+
gem.add_development_dependency 'rspec', '~> 2.13'
|
20
|
+
gem.add_development_dependency 'guard-rspec', '~> 3.0'
|
20
21
|
|
21
|
-
gem.add_runtime_dependency
|
22
|
+
gem.add_runtime_dependency 'bootstrap_navbar', '~> 0.0.10'
|
23
|
+
gem.add_runtime_dependency 'rails', '>= 3.0.0'
|
22
24
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1 +1,8 @@
|
|
1
|
-
require 'rails_bootstrap_navbar'
|
1
|
+
require 'rails_bootstrap_navbar'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
5
|
+
config.run_all_when_everything_filtered = true
|
6
|
+
config.filter_run :focus
|
7
|
+
config.order = 'random'
|
8
|
+
end
|
metadata
CHANGED
@@ -1,49 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_bootstrap_navbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease: 6
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jules Copeland
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-07-21 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 10.0.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 10.0.0
|
14
27
|
- !ruby/object:Gem::Dependency
|
15
28
|
name: rspec
|
16
|
-
requirement:
|
17
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
18
30
|
requirements:
|
19
|
-
- -
|
31
|
+
- - ~>
|
20
32
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
33
|
+
version: '2.13'
|
22
34
|
type: :development
|
23
35
|
prerelease: false
|
24
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.13'
|
25
41
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement:
|
28
|
-
none: false
|
42
|
+
name: guard-rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
29
44
|
requirements:
|
30
|
-
- -
|
45
|
+
- - ~>
|
31
46
|
- !ruby/object:Gem::Version
|
32
|
-
version: '0'
|
47
|
+
version: '3.0'
|
33
48
|
type: :development
|
34
49
|
prerelease: false
|
35
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bootstrap_navbar
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.0.10
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.0.10
|
36
69
|
- !ruby/object:Gem::Dependency
|
37
70
|
name: rails
|
38
|
-
requirement:
|
39
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
40
72
|
requirements:
|
41
|
-
- -
|
73
|
+
- - '>='
|
42
74
|
- !ruby/object:Gem::Version
|
43
75
|
version: 3.0.0
|
44
76
|
type: :runtime
|
45
77
|
prerelease: false
|
46
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.0.0
|
47
83
|
description: A helper method for easy generation of Twitter Bootstrap Navigation menus
|
48
84
|
in Rails
|
49
85
|
email:
|
@@ -63,34 +99,31 @@ files:
|
|
63
99
|
- lib/rails_bootstrap_navbar.rb
|
64
100
|
- lib/rails_bootstrap_navbar/railtie.rb
|
65
101
|
- lib/rails_bootstrap_navbar/version.rb
|
66
|
-
- lib/rails_bootstrap_navbar/view_helpers.rb
|
67
102
|
- rails_bootstrap_navbar.gemspec
|
68
|
-
- spec/lib/rails_bootstrap_navbar/view_helpers_spec.rb
|
69
103
|
- spec/spec_helper.rb
|
70
104
|
homepage: ''
|
71
105
|
licenses: []
|
106
|
+
metadata: {}
|
72
107
|
post_install_message:
|
73
108
|
rdoc_options: []
|
74
109
|
require_paths:
|
75
110
|
- lib
|
76
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
112
|
requirements:
|
79
|
-
- -
|
113
|
+
- - '>='
|
80
114
|
- !ruby/object:Gem::Version
|
81
115
|
version: '0'
|
82
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
117
|
requirements:
|
85
|
-
- -
|
118
|
+
- - '>='
|
86
119
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
120
|
+
version: '0'
|
88
121
|
requirements: []
|
89
122
|
rubyforge_project:
|
90
|
-
rubygems_version:
|
123
|
+
rubygems_version: 2.0.2
|
91
124
|
signing_key:
|
92
|
-
specification_version:
|
125
|
+
specification_version: 4
|
93
126
|
summary: Generate Bootstrap Navbars in Rails views
|
94
127
|
test_files:
|
95
|
-
- spec/lib/rails_bootstrap_navbar/view_helpers_spec.rb
|
96
128
|
- spec/spec_helper.rb
|
129
|
+
has_rdoc:
|
@@ -1,144 +0,0 @@
|
|
1
|
-
require "rails_bootstrap_navbar/version"
|
2
|
-
|
3
|
-
module RailsBootstrapNavbar
|
4
|
-
module ViewHelpers
|
5
|
-
|
6
|
-
def nav_bar(options={}, &block)
|
7
|
-
nav_bar_div(options[:fixed]) do
|
8
|
-
navbar_inner_div do
|
9
|
-
container_div(options[:brand], options[:brand_link], options[:responsive], options[:fluid]) do
|
10
|
-
yield if block_given?
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def menu_group(options={}, &block)
|
17
|
-
pull_class = " pull-#{options[:pull].to_s}" if options[:pull].present?
|
18
|
-
content_tag(:ul, :class => "nav#{pull_class}", &block)
|
19
|
-
end
|
20
|
-
|
21
|
-
def menu_item(name, path="#", *args)
|
22
|
-
options = args.extract_options!
|
23
|
-
content_tag :li, :class => is_active?(path) do
|
24
|
-
link_to name, path, options
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def drop_down(name)
|
29
|
-
content_tag :li, :class => "dropdown" do
|
30
|
-
drop_down_link(name) + drop_down_list {yield}
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def drop_down_divider
|
35
|
-
content_tag :li, "", :class => "divider"
|
36
|
-
end
|
37
|
-
|
38
|
-
def drop_down_header(text)
|
39
|
-
content_tag :li, text, :class => "nav-header"
|
40
|
-
end
|
41
|
-
|
42
|
-
def menu_divider
|
43
|
-
content_tag :li, "", :class => "divider-vertical"
|
44
|
-
end
|
45
|
-
|
46
|
-
def menu_text(text=nil, options={}, &block)
|
47
|
-
pull = options.delete(:pull)
|
48
|
-
pull_class = pull.present? ? "pull-#{pull.to_s}" : nil
|
49
|
-
options.append_merge!(:class, pull_class)
|
50
|
-
options.append_merge!(:class, "navbar-text")
|
51
|
-
content_tag :p, options do
|
52
|
-
text || yield
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def nav_bar_div(fixed, &block)
|
59
|
-
content_tag :div, :class => nav_bar_css_class(fixed) do
|
60
|
-
yield
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def navbar_inner_div(&block)
|
65
|
-
content_tag :div, :class => "navbar-inner" do
|
66
|
-
yield
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def container_div(brand, brand_link, responsive, fluid, &block)
|
71
|
-
content_tag :div, :class => "container#{"-fluid" if fluid}" do
|
72
|
-
container_div_with_block(brand, brand_link, responsive, &block)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def container_div_with_block(brand, brand_link, responsive, &block)
|
77
|
-
output = []
|
78
|
-
if responsive == true
|
79
|
-
output << responsive_button
|
80
|
-
output << brand_link(brand, brand_link)
|
81
|
-
output << responsive_div {capture(&block)}
|
82
|
-
else
|
83
|
-
output << brand_link(brand, brand_link)
|
84
|
-
output << capture(&block)
|
85
|
-
end
|
86
|
-
output.join("\n").html_safe
|
87
|
-
end
|
88
|
-
|
89
|
-
def nav_bar_css_class(fixed_pos)
|
90
|
-
css_class = ["navbar"]
|
91
|
-
css_class << "navbar-fixed-#{fixed_pos.to_s}" if fixed_pos.present?
|
92
|
-
css_class.join(" ")
|
93
|
-
end
|
94
|
-
|
95
|
-
def brand_link(name, url)
|
96
|
-
return "" if name.blank?
|
97
|
-
url ||= root_url
|
98
|
-
link_to(name, url, :class => "brand")
|
99
|
-
end
|
100
|
-
|
101
|
-
def responsive_button
|
102
|
-
%{<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
103
|
-
<span class="icon-bar"></span>
|
104
|
-
<span class="icon-bar"></span>
|
105
|
-
<span class="icon-bar"></span>
|
106
|
-
</a>}
|
107
|
-
end
|
108
|
-
|
109
|
-
def responsive_div(&block)
|
110
|
-
content_tag(:div, :class => "nav-collapse", &block)
|
111
|
-
end
|
112
|
-
|
113
|
-
def is_active?(path)
|
114
|
-
"active" if current_page?(path)
|
115
|
-
end
|
116
|
-
|
117
|
-
def name_and_caret(name)
|
118
|
-
"#{name} #{content_tag(:b, :class => "caret"){}}".html_safe
|
119
|
-
end
|
120
|
-
|
121
|
-
def drop_down_link(name)
|
122
|
-
link_to(name_and_caret(name), "#", :class => "dropdown-toggle", "data-toggle" => "dropdown")
|
123
|
-
end
|
124
|
-
|
125
|
-
def drop_down_list(&block)
|
126
|
-
content_tag :ul, :class => "dropdown-menu", &block
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
class Hash
|
132
|
-
# appends a string to a hash key's value after a space character (Good for merging CSS classes in options hashes)
|
133
|
-
def append_merge!(key, value)
|
134
|
-
# just return self if value is blank
|
135
|
-
return self if value.blank?
|
136
|
-
|
137
|
-
current_value = self[key]
|
138
|
-
# just merge if it doesn't already have that key
|
139
|
-
self[key] = value and return if current_value.blank?
|
140
|
-
# raise error if we're trying to merge into something that isn't a string
|
141
|
-
raise ArgumentError, "Can only merge strings" unless current_value.is_a?(String)
|
142
|
-
self[key] = [current_value, value].compact.join(" ")
|
143
|
-
end
|
144
|
-
end
|
@@ -1,302 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'action_view'
|
4
|
-
require 'active_support'
|
5
|
-
|
6
|
-
include RailsBootstrapNavbar::ViewHelpers
|
7
|
-
include ActionView::Helpers
|
8
|
-
include ActionView::Context
|
9
|
-
|
10
|
-
describe RailsBootstrapNavbar::ViewHelpers, :type => :helper do
|
11
|
-
before do
|
12
|
-
self.stub!("current_page?").and_return(false)
|
13
|
-
self.stub!("root_url").and_return("/")
|
14
|
-
end
|
15
|
-
describe "nav_bar" do
|
16
|
-
it "should return a basic bootstrap navbar" do
|
17
|
-
nav_bar.gsub(/\s/,'').downcase.should eql(BASIC_NAVBAR.gsub(/\s/,'').downcase)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should set the fixed position to top" do
|
21
|
-
nav_bar(:fixed => :top).gsub(/\s/,'').downcase.should eql(FIXED_TOP_NAVBAR.gsub(/\s/,'').downcase)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should set the fixed position to bottom" do
|
25
|
-
nav_bar(:fixed => :bottom).gsub(/\s/,'').downcase.should eql(FIXED_BOTTOM_NAVBAR.gsub(/\s/,'').downcase)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should add the brand name and link it to the home page" do
|
29
|
-
nav_bar(:brand => "Ninety Ten").gsub(/\s/,'').downcase.should eql(NAVBAR_WITH_BRAND.gsub(/\s/,'').downcase)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should be able to set the brand link url" do
|
33
|
-
nav_bar(:brand => "Ninety Ten", :brand_link => "http://www.ninetyten.com").gsub(/\s/,'').downcase.should eql(
|
34
|
-
NAVBAR_WITH_BRAND_AND_LINK.gsub(/\s/,'').downcase)
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should set the container to fluid" do
|
38
|
-
nav_bar(:fluid => :true).gsub(/\s/,'').downcase.should eql(BASIC_NAVBAR_FLUID.gsub(/\s/,'').downcase)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should add the buttons etc for a responsive layout with no block passed" do
|
42
|
-
nav_bar(:responsive => true).gsub(/\s/,'').downcase.should eql(RESPONSIVE_NAVBAR.gsub(/\s/,'').downcase)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should add the buttons etc for a responsive layout with block passed" do
|
46
|
-
nav_bar(:responsive => true) do
|
47
|
-
"<p>Passing a block</p>".html_safe
|
48
|
-
end.gsub(/\s/,'').downcase.should eql(RESPONSIVE_NAVBAR_WITH_BLOCK.gsub(/\s/,'').downcase)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should render contained items" do
|
52
|
-
nav_bar do
|
53
|
-
menu_group do
|
54
|
-
menu_item("Home", "/") + menu_item("Products", "/products")
|
55
|
-
end
|
56
|
-
end.gsub(/\s/,'').downcase.should eql(PLAIN_NAVBAR_WITH_ITEM.gsub(/\s/,'').downcase)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should still render the brand name even with other options turned on" do
|
60
|
-
nav_bar(:brand => "Something") do
|
61
|
-
menu_group do
|
62
|
-
menu_item "Home", "/"
|
63
|
-
end
|
64
|
-
end.gsub(/\s/,'').downcase.should eql(BRANDED_NAVBAR_WITH_ITEM.gsub(/\s/,'').downcase)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "menu_group" do
|
69
|
-
it "should return a ul with the class 'nav'" do
|
70
|
-
menu_group do
|
71
|
-
menu_item("Home", "/") + menu_item("Products", "/products")
|
72
|
-
end.should eql '<ul class="nav"><li><a href="/">Home</a></li><li><a href="/products">Products</a></li></ul>'
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should return a ul with class .pull-left when passed the {:pull => :left} option" do
|
76
|
-
menu_group(:pull => :left) do
|
77
|
-
menu_item("Home", "/")
|
78
|
-
end.should eql('<ul class="nav pull-left"><li><a href="/">Home</a></li></ul>')
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe "menu_item" do
|
83
|
-
it "should return a link within an li tag" do
|
84
|
-
self.stub!("current_page?").and_return(false)
|
85
|
-
menu_item("Home", "/").should eql('<li><a href="/">Home</a></li>')
|
86
|
-
end
|
87
|
-
it "should return the link with class 'active' if on current page" do
|
88
|
-
self.stub!("current_page?").and_return(true)
|
89
|
-
menu_item("Home", "/").should eql('<li class="active"><a href="/">Home</a></li>')
|
90
|
-
end
|
91
|
-
it "should pass any other options through to the link_to method" do
|
92
|
-
self.stub!("current_page?").and_return(true)
|
93
|
-
menu_item("Log out", "/users/sign_out", :class => "home_link", :method => :delete).should eql(
|
94
|
-
'<li class="active"><a href="/users/sign_out" class="home_link" data-method="delete" rel="nofollow">Log out</a></li>')
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe "drop_down" do
|
99
|
-
it "should do render the proper drop down code" do
|
100
|
-
drop_down "Products" do
|
101
|
-
menu_item "Latest", "/"
|
102
|
-
end.gsub(/\s/,'').downcase.should eql(DROPDOWN_MENU.gsub(/\s/,'').downcase)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "menu_divider" do
|
107
|
-
it "should render <li class='divider-vertical'></li>" do
|
108
|
-
menu_divider.should eql '<li class="divider-vertical"></li>'
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe "menu_text" do
|
113
|
-
it "should render text within p tags with class 'navbar-text" do
|
114
|
-
menu_text("Strapline!").should eql("<p class=\"navbar-text\">Strapline!</p>")
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should be able to be pulled right or left" do
|
118
|
-
menu_text("I'm being pulled right", :pull => :right).should eql(
|
119
|
-
"<p class=\"pull-right navbar-text\">I'm being pulled right</p>")
|
120
|
-
end
|
121
|
-
|
122
|
-
it "should be able to cope with arbitrary options being passed to the p tag" do
|
123
|
-
menu_text("I'm classy!", :class => "classy", :id => "classy_text").should eql(
|
124
|
-
"<p class=\"classy navbar-text\" id=\"classy_text\">I'm classy!</p>")
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should be able to cope with a block too" do
|
128
|
-
menu_text do
|
129
|
-
"I've been rendered programmatically!"
|
130
|
-
end.should eql("<p class=\"navbar-text\">I've been rendered programmatically!</p>")
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe "rendering forms ok" do
|
135
|
-
it "should not escape anything unexpectedly" do
|
136
|
-
nav_bar do
|
137
|
-
form_tag "/", :method => 'get' do |f|
|
138
|
-
f.text_field :search, "stub"
|
139
|
-
end
|
140
|
-
end.gsub(/\s/,'').downcase.should eql(PLAIN_NAVBAR_WITH_FORM.gsub(/\s/,'').downcase)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
145
|
-
|
146
|
-
# HTML output
|
147
|
-
|
148
|
-
BASIC_NAVBAR = <<-HTML
|
149
|
-
<div class="navbar">
|
150
|
-
<div class="navbar-inner">
|
151
|
-
<div class="container">
|
152
|
-
</div>
|
153
|
-
</div>
|
154
|
-
</div>
|
155
|
-
HTML
|
156
|
-
|
157
|
-
FIXED_TOP_NAVBAR = <<-HTML
|
158
|
-
<div class="navbar navbar-fixed-top">
|
159
|
-
<div class="navbar-inner">
|
160
|
-
<div class="container">
|
161
|
-
</div>
|
162
|
-
</div>
|
163
|
-
</div>
|
164
|
-
HTML
|
165
|
-
|
166
|
-
FIXED_BOTTOM_NAVBAR = <<-HTML
|
167
|
-
<div class="navbar navbar-fixed-bottom">
|
168
|
-
<div class="navbar-inner">
|
169
|
-
<div class="container">
|
170
|
-
</div>
|
171
|
-
</div>
|
172
|
-
</div>
|
173
|
-
HTML
|
174
|
-
|
175
|
-
BASIC_NAVBAR_FLUID= <<-HTML
|
176
|
-
<div class="navbar">
|
177
|
-
<div class="navbar-inner">
|
178
|
-
<div class="container-fluid">
|
179
|
-
</div>
|
180
|
-
</div>
|
181
|
-
</div>
|
182
|
-
HTML
|
183
|
-
|
184
|
-
NAVBAR_WITH_BRAND = <<-HTML
|
185
|
-
<div class="navbar">
|
186
|
-
<div class="navbar-inner">
|
187
|
-
<div class="container">
|
188
|
-
<a href="/" class="brand">
|
189
|
-
Ninety Ten
|
190
|
-
</a>
|
191
|
-
</div>
|
192
|
-
</div>
|
193
|
-
</div>
|
194
|
-
HTML
|
195
|
-
|
196
|
-
NAVBAR_WITH_BRAND_AND_LINK = <<-HTML
|
197
|
-
<div class="navbar">
|
198
|
-
<div class="navbar-inner">
|
199
|
-
<div class="container">
|
200
|
-
<a href="http://www.ninetyten.com" class="brand">
|
201
|
-
Ninety Ten
|
202
|
-
</a>
|
203
|
-
</div>
|
204
|
-
</div>
|
205
|
-
</div>
|
206
|
-
HTML
|
207
|
-
|
208
|
-
RESPONSIVE_NAVBAR = <<-HTML
|
209
|
-
<div class="navbar">
|
210
|
-
<div class="navbar-inner">
|
211
|
-
<div class="container">
|
212
|
-
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
213
|
-
<span class="icon-bar"></span>
|
214
|
-
<span class="icon-bar"></span>
|
215
|
-
<span class="icon-bar"></span>
|
216
|
-
</a>
|
217
|
-
<div class="nav-collapse">
|
218
|
-
</div>
|
219
|
-
</div>
|
220
|
-
</div>
|
221
|
-
</div>
|
222
|
-
HTML
|
223
|
-
|
224
|
-
RESPONSIVE_NAVBAR_WITH_BLOCK = <<-HTML
|
225
|
-
<div class="navbar">
|
226
|
-
<div class="navbar-inner">
|
227
|
-
<div class="container">
|
228
|
-
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
229
|
-
<span class="icon-bar"></span>
|
230
|
-
<span class="icon-bar"></span>
|
231
|
-
<span class="icon-bar"></span>
|
232
|
-
</a>
|
233
|
-
<div class="nav-collapse">
|
234
|
-
<p>Passing a block</p>
|
235
|
-
</div>
|
236
|
-
</div>
|
237
|
-
</div>
|
238
|
-
</div>
|
239
|
-
HTML
|
240
|
-
|
241
|
-
PLAIN_NAVBAR_WITH_ITEM = <<-HTML
|
242
|
-
<div class="navbar">
|
243
|
-
<div class="navbar-inner">
|
244
|
-
<div class="container">
|
245
|
-
<ul class="nav">
|
246
|
-
<li>
|
247
|
-
<a href="/">Home</a>
|
248
|
-
</li>
|
249
|
-
<li>
|
250
|
-
<a href="/products">Products</a>
|
251
|
-
</li>
|
252
|
-
</ul>
|
253
|
-
</div>
|
254
|
-
</div>
|
255
|
-
</div>
|
256
|
-
HTML
|
257
|
-
|
258
|
-
BRANDED_NAVBAR_WITH_ITEM = <<-HTML
|
259
|
-
<div class="navbar">
|
260
|
-
<div class="navbar-inner">
|
261
|
-
<div class="container">
|
262
|
-
<a href="/" class="brand">
|
263
|
-
Something
|
264
|
-
</a>
|
265
|
-
<ul class="nav">
|
266
|
-
<li>
|
267
|
-
<a href="/">Home</a>
|
268
|
-
</li>
|
269
|
-
</ul>
|
270
|
-
</div>
|
271
|
-
</div>
|
272
|
-
</div>
|
273
|
-
HTML
|
274
|
-
|
275
|
-
DROPDOWN_MENU = <<-HTML
|
276
|
-
<li class="dropdown">
|
277
|
-
<a href="#"
|
278
|
-
class="dropdown-toggle"
|
279
|
-
data-toggle="dropdown">
|
280
|
-
Products
|
281
|
-
<b class="caret"></b>
|
282
|
-
</a>
|
283
|
-
<ul class="dropdown-menu">
|
284
|
-
<li><a href="/">Latest</a></li>
|
285
|
-
</ul>
|
286
|
-
</li>
|
287
|
-
HTML
|
288
|
-
|
289
|
-
PLAIN_NAVBAR_WITH_FORM = <<-HTML
|
290
|
-
<div class="navbar">
|
291
|
-
<div class="navbar-inner">
|
292
|
-
<div class="container">
|
293
|
-
<form accept-charset="utf-8" action="/" method="get">
|
294
|
-
<div style="margin:0;padding:0;display:inline">
|
295
|
-
<input name="utf8" type="hidden" value="✓"/>
|
296
|
-
</div>
|
297
|
-
<input id="search_stub" name="search[stub]" size="30" type="text"/>
|
298
|
-
</form>
|
299
|
-
</div>
|
300
|
-
</div>
|
301
|
-
</div>
|
302
|
-
HTML
|