twitter-bootstrap-markup-rails 0.2.1 → 0.2.2
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/.rspec +1 -0
- data/CONTRIBUTORS.md +4 -0
- data/README.md +64 -2
- data/lib/twitter-bootstrap-markup-rails/components.rb +1 -0
- data/lib/twitter-bootstrap-markup-rails/components/navigation.rb +47 -0
- data/lib/twitter-bootstrap-markup-rails/engine.rb +1 -0
- data/lib/twitter-bootstrap-markup-rails/helpers.rb +1 -0
- data/lib/twitter-bootstrap-markup-rails/helpers/navigation_helpers.rb +33 -0
- data/lib/twitter-bootstrap-markup-rails/version.rb +1 -1
- data/spec/helpers/navigation_helpers_spec.rb +61 -0
- data/spec/integration/action_view_spec.rb +4 -0
- data/spec/support/bootstrap_navigation_macros.rb +8 -0
- data/twitter-bootstrap-markup-rails.gemspec +1 -0
- metadata +25 -2
data/.rspec
CHANGED
data/CONTRIBUTORS.md
ADDED
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
<table>
|
4
4
|
<tr>
|
5
5
|
<th>Version</th>
|
6
|
-
<td>v0.2.
|
6
|
+
<td>v0.2.2</td>
|
7
7
|
</tr>
|
8
8
|
<tr>
|
9
9
|
<th>Build Status</th>
|
@@ -26,7 +26,7 @@ This gem focuses on making it easier to use Twitter's Bootstrap 2.0. It's a coll
|
|
26
26
|
|
27
27
|
Add to your `Gemfile`:
|
28
28
|
|
29
|
-
gem 'twitter-bootstrap-markup-rails', '0.2.
|
29
|
+
gem 'twitter-bootstrap-markup-rails', '0.2.2'
|
30
30
|
|
31
31
|
## Currently Supported
|
32
32
|
|
@@ -92,6 +92,68 @@ end
|
|
92
92
|
</div>'
|
93
93
|
```
|
94
94
|
|
95
|
+
Navigation lists:
|
96
|
+
|
97
|
+
Basic tabs example:
|
98
|
+
|
99
|
+
bootstrap_navigation do |nav|
|
100
|
+
nav.link_to "Nav1", "/link1", :active_nav => true
|
101
|
+
nav.link_to "Nav2", "/link2"
|
102
|
+
end
|
103
|
+
# => <ul class="nav nav-tabs">
|
104
|
+
<li class="active">
|
105
|
+
<a href="/link1">Nav1</a>
|
106
|
+
</li>
|
107
|
+
<li>
|
108
|
+
<a href="/link2">Nav2</a>
|
109
|
+
</li>
|
110
|
+
</ul>
|
111
|
+
|
112
|
+
Basic pills example:
|
113
|
+
|
114
|
+
bootstrap_navigation(:type => "pills") do |nav|
|
115
|
+
nav.link_to "Nav1", "/link1"
|
116
|
+
nav.link_to "Nav2", "/link2", :active_nav => true
|
117
|
+
end
|
118
|
+
# => <ul class="nav nav-pills">
|
119
|
+
<li>
|
120
|
+
<a href="/link1">Nav1</a>
|
121
|
+
</li>
|
122
|
+
<li class="active">
|
123
|
+
<a href="/link2">Nav2</a>
|
124
|
+
</li>
|
125
|
+
</ul>
|
126
|
+
|
127
|
+
Stacked tabs example:
|
128
|
+
|
129
|
+
bootstrap_navigation(:type => "tabs", :stacked => true) do |nav|
|
130
|
+
nav.link_to "Nav1", "/link1", :active_nav => true
|
131
|
+
nav.link_to "Nav2", "/link2"
|
132
|
+
end
|
133
|
+
# => <ul class="nav nav-tabs nav-stacked">
|
134
|
+
<li class="active">
|
135
|
+
<a href="/link1">Nav1</a>
|
136
|
+
</li>
|
137
|
+
<li>
|
138
|
+
<a href="/link2">Nav2</a>
|
139
|
+
</li>
|
140
|
+
</ul>
|
141
|
+
|
142
|
+
Stacked pills example:
|
143
|
+
|
144
|
+
bootstrap_navigation(:type => "pills", :stacked => true) do |nav|
|
145
|
+
nav.link_to "Nav1", "/link1"
|
146
|
+
nav.link_to "Nav2", "/link2", :active_nav => true
|
147
|
+
end
|
148
|
+
# => <ul class="nav nav-pills nav-stacked">
|
149
|
+
<li>
|
150
|
+
<a href="/link1">Nav1</a>
|
151
|
+
</li>
|
152
|
+
<li class="active">
|
153
|
+
<a href="/link2">Nav2</a>
|
154
|
+
</li>
|
155
|
+
</ul>
|
156
|
+
|
95
157
|
Plugins
|
96
158
|
---
|
97
159
|
|
@@ -7,6 +7,7 @@ module Twitter::Bootstrap::Markup::Rails
|
|
7
7
|
autoload :FormBuilder, 'twitter-bootstrap-markup-rails/components/form_builder'
|
8
8
|
autoload :Button, 'twitter-bootstrap-markup-rails/components/button'
|
9
9
|
autoload :ButtonDropdown, 'twitter-bootstrap-markup-rails/components/button_dropdown'
|
10
|
+
autoload :Navigation, 'twitter-bootstrap-markup-rails/components/navigation'
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Twitter::Bootstrap::Markup::Rails::Components
|
2
|
+
class Navigation < Base
|
3
|
+
attr_reader :collection
|
4
|
+
|
5
|
+
def initialize(elements, options = {})
|
6
|
+
super
|
7
|
+
@elements = elements
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
output_buffer << content_tag(:ul, :class => build_class) do
|
12
|
+
html = ""
|
13
|
+
|
14
|
+
@elements.each do |e|
|
15
|
+
html_class = build_html_class(e)
|
16
|
+
html << content_tag(:li, e.to_s, html_class)
|
17
|
+
end
|
18
|
+
|
19
|
+
html.html_safe
|
20
|
+
end
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def default_options
|
27
|
+
{}
|
28
|
+
end
|
29
|
+
|
30
|
+
def build_html_class(element)
|
31
|
+
html_class = {}
|
32
|
+
if element.options[:active_nav]
|
33
|
+
element.options.reject! {|k,v| k == :active_nav }
|
34
|
+
html_class = { :class => "active" }
|
35
|
+
end
|
36
|
+
html_class
|
37
|
+
end
|
38
|
+
|
39
|
+
def build_class
|
40
|
+
classes = %w( nav )
|
41
|
+
classes << "nav-#{ options[:type] || "tabs" }"
|
42
|
+
classes << "nav-stacked" if options[:stacked]
|
43
|
+
classes.join(" ")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -8,6 +8,7 @@ module Twitter::Bootstrap::Markup::Rails
|
|
8
8
|
include Twitter::Bootstrap::Markup::Rails::Helpers::InlineLabelHelpers
|
9
9
|
include Twitter::Bootstrap::Markup::Rails::Helpers::FormHelpers
|
10
10
|
include Twitter::Bootstrap::Markup::Rails::Helpers::ButtonHelpers
|
11
|
+
include Twitter::Bootstrap::Markup::Rails::Helpers::NavigationHelpers
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
@@ -4,6 +4,7 @@ module Twitter::Bootstrap::Markup::Rails
|
|
4
4
|
autoload :InlineLabelHelpers, 'twitter-bootstrap-markup-rails/helpers/inline_label_helpers'
|
5
5
|
autoload :FormHelpers, 'twitter-bootstrap-markup-rails/helpers/form_helpers'
|
6
6
|
autoload :ButtonHelpers, 'twitter-bootstrap-markup-rails/helpers/button_helpers'
|
7
|
+
autoload :NavigationHelpers, 'twitter-bootstrap-markup-rails/helpers/navigation_helpers'
|
7
8
|
end
|
8
9
|
end
|
9
10
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Twitter::Bootstrap::Markup::Rails::Helpers
|
4
|
+
module NavigationHelpers
|
5
|
+
|
6
|
+
# Render a navigation list
|
7
|
+
#
|
8
|
+
# @param [Hash] options hash containing options (default: {}):
|
9
|
+
# :type - could be either 'tabs' or 'pills'. Default is 'tabs'.
|
10
|
+
# :stacked - if true, renders the navigation list in stacked mode.
|
11
|
+
#
|
12
|
+
# Examples
|
13
|
+
#
|
14
|
+
# bootstrap_navigation(:type => "tabs", :stacked => true) do |nav|
|
15
|
+
# nav.link_to "Nav1", "/link1", :active_nav => true
|
16
|
+
# nav.link_to "Nav2", "/link2"
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# Returns HTML String for the navigation list
|
20
|
+
def bootstrap_navigation(options = {})
|
21
|
+
elements = Twitter::Bootstrap::Markup::Rails::HelperCollection.new(self)
|
22
|
+
|
23
|
+
yield elements
|
24
|
+
|
25
|
+
Twitter::Bootstrap::Markup::Rails::Components::Navigation.new(
|
26
|
+
elements,
|
27
|
+
options
|
28
|
+
).to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Twitter::Bootstrap::Markup::Rails::Helpers::NavigationHelpers do
|
5
|
+
include BootstrapSpecHelper
|
6
|
+
include BootstrapNavigationMacros
|
7
|
+
|
8
|
+
describe "#bootstrap_navigation" do
|
9
|
+
before do
|
10
|
+
@output_buffer = ''
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should create a basic navigation list of type tabs" do
|
14
|
+
build_bootstrap_navigation do |nav|
|
15
|
+
nav.link_to "Nav1", "/link1", :active_nav => true
|
16
|
+
nav.link_to "Nav2", "/link2"
|
17
|
+
end
|
18
|
+
|
19
|
+
output_buffer.should have_tag('ul.nav.nav-tabs') do |ul|
|
20
|
+
ul.should have_tag('li[@class="active"] a[@href="/link1"]')
|
21
|
+
ul.should have_tag('li a[@href="/link1"]')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should create a basic navigation list of type pills" do
|
26
|
+
build_bootstrap_navigation(:type => "pills") do |nav|
|
27
|
+
nav.link_to "Nav1", "/link1"
|
28
|
+
nav.link_to "Nav2", "/link2", :active_nav => true
|
29
|
+
end
|
30
|
+
|
31
|
+
output_buffer.should have_tag('ul.nav.nav-pills') do |ul|
|
32
|
+
ul.should have_tag('li a[@href="/link1"]')
|
33
|
+
ul.should have_tag('li[class="active"] a[@href="/link2"]')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should create a vertical navigation list of type tabs when called with a list of links" do
|
38
|
+
build_bootstrap_navigation(:type => "tabs", :stacked => true) do |nav|
|
39
|
+
nav.link_to "Nav1", "/link1", :active_nav => true
|
40
|
+
nav.link_to "Nav2", "/link2"
|
41
|
+
end
|
42
|
+
|
43
|
+
output_buffer.should have_tag('ul.nav.nav-tabs.nav-stacked') do |ul|
|
44
|
+
ul.should have_tag('li[@class="active"] a[@href="/link1"]')
|
45
|
+
ul.should have_tag('li a[@href="/link1"]')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should create a vertical navigation list of type pills when called with a list of links" do
|
50
|
+
build_bootstrap_navigation(:type => "pills", :stacked => true) do |nav|
|
51
|
+
nav.link_to "Nav1", "/link1"
|
52
|
+
nav.link_to "Nav2", "/link2", :active_nav => true
|
53
|
+
end
|
54
|
+
|
55
|
+
output_buffer.should have_tag('ul.nav.nav-pills.nav-stacked') do |ul|
|
56
|
+
ul.should have_tag('li a[@href="/link1"]')
|
57
|
+
ul.should have_tag('li[@class="active"] a[@href="/link2"]')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -16,4 +16,8 @@ describe ActionView::Base do
|
|
16
16
|
it "includes inline form helpers" do
|
17
17
|
@view.ancestors.should include(Twitter::Bootstrap::Markup::Rails::Helpers::FormHelpers)
|
18
18
|
end
|
19
|
+
|
20
|
+
it "includes inline navigation helpers" do
|
21
|
+
@view.ancestors.should include(Twitter::Bootstrap::Markup::Rails::Helpers::NavigationHelpers)
|
22
|
+
end
|
19
23
|
end
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |gem|
|
|
24
24
|
gem.add_development_dependency "rspec_tag_matchers", ">= 1.0"
|
25
25
|
gem.add_development_dependency "rake"
|
26
26
|
gem.add_development_dependency 'yard'
|
27
|
+
gem.add_development_dependency 'redcarpet'
|
27
28
|
gem.add_development_dependency 'yard-tomdoc'
|
28
29
|
gem.add_development_dependency 'simple-navigation'
|
29
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter-bootstrap-markup-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -139,6 +139,22 @@ dependencies:
|
|
139
139
|
- - ! '>='
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: redcarpet
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
142
158
|
- !ruby/object:Gem::Dependency
|
143
159
|
name: yard-tomdoc
|
144
160
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,6 +198,7 @@ files:
|
|
182
198
|
- .gitignore
|
183
199
|
- .rspec
|
184
200
|
- .travis.yml
|
201
|
+
- CONTRIBUTORS.md
|
185
202
|
- Gemfile
|
186
203
|
- Guardfile
|
187
204
|
- README.md
|
@@ -197,6 +214,7 @@ files:
|
|
197
214
|
- lib/twitter-bootstrap-markup-rails/components/form/label.rb
|
198
215
|
- lib/twitter-bootstrap-markup-rails/components/form_builder.rb
|
199
216
|
- lib/twitter-bootstrap-markup-rails/components/inline_label.rb
|
217
|
+
- lib/twitter-bootstrap-markup-rails/components/navigation.rb
|
200
218
|
- lib/twitter-bootstrap-markup-rails/engine.rb
|
201
219
|
- lib/twitter-bootstrap-markup-rails/helper_collection.rb
|
202
220
|
- lib/twitter-bootstrap-markup-rails/helpers.rb
|
@@ -204,6 +222,7 @@ files:
|
|
204
222
|
- lib/twitter-bootstrap-markup-rails/helpers/button_helpers.rb
|
205
223
|
- lib/twitter-bootstrap-markup-rails/helpers/form_helpers.rb
|
206
224
|
- lib/twitter-bootstrap-markup-rails/helpers/inline_label_helpers.rb
|
225
|
+
- lib/twitter-bootstrap-markup-rails/helpers/navigation_helpers.rb
|
207
226
|
- lib/twitter-bootstrap-markup-rails/plugins.rb
|
208
227
|
- lib/twitter-bootstrap-markup-rails/plugins/simple_navigation/renderer/bootstrap_topbar_list.rb
|
209
228
|
- lib/twitter-bootstrap-markup-rails/version.rb
|
@@ -212,12 +231,14 @@ files:
|
|
212
231
|
- spec/helpers/button_helpers_spec.rb
|
213
232
|
- spec/helpers/form_helpers_spec.rb
|
214
233
|
- spec/helpers/inline_label_helpers_spec.rb
|
234
|
+
- spec/helpers/navigation_helpers_spec.rb
|
215
235
|
- spec/integration/action_view_spec.rb
|
216
236
|
- spec/integration/readme_spec.rb
|
217
237
|
- spec/plugins/bootstrap_topbar_list_spec.rb
|
218
238
|
- spec/spec_helper.rb
|
219
239
|
- spec/support/bootstrap_button_macros.rb
|
220
240
|
- spec/support/bootstrap_form_macros.rb
|
241
|
+
- spec/support/bootstrap_navigation_macros.rb
|
221
242
|
- spec/support/bootstrap_spec_helper.rb
|
222
243
|
- spec/support/test_environment.rb
|
223
244
|
- twitter-bootstrap-markup-rails.gemspec
|
@@ -251,12 +272,14 @@ test_files:
|
|
251
272
|
- spec/helpers/button_helpers_spec.rb
|
252
273
|
- spec/helpers/form_helpers_spec.rb
|
253
274
|
- spec/helpers/inline_label_helpers_spec.rb
|
275
|
+
- spec/helpers/navigation_helpers_spec.rb
|
254
276
|
- spec/integration/action_view_spec.rb
|
255
277
|
- spec/integration/readme_spec.rb
|
256
278
|
- spec/plugins/bootstrap_topbar_list_spec.rb
|
257
279
|
- spec/spec_helper.rb
|
258
280
|
- spec/support/bootstrap_button_macros.rb
|
259
281
|
- spec/support/bootstrap_form_macros.rb
|
282
|
+
- spec/support/bootstrap_navigation_macros.rb
|
260
283
|
- spec/support/bootstrap_spec_helper.rb
|
261
284
|
- spec/support/test_environment.rb
|
262
285
|
has_rdoc:
|