bootstraps_bootstraps 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +92 -0
- data/README.md +4 -4
- data/bootstraps_bootstraps.gemspec +2 -0
- data/lib/bootstraps_bootstraps.rb +11 -3
- data/lib/bootstraps_bootstraps/bootstrap_form_builder.rb +12 -9
- data/lib/bootstraps_bootstraps/engine.rb +12 -0
- data/lib/bootstraps_bootstraps/railtie.rb +4 -7
- data/lib/version.rb +1 -1
- metadata +31 -14
data/Gemfile.lock
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bootstraps_bootstraps (2.0.2)
|
5
|
+
activesupport (~> 3.2.1)
|
6
|
+
rails (~> 3.2.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (3.2.3)
|
12
|
+
actionpack (= 3.2.3)
|
13
|
+
mail (~> 2.4.4)
|
14
|
+
actionpack (3.2.3)
|
15
|
+
activemodel (= 3.2.3)
|
16
|
+
activesupport (= 3.2.3)
|
17
|
+
builder (~> 3.0.0)
|
18
|
+
erubis (~> 2.7.0)
|
19
|
+
journey (~> 1.0.1)
|
20
|
+
rack (~> 1.4.0)
|
21
|
+
rack-cache (~> 1.2)
|
22
|
+
rack-test (~> 0.6.1)
|
23
|
+
sprockets (~> 2.1.2)
|
24
|
+
activemodel (3.2.3)
|
25
|
+
activesupport (= 3.2.3)
|
26
|
+
builder (~> 3.0.0)
|
27
|
+
activerecord (3.2.3)
|
28
|
+
activemodel (= 3.2.3)
|
29
|
+
activesupport (= 3.2.3)
|
30
|
+
arel (~> 3.0.2)
|
31
|
+
tzinfo (~> 0.3.29)
|
32
|
+
activeresource (3.2.3)
|
33
|
+
activemodel (= 3.2.3)
|
34
|
+
activesupport (= 3.2.3)
|
35
|
+
activesupport (3.2.3)
|
36
|
+
i18n (~> 0.6)
|
37
|
+
multi_json (~> 1.0)
|
38
|
+
arel (3.0.2)
|
39
|
+
builder (3.0.0)
|
40
|
+
erubis (2.7.0)
|
41
|
+
hike (1.2.1)
|
42
|
+
i18n (0.6.0)
|
43
|
+
journey (1.0.3)
|
44
|
+
json (1.6.6)
|
45
|
+
mail (2.4.4)
|
46
|
+
i18n (>= 0.4.0)
|
47
|
+
mime-types (~> 1.16)
|
48
|
+
treetop (~> 1.4.8)
|
49
|
+
mime-types (1.18)
|
50
|
+
multi_json (1.2.0)
|
51
|
+
polyglot (0.3.3)
|
52
|
+
rack (1.4.1)
|
53
|
+
rack-cache (1.2)
|
54
|
+
rack (>= 0.4)
|
55
|
+
rack-ssl (1.3.2)
|
56
|
+
rack
|
57
|
+
rack-test (0.6.1)
|
58
|
+
rack (>= 1.0)
|
59
|
+
rails (3.2.3)
|
60
|
+
actionmailer (= 3.2.3)
|
61
|
+
actionpack (= 3.2.3)
|
62
|
+
activerecord (= 3.2.3)
|
63
|
+
activeresource (= 3.2.3)
|
64
|
+
activesupport (= 3.2.3)
|
65
|
+
bundler (~> 1.0)
|
66
|
+
railties (= 3.2.3)
|
67
|
+
railties (3.2.3)
|
68
|
+
actionpack (= 3.2.3)
|
69
|
+
activesupport (= 3.2.3)
|
70
|
+
rack-ssl (~> 1.3.2)
|
71
|
+
rake (>= 0.8.7)
|
72
|
+
rdoc (~> 3.4)
|
73
|
+
thor (~> 0.14.6)
|
74
|
+
rake (0.9.2.2)
|
75
|
+
rdoc (3.12)
|
76
|
+
json (~> 1.4)
|
77
|
+
sprockets (2.1.2)
|
78
|
+
hike (~> 1.2)
|
79
|
+
rack (~> 1.0)
|
80
|
+
tilt (~> 1.1, != 1.3.0)
|
81
|
+
thor (0.14.6)
|
82
|
+
tilt (1.3.3)
|
83
|
+
treetop (1.4.10)
|
84
|
+
polyglot
|
85
|
+
polyglot (>= 0.3.1)
|
86
|
+
tzinfo (0.3.33)
|
87
|
+
|
88
|
+
PLATFORMS
|
89
|
+
ruby
|
90
|
+
|
91
|
+
DEPENDENCIES
|
92
|
+
bootstraps_bootstraps!
|
data/README.md
CHANGED
@@ -12,16 +12,16 @@ Development of this gem more or less follows [Bootstrap-sass](https://github.com
|
|
12
12
|
|
13
13
|
An extended form_for called `bootstrap_form` with all the classic functionality yet extended to provide correct Bootstrap 2 syntax for horizontal forms (classed with .form_horizontal) for most elements.
|
14
14
|
|
15
|
+
##Impetus
|
16
|
+
|
17
|
+
Many form builders already exist which enable bootstrap style syntax. My biggest reason for not using any of them is that I just want to write simple rails view code in my view. I don't want to define in my model what type of form field a column needs to be represented by, because it might be represented by many interaction types. I also don't want to have to deal with syntax config files to get the form builder to render bootstrap compatible syntax. Above all, when I don't want the markup to be mucked with *at all*, I want to be able to just render the form as rails always does. Bootstraps_bootstraps provides this functionality by simply providing a secondary FormBuilder and a shortcut method to build forms with that builder.
|
18
|
+
|
15
19
|
##Development Strategy
|
16
20
|
|
17
21
|
This isn't compatible with Bootstrap versions < 2.
|
18
22
|
|
19
23
|
More or less I'm writing this library as needed. Each time I find myself trying to do something with form_for or interact between Rails and Bootstrap I find a way to make them play nice together without losing baseline Rails functionality.
|
20
24
|
|
21
|
-
Things that I know aren't in the library yet:
|
22
|
-
|
23
|
-
- Collection methods (select box, check boxes, radio buttons)
|
24
|
-
|
25
25
|
##Use
|
26
26
|
|
27
27
|
Add it to your gemfile: `gem 'bootstraps_bootstraps'`
|
@@ -11,6 +11,8 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
12
|
gem.files = `git ls-files`.split("\n")
|
13
13
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.add_dependency 'activesupport','>= 3.1.1'
|
15
|
+
gem.add_dependency 'rails', '>= 3.1.1'
|
14
16
|
gem.name = "bootstraps_bootstraps"
|
15
17
|
gem.require_paths = ["lib"]
|
16
18
|
gem.version = BootstrapsBootstraps::VERSION
|
@@ -1,7 +1,15 @@
|
|
1
1
|
require 'version.rb'
|
2
2
|
|
3
|
+
#require 'bootstraps_bootstraps/engine' if defined? ::Rails
|
4
|
+
require 'bootstraps_bootstraps/railtie.rb'
|
5
|
+
|
3
6
|
module BootstrapsBootstraps
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
+
extend ::ActiveSupport::Autoload
|
8
|
+
|
9
|
+
autoload :BootstrapFormBuilder
|
10
|
+
autoload :BootstrapFormHelper
|
7
11
|
end
|
12
|
+
|
13
|
+
::ActionView::Helpers.send(:load, 'bootstraps_bootstraps/bootstrap_form_builder.rb')
|
14
|
+
::ActionView::Helpers.send(:load, 'bootstraps_bootstraps/bootstrap_form_helper.rb')
|
15
|
+
::ActionView::Helpers.send(:include, BootstrapsBootstraps::BootstrapFormHelper)
|
@@ -72,7 +72,7 @@ module BootstrapsBootstraps
|
|
72
72
|
field = label + field unless @form_mode == :inline
|
73
73
|
|
74
74
|
#wrap it in div.control-group
|
75
|
-
field = div_with_class(['control-group',errors], :content => field)
|
75
|
+
field = div_with_class(['control-group',errors], :content => field)
|
76
76
|
|
77
77
|
field
|
78
78
|
end
|
@@ -89,8 +89,13 @@ module BootstrapsBootstraps
|
|
89
89
|
text = options[:label] || ''
|
90
90
|
options.delete :label
|
91
91
|
|
92
|
-
|
93
|
-
|
92
|
+
#TODO provide support for grouped checkboxes
|
93
|
+
div_with_class 'control-group' do
|
94
|
+
div_with_class 'controls' do
|
95
|
+
field_label(method, options) do
|
96
|
+
super(method,options,checked_value,unchecked_value) + text
|
97
|
+
end
|
98
|
+
end
|
94
99
|
end
|
95
100
|
end
|
96
101
|
|
@@ -102,10 +107,9 @@ module BootstrapsBootstraps
|
|
102
107
|
|
103
108
|
errors, error_msg = render_errors method
|
104
109
|
|
105
|
-
label_options =
|
110
|
+
label_options = options.clone
|
106
111
|
guarantee_html_class label_options, 'control-label'
|
107
|
-
|
108
|
-
label = options[:label] == false ? ''.html_safe : field_label(options[:label], label_options)
|
112
|
+
label = options[:label] == false ? ''.html_safe : field_label(method, label_options)
|
109
113
|
|
110
114
|
guarantee_html_class options
|
111
115
|
options[:class].push 'input-xlarge' if options[:large]
|
@@ -163,12 +167,11 @@ module BootstrapsBootstraps
|
|
163
167
|
end
|
164
168
|
end
|
165
169
|
|
166
|
-
def submit
|
170
|
+
def submit text = nil, options = {}
|
167
171
|
# options block gets stringify_keys called on it in the first super, no :keys exist after that
|
168
172
|
field = super
|
169
173
|
return field if options['vanilla']
|
170
174
|
field = div_with_class('form-actions', content: field) unless options['no_action_block'] || @action_wrapped || [:inline, :search].include?(@form_mode)
|
171
|
-
puts @action_wrapped
|
172
175
|
field
|
173
176
|
end
|
174
177
|
|
@@ -273,7 +276,7 @@ module BootstrapsBootstraps
|
|
273
276
|
end
|
274
277
|
|
275
278
|
errors = object.errors[method].any? ? 'error' : ''
|
276
|
-
error_msg = object.errors[method].any? ? content_tag(:span, object.errors[method].join(","), class: 'help-inline') : ''
|
279
|
+
error_msg = object.errors[method].any? ? content_tag(:span, object.errors[method].join(","), class: @form_mode == :vertical ? 'help-block' : 'help-inline') : ''
|
277
280
|
|
278
281
|
[errors, error_msg]
|
279
282
|
end
|
@@ -1,18 +1,15 @@
|
|
1
|
-
require 'ruby-debug'
|
2
|
-
|
3
1
|
module BootstrapsBootstraps
|
4
2
|
class Railtie < Rails::Railtie
|
3
|
+
|
5
4
|
initializer "bootstraps_bootstraps.configure_rails_initialization" do |application|
|
6
5
|
# Prevent Rails from wrapping form elements with errors in <div class="field_with_error">
|
7
6
|
# boxes. Bootstrap has a bit of a different paradigm.
|
8
7
|
# Credit where due: http://stackoverflow.com/questions/5267998/rails-3-field-with-errors-wrapper-changes-the-page-appearance-how-to-avoid-t
|
9
8
|
application.config.action_view.field_error_proc = Proc.new { |html_tag, instance| html_tag }
|
10
|
-
|
9
|
+
ActiveSupport.on_load :action_view do
|
10
|
+
include BootstrapsBootstraps::BootstrapFormHelper
|
11
|
+
end
|
11
12
|
|
12
|
-
config.to_prepare do
|
13
|
-
#RELOAD THE GEM ALL THE TIME WITHOUT RESTARTING THE SERVER :O (without restarting the server)
|
14
|
-
::ActionView::Helpers.send(:load, 'bootstraps_bootstraps/bootstrap_form_builder.rb')
|
15
|
-
::ActionView::Helpers.send(:include, BootstrapsBootstraps::BootstrapFormHelper)
|
16
13
|
end
|
17
14
|
end
|
18
15
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstraps_bootstraps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 2
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
version: 2.0.2
|
4
|
+
prerelease:
|
5
|
+
version: 2.0.3
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Robert L. Carpenter
|
@@ -14,10 +10,31 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2012-
|
13
|
+
date: 2012-12-08 00:00:00 -07:00
|
18
14
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: activesupport
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 3.1.1
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 3.1.1
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
21
38
|
description: A gem to make working with Bootstrap 2.0 in Rails 3 easier and better. Includes a new bootstrapped_form replacement for form_for which gives error text handling and html formatting to match Bootstrap's syntax.
|
22
39
|
email:
|
23
40
|
- codemonkey@robacarp.com
|
@@ -30,6 +47,7 @@ extra_rdoc_files: []
|
|
30
47
|
files:
|
31
48
|
- .gitignore
|
32
49
|
- Gemfile
|
50
|
+
- Gemfile.lock
|
33
51
|
- LICENSE
|
34
52
|
- README.md
|
35
53
|
- Rakefile
|
@@ -37,6 +55,7 @@ files:
|
|
37
55
|
- lib/bootstraps_bootstraps.rb
|
38
56
|
- lib/bootstraps_bootstraps/bootstrap_form_builder.rb
|
39
57
|
- lib/bootstraps_bootstraps/bootstrap_form_helper.rb
|
58
|
+
- lib/bootstraps_bootstraps/engine.rb
|
40
59
|
- lib/bootstraps_bootstraps/railtie.rb
|
41
60
|
- lib/version.rb
|
42
61
|
- railtie.rb
|
@@ -50,23 +69,21 @@ rdoc_options: []
|
|
50
69
|
require_paths:
|
51
70
|
- lib
|
52
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
53
73
|
requirements:
|
54
74
|
- - ">="
|
55
75
|
- !ruby/object:Gem::Version
|
56
|
-
segments:
|
57
|
-
- 0
|
58
76
|
version: "0"
|
59
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
60
79
|
requirements:
|
61
80
|
- - ">="
|
62
81
|
- !ruby/object:Gem::Version
|
63
|
-
segments:
|
64
|
-
- 0
|
65
82
|
version: "0"
|
66
83
|
requirements: []
|
67
84
|
|
68
85
|
rubyforge_project:
|
69
|
-
rubygems_version: 1.
|
86
|
+
rubygems_version: 1.6.2
|
70
87
|
signing_key:
|
71
88
|
specification_version: 3
|
72
89
|
summary: Bootstrap 2.0 html helpers for Rails 3
|