twitter-bootstrap3-rails 3.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +708 -0
  3. data/Rakefile +46 -0
  4. data/app/assets/fonts/fontawesome-webfont.eot +0 -0
  5. data/app/assets/fonts/fontawesome-webfont.svg +399 -0
  6. data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
  7. data/app/assets/fonts/fontawesome-webfont.woff +0 -0
  8. data/app/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
  9. data/app/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
  10. data/app/assets/javascripts/twitter/bootstrap.js +12 -0
  11. data/app/assets/javascripts/twitter/bootstrap/affix.js +126 -0
  12. data/app/assets/javascripts/twitter/bootstrap/alert.js +98 -0
  13. data/app/assets/javascripts/twitter/bootstrap/button.js +109 -0
  14. data/app/assets/javascripts/twitter/bootstrap/carousel.js +217 -0
  15. data/app/assets/javascripts/twitter/bootstrap/collapse.js +179 -0
  16. data/app/assets/javascripts/twitter/bootstrap/dropdown.js +154 -0
  17. data/app/assets/javascripts/twitter/bootstrap/modal.js +244 -0
  18. data/app/assets/javascripts/twitter/bootstrap/popover.js +117 -0
  19. data/app/assets/javascripts/twitter/bootstrap/scrollspy.js +158 -0
  20. data/app/assets/javascripts/twitter/bootstrap/tab.js +135 -0
  21. data/app/assets/javascripts/twitter/bootstrap/tooltip.js +382 -0
  22. data/app/assets/javascripts/twitter/bootstrap/transition.js +56 -0
  23. data/app/assets/javascripts/twitter/bootstrap_ujs.js +11 -0
  24. data/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +5579 -0
  25. data/app/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +787 -0
  26. data/app/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +146 -0
  27. data/app/helpers/badge_label_helper.rb +16 -0
  28. data/app/helpers/bootstrap_flash_helper.rb +29 -0
  29. data/app/helpers/flash_block_helper.rb +17 -0
  30. data/app/helpers/glyph_helper.rb +17 -0
  31. data/app/helpers/modal_helper.rb +59 -0
  32. data/app/helpers/navbar_helper.rb +195 -0
  33. data/app/helpers/twitter_breadcrumbs_helper.rb +10 -0
  34. data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +12 -0
  35. data/lib/generators/bootstrap/install/install_generator.rb +82 -0
  36. data/lib/generators/bootstrap/install/templates/application.css +7 -0
  37. data/lib/generators/bootstrap/install/templates/application.js +10 -0
  38. data/lib/generators/bootstrap/install/templates/bootstrap.coffee +3 -0
  39. data/lib/generators/bootstrap/install/templates/bootstrap.js +4 -0
  40. data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.css +7 -0
  41. data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +29 -0
  42. data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +18 -0
  43. data/lib/generators/bootstrap/layout/layout_generator.rb +20 -0
  44. data/lib/generators/bootstrap/layout/templates/layout.html.erb +85 -0
  45. data/lib/generators/bootstrap/layout/templates/layout.html.haml +50 -0
  46. data/lib/generators/bootstrap/layout/templates/layout.html.slim +52 -0
  47. data/lib/generators/bootstrap/partial/partial_generator.rb +20 -0
  48. data/lib/generators/bootstrap/partial/templates/_login.html.erb +28 -0
  49. data/lib/generators/bootstrap/themed/templates/_form.html.erb +16 -0
  50. data/lib/generators/bootstrap/themed/templates/_form.html.haml +9 -0
  51. data/lib/generators/bootstrap/themed/templates/_form.html.slim +10 -0
  52. data/lib/generators/bootstrap/themed/templates/edit.html.erb +5 -0
  53. data/lib/generators/bootstrap/themed/templates/edit.html.haml +4 -0
  54. data/lib/generators/bootstrap/themed/templates/edit.html.slim +4 -0
  55. data/lib/generators/bootstrap/themed/templates/index.html.erb +40 -0
  56. data/lib/generators/bootstrap/themed/templates/index.html.haml +25 -0
  57. data/lib/generators/bootstrap/themed/templates/index.html.slim +27 -0
  58. data/lib/generators/bootstrap/themed/templates/new.html.erb +5 -0
  59. data/lib/generators/bootstrap/themed/templates/new.html.haml +4 -0
  60. data/lib/generators/bootstrap/themed/templates/new.html.slim +4 -0
  61. data/lib/generators/bootstrap/themed/templates/show.html.erb +21 -0
  62. data/lib/generators/bootstrap/themed/templates/show.html.haml +15 -0
  63. data/lib/generators/bootstrap/themed/templates/show.html.slim +16 -0
  64. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb +13 -0
  65. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +10 -0
  66. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim +11 -0
  67. data/lib/generators/bootstrap/themed/themed_generator.rb +148 -0
  68. data/lib/twitter-bootstrap-rails.rb +10 -0
  69. data/lib/twitter/bootstrap/rails/bootstrap.rb +2 -0
  70. data/lib/twitter/bootstrap/rails/engine.rb +33 -0
  71. data/lib/twitter/bootstrap/rails/twitter-bootstrap-breadcrumbs.rb +42 -0
  72. data/lib/twitter/bootstrap/rails/version.rb +7 -0
  73. data/spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb +22 -0
  74. data/spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb +62 -0
  75. data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +331 -0
  76. data/spec/lib/twitter_bootstrap_rails/uri_state_spec.rb +47 -0
  77. data/spec/spec_helper.rb +11 -0
  78. data/test/lib/breadcrumbs_test.rb +75 -0
  79. data/test/test_helper.rb +11 -0
  80. data/vendor/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +5579 -0
  81. data/vendor/static-source/bootstrap.less +1 -0
  82. data/vendor/static-source/fontawesome.less +9 -0
  83. data/vendor/static-source/sprites.less +6 -0
  84. data/vendor/toolkit/fontawesome/bootstrap.less +84 -0
  85. data/vendor/toolkit/fontawesome/core.less +129 -0
  86. data/vendor/toolkit/fontawesome/extras.less +93 -0
  87. data/vendor/toolkit/fontawesome/font-awesome-ie7.less +1953 -0
  88. data/vendor/toolkit/fontawesome/font-awesome.less +33 -0
  89. data/vendor/toolkit/fontawesome/icons.less +381 -0
  90. data/vendor/toolkit/fontawesome/mixins.less +48 -0
  91. data/vendor/toolkit/fontawesome/path.less +14 -0
  92. data/vendor/toolkit/fontawesome/variables.less +735 -0
  93. data/vendor/toolkit/twitter/bootstrap/alerts.less +71 -0
  94. data/vendor/toolkit/twitter/bootstrap/badges.less +51 -0
  95. data/vendor/toolkit/twitter/bootstrap/bootstrap.less +63 -0
  96. data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +23 -0
  97. data/vendor/toolkit/twitter/bootstrap/button-groups.less +244 -0
  98. data/vendor/toolkit/twitter/bootstrap/buttons.less +159 -0
  99. data/vendor/toolkit/twitter/bootstrap/carousel.less +204 -0
  100. data/vendor/toolkit/twitter/bootstrap/close.less +33 -0
  101. data/vendor/toolkit/twitter/bootstrap/code.less +56 -0
  102. data/vendor/toolkit/twitter/bootstrap/component-animations.less +29 -0
  103. data/vendor/toolkit/twitter/bootstrap/dropdowns.less +176 -0
  104. data/vendor/toolkit/twitter/bootstrap/forms.less +332 -0
  105. data/vendor/toolkit/twitter/bootstrap/grid.less +340 -0
  106. data/vendor/toolkit/twitter/bootstrap/input-groups.less +127 -0
  107. data/vendor/toolkit/twitter/bootstrap/jumbotron.less +29 -0
  108. data/vendor/toolkit/twitter/bootstrap/labels.less +54 -0
  109. data/vendor/toolkit/twitter/bootstrap/list-group.less +88 -0
  110. data/vendor/toolkit/twitter/bootstrap/media.less +56 -0
  111. data/vendor/toolkit/twitter/bootstrap/mixins.less +693 -0
  112. data/vendor/toolkit/twitter/bootstrap/modals.less +133 -0
  113. data/vendor/toolkit/twitter/bootstrap/navbar.less +559 -0
  114. data/vendor/toolkit/twitter/bootstrap/navs.less +228 -0
  115. data/vendor/toolkit/twitter/bootstrap/normalize.less +396 -0
  116. data/vendor/toolkit/twitter/bootstrap/pager.less +55 -0
  117. data/vendor/toolkit/twitter/bootstrap/pagination.less +72 -0
  118. data/vendor/toolkit/twitter/bootstrap/panels.less +128 -0
  119. data/vendor/toolkit/twitter/bootstrap/popovers.less +133 -0
  120. data/vendor/toolkit/twitter/bootstrap/print.less +100 -0
  121. data/vendor/toolkit/twitter/bootstrap/progress-bars.less +99 -0
  122. data/vendor/toolkit/twitter/bootstrap/responsive-utilities.less +149 -0
  123. data/vendor/toolkit/twitter/bootstrap/scaffolding.less +111 -0
  124. data/vendor/toolkit/twitter/bootstrap/tables.less +211 -0
  125. data/vendor/toolkit/twitter/bootstrap/thumbnails.less +42 -0
  126. data/vendor/toolkit/twitter/bootstrap/tooltip.less +95 -0
  127. data/vendor/toolkit/twitter/bootstrap/type.less +238 -0
  128. data/vendor/toolkit/twitter/bootstrap/utilities.less +42 -0
  129. data/vendor/toolkit/twitter/bootstrap/variables.less +607 -0
  130. data/vendor/toolkit/twitter/bootstrap/wells.less +29 -0
  131. data/vendor/toolkit/twitter/bootstrap_base.less +2 -0
  132. metadata +297 -0
