booter 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.
@@ -0,0 +1,66 @@
1
+ class BootstrapFormBuilder < ActionView::Helpers::FormBuilder
2
+ delegate :content_tag, :safe_join, to: :@template
3
+
4
+ def errors_for
5
+ return "" if @object.errors.empty?
6
+
7
+ messages = @object.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
8
+ sentence = I18n.t(
9
+ "errors.messages.not_saved",
10
+ :count => @object.errors.count,
11
+ :resource => @object.class.model_name.human.downcase
12
+ )
13
+
14
+ html = <<-HTML
15
+ <div class="alert alert-error">
16
+ <p><b>#{sentence}</b></p>
17
+ <ul>#{messages}</ul>
18
+ </div>
19
+ HTML
20
+
21
+ html.html_safe
22
+ end
23
+
24
+ %w[email_field password_field text_field text_area].each do |method_name|
25
+ define_method method_name do |*args|
26
+ options = args.extract_options!
27
+ name = args.first
28
+ wrapper name, options do
29
+ if method_name == 'text_area'
30
+ super(name, rows: 7)
31
+ else
32
+ super(name)
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ def check_box(name)
39
+ wrapper name do
40
+ content_tag :label, class: 'checkbox' do
41
+ super(name)
42
+ end
43
+ end
44
+ end
45
+
46
+ def submit(value=nil)
47
+ content_tag :div, class: 'form-actions' do
48
+ super value, class: 'btn btn-primary'
49
+ end
50
+ end
51
+
52
+ private
53
+ def wrapper(name, options = {}, &block)
54
+ content_tag :div, class: ['control-group', ('error' if @object.errors[name].present?)] do
55
+ safe_join [
56
+ label(name, class: 'control-label'),
57
+ content_tag(:div, class: 'controls'){
58
+ safe_join [
59
+ yield,
60
+ (content_tag(:p, options[:hint], class: 'help-block') if options[:hint].present?)
61
+ ]
62
+ }
63
+ ]
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,8 @@
1
+ module BooterHelper
2
+ def nice_form_for(object, options = {}, &block)
3
+ options[:builder] = BootstrapFormBuilder
4
+ options[:html] ||= {}
5
+ options[:html][:class] = 'form-horizontal'
6
+ form_for(object, options, &block)
7
+ end
8
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/booter/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Alexey Vakhov"]
6
+ gem.email = ["vakhov@gmail.com"]
7
+ gem.description = %q{Twitter bootstrap for Rails}
8
+ gem.summary = %q{Twitter bootstrap framework wrapper}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "booter"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Booter::VERSION
17
+
18
+ gem.add_dependency 'rails', '~> 3.2'
19
+ end
@@ -0,0 +1,2 @@
1
+ require "booter/version"
2
+ require "booter/engine"
@@ -0,0 +1,4 @@
1
+ module Booter
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Booter
2
+ VERSION = "0.2.2"
3
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: booter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alexey Vakhov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &83935090 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *83935090
25
+ description: Twitter bootstrap for Rails
26
+ email:
27
+ - vakhov@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - app/assets/images/glyphicons-halflings-white.png
38
+ - app/assets/images/glyphicons-halflings.png
39
+ - app/assets/javascripts/bootstrap.js
40
+ - app/assets/stylesheets/bootstrap-responsive.css
41
+ - app/assets/stylesheets/bootstrap.css.scss
42
+ - app/form_builders/bootstrap_form_builder.rb
43
+ - app/helpers/booter_helper.rb
44
+ - booter.gemspec
45
+ - lib/booter.rb
46
+ - lib/booter/engine.rb
47
+ - lib/booter/version.rb
48
+ homepage: ''
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ segments:
61
+ - 0
62
+ hash: -742628685
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ segments:
70
+ - 0
71
+ hash: -742628685
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 1.8.17
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Twitter bootstrap framework wrapper
78
+ test_files: []