formtastic-bootstrap 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -1
- data/VERSION +1 -1
- data/formtastic-bootstrap.gemspec +3 -2
- data/lib/formtastic-bootstrap/helpers/buttons_helper.rb +7 -2
- data/spec/helpers/buttons_helper_spec.rb +149 -0
- metadata +4 -3
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
A [Formtastic](https://github.com/justinfrench/formtastic) form builder that creates markup suitable for the [Twitter Bootstrap](http://twitter.github.com/bootstrap/) framework. In theory, it should just work. Two great tastes in one!
|
4
4
|
|
5
|
+
You can follow [FormBoot on twitter](http://twitter.com/FormBoot) for update announcements and other relevant info.
|
6
|
+
|
5
7
|
## Getting Started
|
6
8
|
|
7
9
|
### Dependencies
|
@@ -84,7 +86,7 @@ made to generate the HTML expected by Bootstrap while still generating the rich
|
|
84
86
|
</div>
|
85
87
|
</fieldset>
|
86
88
|
<div class="actions">
|
87
|
-
<input class="btn create" name="commit" type="submit" value="Create Post" />
|
89
|
+
<input class="btn create commit" name="commit" type="submit" value="Create Post" />
|
88
90
|
</div>
|
89
91
|
</form>
|
90
92
|
|
@@ -96,9 +98,12 @@ made to generate the HTML expected by Bootstrap while still generating the rich
|
|
96
98
|
* <tt>:date</tt> et al are tagged with the <tt>stringish</tt> class.
|
97
99
|
* Hidden fields are not generated.
|
98
100
|
* Fieldsets are simply nested.
|
101
|
+
* <tt>f.buttons :name</tt> is not supported. This generates a <tt>fieldset</tt> and <tt>legend</tt> tag which will cause the wrong thing to happen in Bootstrap.
|
99
102
|
|
100
103
|
Bootstrap is somewhat incomplete, and in a few cases an inference needed to be drawn to determine a course of action. If you disagree with any of these choices, feel free to let me know.
|
101
104
|
|
105
|
+
(At some point, this gem may also provide some additional CSS to cover cases left unaddressed by Bootstrap, but its obvious what should be done. That's not going to happen any time soon though!)
|
106
|
+
|
102
107
|
### Other
|
103
108
|
|
104
109
|
A lot of the code (especially the test suite) was copied over from Formtastic and then beaten into submission. I'm sure you'll find some ugliness in there. In general, I mimicked the Formtastic code structure as much as possible.
|
@@ -119,6 +124,16 @@ In particular:
|
|
119
124
|
|
120
125
|
## Contributing to formtastic-bootstrap
|
121
126
|
|
127
|
+
### Submitting Issues
|
128
|
+
|
129
|
+
If you're filing a bug, thank you! Secondly, in the report please include:
|
130
|
+
|
131
|
+
* The version of Formtastic you're using.
|
132
|
+
* The version of Twitter Bootstrap you're using.
|
133
|
+
* The code for your form.
|
134
|
+
* Anything else you think will help!
|
135
|
+
|
136
|
+
### Source Contributions
|
122
137
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
123
138
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
124
139
|
* Fork the project
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "formtastic-bootstrap"
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matthew Bellantoni"]
|
12
|
-
s.date = "2011-
|
12
|
+
s.date = "2011-12-01"
|
13
13
|
s.description = "Formtastic form builder to generate Twitter Bootstrap-friendly markup."
|
14
14
|
s.email = "mjbellantoni@yahoo.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -64,6 +64,7 @@ Gem::Specification.new do |s|
|
|
64
64
|
"lib/formtastic-bootstrap/inputs/url_input.rb",
|
65
65
|
"spec/builder/errors_spec.rb",
|
66
66
|
"spec/builder/semantic_fields_for_spec.rb",
|
67
|
+
"spec/helpers/buttons_helper_spec.rb",
|
67
68
|
"spec/helpers/input_helper_spec.rb",
|
68
69
|
"spec/helpers/inputs_helper_spec.rb",
|
69
70
|
"spec/inputs/boolean_input_spec.rb",
|
@@ -5,8 +5,13 @@ module FormtasticBootstrap
|
|
5
5
|
include Formtastic::Helpers::ButtonsHelper
|
6
6
|
|
7
7
|
def buttons(*args, &block)
|
8
|
+
|
8
9
|
html_options = args.extract_options!
|
9
10
|
html_options[:class] ||= "actions"
|
11
|
+
|
12
|
+
if html_options.has_key?(:name)
|
13
|
+
ActiveSupport::Deprecation.warn('The :name option is not supported')
|
14
|
+
end
|
10
15
|
|
11
16
|
if block_given?
|
12
17
|
template.content_tag(:div, html_options) do
|
@@ -16,7 +21,7 @@ module FormtasticBootstrap
|
|
16
21
|
args = [:commit] if args.empty?
|
17
22
|
contents = args.map { |button_name| send(:"#{button_name}_button") }
|
18
23
|
template.content_tag(:div, html_options.except(:builder, :parent, :name)) do
|
19
|
-
Formtastic::Util.html_safe(contents)
|
24
|
+
Formtastic::Util.html_safe(contents.join)
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
@@ -30,7 +35,7 @@ module FormtasticBootstrap
|
|
30
35
|
Formtastic::I18n.t(commit_button_i18n_key, :model => commit_button_object_name)) unless text.is_a?(::String)
|
31
36
|
|
32
37
|
button_html = options.delete(:button_html) || {}
|
33
|
-
button_html.merge!(:class => [button_html[:class], "btn", commit_button_i18n_key].compact.join(' '))
|
38
|
+
button_html.merge!(:class => [button_html[:class], "btn commit", commit_button_i18n_key].compact.join(' '))
|
34
39
|
|
35
40
|
# TODO We don't have a wrapper. Add deprecation message.
|
36
41
|
# wrapper_html = options.delete(:wrapper_html) || {}
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'Formtastic::FormBuilder#buttons' do
|
5
|
+
|
6
|
+
include FormtasticSpecHelper
|
7
|
+
|
8
|
+
before do
|
9
|
+
@output_buffer = ''
|
10
|
+
mock_everything
|
11
|
+
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'with a block' do
|
15
|
+
describe 'when no options are provided' do
|
16
|
+
before do
|
17
|
+
concat(semantic_form_for(@new_post) do |builder|
|
18
|
+
buttons = builder.buttons do
|
19
|
+
concat('hello')
|
20
|
+
end
|
21
|
+
concat(buttons)
|
22
|
+
end)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should render a div inside the form, with a class of "actions"' do
|
26
|
+
output_buffer.should have_tag("form div.actions")
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should not render an ol inside the div' do
|
30
|
+
output_buffer.should_not have_tag("form div.actions ol")
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should render the contents of the block inside the input' do
|
34
|
+
output_buffer.should have_tag("form div.actions", /hello/)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should not render a legend inside the div' do
|
38
|
+
output_buffer.should_not have_tag("form div.actions legend")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'when other options are provided' do
|
43
|
+
before do
|
44
|
+
@id_option = 'advanced'
|
45
|
+
@class_option = 'wide'
|
46
|
+
|
47
|
+
concat(semantic_form_for(@new_post) do |builder|
|
48
|
+
builder.buttons :id => @id_option, :class => @class_option do
|
49
|
+
end
|
50
|
+
end)
|
51
|
+
end
|
52
|
+
it 'should pass the options into the div tag as attributes' do
|
53
|
+
output_buffer.should have_tag("form div##{@id_option}")
|
54
|
+
output_buffer.should have_tag("form div.#{@class_option}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'without a block' do
|
61
|
+
|
62
|
+
describe 'with no args (default buttons)' do
|
63
|
+
|
64
|
+
before do
|
65
|
+
concat(semantic_form_for(@new_post) do |builder|
|
66
|
+
concat(builder.buttons)
|
67
|
+
end)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should render a form' do
|
71
|
+
output_buffer.should have_tag('form')
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should render a "actions" div inside the form' do
|
75
|
+
output_buffer.should have_tag('form div.actions')
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should not render a legend in the div' do
|
79
|
+
output_buffer.should_not have_tag('form div.actions legend')
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should render an button item in the ol for each default button' do
|
83
|
+
output_buffer.should have_tag('form div.actions input.btn', :count => 1)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should render a commit list item for the commit button' do
|
87
|
+
output_buffer.should have_tag('form div.actions input.commit')
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
describe 'with button names as args' do
|
93
|
+
|
94
|
+
before do
|
95
|
+
concat(semantic_form_for(@new_post) do |builder|
|
96
|
+
concat(builder.buttons(:commit))
|
97
|
+
end)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should render a form with a div containing an input for each button arg' do
|
101
|
+
output_buffer.should have_tag('form > div.actions > input', :count => 1)
|
102
|
+
output_buffer.should have_tag('form > div.actions > input.commit')
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
describe 'with :names' do
|
108
|
+
|
109
|
+
before do
|
110
|
+
ActiveSupport::Deprecation.should_receive(:warn)
|
111
|
+
concat(
|
112
|
+
semantic_form_for(@new_post) do |builder|
|
113
|
+
concat(builder.buttons(:commit, :name => "Now click a button"))
|
114
|
+
end
|
115
|
+
)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should warn that \':name\' is not supported' do
|
119
|
+
# Assertion is above in the before block.
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
describe 'with button names and an options hash' do
|
126
|
+
|
127
|
+
before do
|
128
|
+
concat(
|
129
|
+
semantic_form_for(@new_post) do |builder|
|
130
|
+
concat(builder.buttons(:commit, :id => "my-id"))
|
131
|
+
end
|
132
|
+
)
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should render a form with a div containing a input for each button arg' do
|
136
|
+
output_buffer.should have_tag('form > div.actions > input', :count => 1)
|
137
|
+
output_buffer.should have_tag('form > div.actions > input.commit', :count => 1)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should pass the options down to the div' do
|
141
|
+
output_buffer.should have_tag('form > div#my-id.actions')
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: formtastic-bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Matthew Bellantoni
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-12-01 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: formtastic
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/formtastic-bootstrap/inputs/url_input.rb
|
147
147
|
- spec/builder/errors_spec.rb
|
148
148
|
- spec/builder/semantic_fields_for_spec.rb
|
149
|
+
- spec/helpers/buttons_helper_spec.rb
|
149
150
|
- spec/helpers/input_helper_spec.rb
|
150
151
|
- spec/helpers/inputs_helper_spec.rb
|
151
152
|
- spec/inputs/boolean_input_spec.rb
|
@@ -183,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
184
|
requirements:
|
184
185
|
- - ">="
|
185
186
|
- !ruby/object:Gem::Version
|
186
|
-
hash:
|
187
|
+
hash: 3880003414607105780
|
187
188
|
segments:
|
188
189
|
- 0
|
189
190
|
version: "0"
|