@@ -0,0 +1,42 @@
1
+ module Twitter
2
+ module Bootstrap
3
+ module BreadCrumbs
4
+ def self.included(base)
5
+ base.extend(ClassMethods)
6
+ end
7
+
8
+ module ClassMethods
9
+ def add_breadcrumb(name, url, options = {})
10
+ class_name = self.name
11
+ before_filter options do |controller|
12
+ name = controller.send :translate_breadcrumb, name, class_name if name.is_a?(Symbol)
13
+ controller.send :add_breadcrumb, name, url
14
+ end
15
+ end
16
+ end
17
+
18
+ protected
19
+
20
+ def add_breadcrumb(name, url = '', options = {})
21
+ @breadcrumbs ||= []
22
+ name = translate_breadcrumb(name, self.class.name) if name.is_a?(Symbol)
23
+ url = eval(url.to_s) if url =~ /_path|_url|@/
24
+ @breadcrumbs << {:name => name, :url => url, :options => options}
25
+ end
26
+
27
+ def translate_breadcrumb(name, class_name)
28
+ scope = [:breadcrumbs]
29
+ namespace = class_name.underscore.split('/')
30
+ namespace.last.sub!('_controller', '')
31
+ scope += namespace
32
+
33
+ I18n.t name, :scope => scope
34
+ end
35
+
36
+ def render_breadcrumbs(divider = '/')
37
+ s = render :partial => 'twitter-bootstrap/breadcrumbs', :locals => {:divider => divider}
38
+ s.first
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,7 @@
1
+ module Twitter
2
+ module Bootstrap
3
+ module Rails
4
+ VERSION = "3.2.7"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'action_view'
4
+ require 'active_support'
5
+ require_relative '../../../app/helpers/badge_label_helper'
6
+
7
+ include ActionView::Helpers
8
+ include ActionView::Context
9
+ include BadgeLabelHelper
10
+
11
+ describe BadgeLabelHelper, :type => :helper do
12
+ it "should return a basic bootstrap badge" do
13
+ badge('test').gsub(/\s/, '').downcase.should eql(BASIC_BADGE.gsub(/\s/, '').downcase)
14
+ end
15
+
16
+ it "should return a bootstrap badge with class" do
17
+ badge('waning', :warning).gsub(/\s/, '').downcase.should eql(BADGE_WITH_CLASS.gsub(/\s/, '').downcase)
18
+ end
19
+ end
20
+
21
+ BASIC_BADGE = %{<span class="badge">test</span>}
22
+ BADGE_WITH_CLASS = %{<span class="badge badge-warning">waning</span>}
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require_relative '../../../app/helpers/modal_helper'
4
+
5
+ include ActionView::Helpers
6
+ include ActionView::Context
7
+ include ModalHelper
8
+
9
+ describe ModalHelper, :type => :helper do
10
+ header_with_close = { :show_close => true, :dismiss => 'modal', :title => 'Modal header' }
11
+ header_without_close = { :show_close => false, :title => 'Modal header' }
12
+ options = { :id => "modal",
13
+ :header => header_with_close,
14
+ :body => 'This is the body',
15
+ :footer => content_tag(:button, 'Save', :class => 'btn')
16
+ }
17
+
18
+ it 'returns a complete modal' do
19
+ modal_dialog(options).gsub(/\n/, "").should eql BASIC_MODAL.gsub(/\n/, "")
20
+ end
21
+
22
+ it 'returns a modal header with a close button if show_close is true' do
23
+ modal_header(header_with_close).gsub(/\n/, "").should eql MODAL_HEADER_WITH_CLOSE.gsub(/\n/, "")
24
+ end
25
+
26
+ it 'renders a modal header without a close button' do
27
+ modal_header(header_without_close).gsub(/\n/, "").should eql MODAL_HEADER_WITHOUT_CLOSE.gsub(/\n/, "")
28
+ end
29
+
30
+ it 'renders a close button' do
31
+ close_button('modal').should eql "<button class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>"
32
+ end
33
+
34
+ it 'renders a modal toggle button' do
35
+ modal_toggle('Save', :href => "#modal").gsub(/\n/, "").should eql MODAL_TOGGLE.gsub(/\n/, "")
36
+ end
37
+
38
+ it 'renders a cancel button' do
39
+ modal_cancel_button("Cancel", :href => "#modal", :data => {:dismiss => 'modal'}).gsub(/\n/, "").should eql MODAL_CANCEL_BUTTON.gsub(/\n/, "")
40
+ end
41
+ end
42
+
43
+ BASIC_MODAL = <<-HTML
44
+ <div class="modal fade" id="modal"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button class="close" data-dismiss="modal" aria-hidden="true">&times;</button><h4 class="modal-title">Modal header</h4></div><div class="modal-body">This is the body</div><div class="modal-footer"><button class="btn">Save</button></div></div></div></div>
45
+ HTML
46
+
47
+ MODAL_HEADER_WITHOUT_CLOSE = <<-HTML
48
+ <div class="modal-header"><h4 class="modal-title">Modal header</h4></div>
49
+ HTML
50
+
51
+ MODAL_HEADER_WITH_CLOSE = <<-HTML
52
+ <div class="modal-header"><button class="close" data-dismiss="modal" aria-hidden="true">&times;</button><h4 class="modal-title">Modal header</h4></div>
53
+ HTML
54
+
55
+ MODAL_TOGGLE = <<-HTML
56
+ <a class="btn btn-default" data-toggle="modal" href="#modal">Save</a>
57
+ HTML
58
+
59
+ MODAL_CANCEL_BUTTON = <<-HTML
60
+ <a class="btn bootstrap-modal-cancel-button" data-dismiss="modal" href="#modal">Cancel</a>
61
+ HTML
62
+
@@ -0,0 +1,331 @@
1
+ # encoding: utf-8
2
+ #Credit for this goes to https://github.com/julescopeland/Rails-Bootstrap-Navbar
3
+ require 'spec_helper'
4
+ require 'action_view'
5
+ require 'active_support'
6
+ require_relative '../../../app/helpers/navbar_helper'
7
+
8
+ include ActionView::Helpers
9
+ include ActionView::Context
10
+ include NavbarHelper
11
+
12
+ describe NavbarHelper, :type => :helper do
13
+ before do
14
+ self.stub!("uri_state").and_return(:inactive)
15
+ self.stub!("root_url").and_return("/")
16
+ end
17
+ describe "nav_bar" do
18
+ it "should return a basic bootstrap navbar" do
19
+ nav_bar.gsub(/\s/, '').downcase.should eql(BASIC_NAVBAR.gsub(/\s/, '').downcase)
20
+ end
21
+
22
+ it "should set the fixed position to top" do
23
+ nav_bar(:fixed => :top).gsub(/\s/, '').downcase.should eql(FIXED_TOP_NAVBAR.gsub(/\s/, '').downcase)
24
+ end
25
+
26
+ it "should set the static position to top" do
27
+ nav_bar(:static => :top).gsub(/\s/, '').downcase.should eql(STATIC_TOP_NAVBAR.gsub(/\s/, '').downcase)
28
+ end
29
+
30
+ it "should set the fixed position to bottom" do
31
+ nav_bar(:fixed => :bottom).gsub(/\s/, '').downcase.should eql(FIXED_BOTTOM_NAVBAR.gsub(/\s/, '').downcase)
32
+ end
33
+
34
+ it "should set the style to inverse" do
35
+ nav_bar(:inverse => true).gsub(/\s/, '').downcase.should eql(INVERSE_NAVBAR.gsub(/\s/, '').downcase)
36
+ end
37
+
38
+ it "should add the brand name and link it to the home page" do
39
+ nav_bar(:brand => "Ninety Ten").gsub(/\s/, '').downcase.should eql(NAVBAR_WITH_BRAND.gsub(/\s/, '').downcase)
40
+ end
41
+
42
+ it "should be able to set the brand link url" do
43
+ nav_bar(:brand => "Ninety Ten", :brand_link => "http://www.ninetyten.com").gsub(/\s/, '').downcase.should eql(NAVBAR_WITH_BRAND_AND_LINK.gsub(/\s/, '').downcase)
44
+ end
45
+
46
+ it "should add the buttons etc for a responsive layout with no block passed" do
47
+ nav_bar(:responsive => true).gsub(/\s/, '').downcase.should eql(RESPONSIVE_NAVBAR.gsub(/\s/, '').downcase)
48
+ end
49
+
50
+ it "should add the buttons etc for a responsive layout with block passed" do
51
+ nav_bar(:responsive => true) do
52
+ "<p>Passing a block</p>".html_safe
53
+ end.gsub(/\s/, '').downcase.should eql(RESPONSIVE_NAVBAR_WITH_BLOCK.gsub(/\s/, '').downcase)
54
+ end
55
+
56
+ it "should render contained items" do
57
+ nav_bar do
58
+ menu_group do
59
+ menu_item("Home", "/") + menu_item("Products", "/products")
60
+ end
61
+ end.gsub(/\s/, '').downcase.should eql(PLAIN_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
62
+ end
63
+
64
+ it "should still render the brand name even with other options turned on" do
65
+ nav_bar(:brand => "Something") do
66
+ menu_group do
67
+ menu_item "Home", "/"
68
+ end
69
+ end.gsub(/\s/, '').downcase.should eql(BRANDED_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
70
+ end
71
+ end
72
+
73
+ describe "menu_group" do
74
+ it "should return a ul with the class 'nav'" do
75
+ menu_group do
76
+ menu_item("Home", "/") + menu_item("Products", "/products")
77
+ end.should eql '<ul class="nav navbar-nav "><li><a href="/">Home</a></li><li><a href="/products">Products</a></li></ul>'
78
+ end
79
+
80
+ it "should return a ul with class .pull-left when passed the {:pull => :left} option" do
81
+ menu_group(:pull => :left) do
82
+ menu_item("Home", "/")
83
+ end.should eql('<ul class="nav navbar-nav pull-left"><li><a href="/">Home</a></li></ul>')
84
+ end
85
+ end
86
+
87
+ describe "menu_item" do
88
+ it "should return a link within an li tag" do
89
+ self.stub!("current_page?").and_return(false)
90
+ menu_item("Home", "/").should eql('<li><a href="/">Home</a></li>')
91
+ end
92
+ it "should return the link with class 'active' if on current page" do
93
+ self.stub!("uri_state").and_return(:active)
94
+ menu_item("Home", "/").should eql('<li class="active"><a href="/">Home</a></li>')
95
+ end
96
+ it "should pass any other options through to the link_to method" do
97
+ self.stub!("uri_state").and_return(:active)
98
+ menu_item("Log out", "/users/sign_out", :class => "home_link", :method => :delete).should eql('<li class="active"><a class="home_link" data-method="delete" href="/users/sign_out" rel="nofollow">Log out</a></li>')
99
+ end
100
+ it "should pass a block but no name if a block is present" do
101
+ self.stub!("current_page?").and_return(false)
102
+ menu_item("/"){content_tag("i", "", :class => "icon-home") + " Home"}.should eql('<li><a href="/"><i class="icon-home"></i> Home</a></li>')
103
+ end
104
+ it "should work with just a block" do
105
+ self.stub!("current_page?").and_return(false)
106
+ menu_item{ content_tag("i", "", :class => "icon-home") + " Home" }.should eql('<li><a href="#"><i class="icon-home"></i> Home</a></li>')
107
+ end
108
+ it "should return the link with class 'active' if on current page with a block" do
109
+ self.stub!("uri_state").and_return(:active)
110
+ menu_item("/"){ content_tag("i", "", :class => "icon-home") + " Home" }.should eql('<li class="active"><a href="/"><i class="icon-home"></i> Home</a></li>')
111
+ end
112
+ end
113
+
114
+ describe "drop_down" do
115
+ it "should do render the proper drop down code" do
116
+ drop_down "Products" do
117
+ menu_item "Latest", "/"
118
+ end.gsub(/\s/, '').downcase.should eql(DROPDOWN_MENU.gsub(/\s/, '').downcase)
119
+ end
120
+ end
121
+
122
+ describe "drop_down_with_submenu" do
123
+ it "should do render the proper drop down code" do
124
+ drop_down_with_submenu "Products" do
125
+ drop_down_submenu "Latest" do
126
+ menu_item "Option1", "/"
127
+ end
128
+ end.gsub(/\s/, '').downcase.should eql(DROPDOWN_MENU_WITH_SUBMENU.gsub(/\s/, '').downcase)
129
+ end
130
+ end
131
+
132
+ describe "menu_divider" do
133
+ it "should render <li class='divider-vertical'></li>" do
134
+ menu_divider.should eql '<li class="divider-vertical"></li>'
135
+ end
136
+ end
137
+
138
+ describe "menu_text" do
139
+ it "should render text within p tags with class 'navbar-text" do
140
+ menu_text("Strapline!").should eql("<p class=\"navbar-text\">Strapline!</p>")
141
+ end
142
+
143
+ it "should be able to be pulled right or left" do
144
+ menu_text("I am being pulled right", :pull => :right).should eql("<p class=\"pull-right navbar-text\">I am being pulled right</p>")
145
+ end
146
+
147
+ it "should be able to cope with arbitrary options being passed to the p tag" do
148
+ menu_text("I am classy!", :class => "classy", :id => "classy_text").should eql("<p class=\"classy navbar-text\" id=\"classy_text\">I am classy!</p>")
149
+ end
150
+
151
+ it "should be able to cope with a block too" do
152
+ menu_text do
153
+ "I have been rendered programmatically!"
154
+ end.should eql("<p class=\"navbar-text\">I have been rendered programmatically!</p>")
155
+ end
156
+ end
157
+
158
+ describe "rendering forms ok" do
159
+ it "should not escape anything unexpectedly" do
160
+ nav_bar do
161
+ form_tag "/", :method => 'get' do |f|
162
+ f.text_field :search, "stub"
163
+ end
164
+ end.gsub(/\s/, '').downcase.should eql(PLAIN_NAVBAR_WITH_FORM.gsub(/\s/, '').downcase)
165
+ end
166
+ end
167
+
168
+ end
169
+
170
+ # HTML output
171
+
172
+ BASIC_NAVBAR = <<-HTML
173
+ <nav class="navbar navbar-default" role="navigation">
174
+ <div class="container">
175
+ </div>
176
+ </nav>
177
+ HTML
178
+
179
+ FIXED_TOP_NAVBAR = <<-HTML
180
+ <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
181
+ <div class="container">
182
+ </div>
183
+ </nav>
184
+ HTML
185
+
186
+ STATIC_TOP_NAVBAR = <<-HTML
187
+ <nav class="navbar navbar-default navbar-static-top" role="navigation">
188
+ <div class="container">
189
+ </div>
190
+ </nav>
191
+ HTML
192
+
193
+ FIXED_BOTTOM_NAVBAR = <<-HTML
194
+ <nav class="navbar navbar-default navbar-fixed-bottom" role="navigation">
195
+ <div class="container">
196
+ </div>
197
+ </nav>
198
+ HTML
199
+
200
+ INVERSE_NAVBAR = <<-HTML
201
+ <nav class="navbar navbar-default navbar-inverse" role="navigation">
202
+ <div class="container">
203
+ </div>
204
+ </nav>
205
+ HTML
206
+
207
+ NAVBAR_WITH_BRAND = <<-HTML
208
+ <nav class="navbar navbar-default" role="navigation">
209
+ <div class="container">
210
+ <a class="navbar-brand" href="/">
211
+ Ninety Ten
212
+ </a>
213
+ </div>
214
+ </nav>
215
+ HTML
216
+
217
+ NAVBAR_WITH_BRAND_AND_LINK = <<-HTML
218
+ <nav class="navbar navbar-default" role="navigation">
219
+ <div class="container">
220
+ <a class="navbar-brand" href="http://www.ninetyten.com">
221
+ Ninety Ten
222
+ </a>
223
+ </div>
224
+ </nav>
225
+ HTML
226
+
227
+ RESPONSIVE_NAVBAR = <<-HTML
228
+ <nav class="navbar navbar-default" role="navigation">
229
+ <div class="container">
230
+ <div class="navbar-header">
231
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
232
+ <span class="sr-only">Toggle Navigation</span>
233
+ <span class="icon-bar"></span>
234
+ <span class="icon-bar"></span>
235
+ <span class="icon-bar"></span>
236
+ </button>
237
+ </div>
238
+ <div class="navbar-collapse collapse">
239
+ </div>
240
+ </div>
241
+ </nav>
242
+ HTML
243
+
244
+ RESPONSIVE_NAVBAR_WITH_BLOCK = <<-HTML
245
+ <nav class="navbar navbar-default" role="navigation">
246
+ <div class="container">
247
+ <div class="navbar-header">
248
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
249
+ <span class="sr-only">Toggle Navigation</span>
250
+ <span class="icon-bar"></span>
251
+ <span class="icon-bar"></span>
252
+ <span class="icon-bar"></span>
253
+ </button>
254
+ </div>
255
+ <div class="navbar-collapse collapse">
256
+ <p>Passing a block</p>
257
+ </div>
258
+ </div>
259
+ </nav>
260
+ HTML
261
+
262
+ PLAIN_NAVBAR_WITH_ITEM = <<-HTML
263
+ <nav class="navbar navbar-default" role="navigation">
264
+ <div class="container">
265
+ <ul class="nav navbar-nav">
266
+ <li>
267
+ <a href="/">Home</a>
268
+ </li>
269
+ <li>
270
+ <a href="/products">Products</a>
271
+ </li>
272
+ </ul>
273
+ </div>
274
+ </nav>
275
+ HTML
276
+
277
+ BRANDED_NAVBAR_WITH_ITEM = <<-HTML
278
+ <nav class="navbar navbar-default" role="navigation">
279
+ <div class="container">
280
+ <a class="navbar-brand" href="/">
281
+ Something
282
+ </a>
283
+ <ul class="nav navbar-nav">
284
+ <li>
285
+ <a href="/">Home</a>
286
+ </li>
287
+ </ul>
288
+ </div>
289
+ </nav>
290
+ HTML
291
+
292
+ DROPDOWN_MENU = <<-HTML
293
+ <li class="dropdown">
294
+ <a class="dropdown-toggle"
295
+ data-toggle="dropdown"
296
+ href="#">
297
+ Products
298
+ <b class="caret"></b>
299
+ </a>
300
+ <ul class="dropdown-menu">
301
+ <li><a href="/">Latest</a></li>
302
+ </ul>
303
+ </li>
304
+ HTML
305
+
306
+ DROPDOWN_MENU_WITH_SUBMENU = <<-HTML
307
+ <li class="dropdown">
308
+ <a class="dropdown-toggle" data-toggle="dropdown" href="#">Products <b class="caret"></b></a>
309
+ <ul class="dropdown-menu">
310
+ <li class="dropdown-submenu">
311
+ <a href="">Latest</a>
312
+ <ul class="dropdown-menu">
313
+ <li><a href="/">Option1</a></li>
314
+ </ul>
315
+ </li>
316
+ </ul>
317
+ </li>
318
+ HTML
319
+
320
+ PLAIN_NAVBAR_WITH_FORM = <<-HTML
321
+ <nav class="navbar navbar-default" role="navigation">
322
+ <div class="container">
323
+ <form accept-charset="utf-8" action="/" method="get">
324
+ <div style="margin:0;padding:0;display:inline">
325
+ <input name="utf8" type="hidden" value="&#x2713;"/>
326
+ </div>
327
+ <input id="search_stub" name="search[stub]" type="text"/>
328
+ </form>
329
+ </div>
330
+ </nav>
331
+ HTML