Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bootstrapped

  • Loading branch information...
commit de3e0f0766d3a70e41b6844705e169336d9fa3fb 1 parent 8ff6d47
benjab authored
View
15 Gemfile
@@ -5,13 +5,14 @@ gem 'rails', '3.2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
-gem 'sqlite3'
-
+group :development, :test do
+ gem 'sqlite3'
+end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
- gem 'sass-rails', '~> 3.2.3'
+ gem 'less-rails', '~> 2.1.0'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
@@ -20,6 +21,14 @@ group :assets do
gem 'uglifier', '>= 1.0.3'
end
+gem 'simple_form', :git => 'git://github.com/plataformatec/simple_form.git', :ref => "9f7a7bcbb9323e91cf8b9261bf2b31c2a174b342"
+gem 'twitter-bootstrap-rails'
+
+group :production do
+ gem 'pg'
+ gem 'yui-compressor'
+end
+
gem 'jquery-rails'
# To use ActiveModel has_secure_password
View
43 Gemfile.lock
@@ -1,6 +1,19 @@
+GIT
+ remote: git://github.com/plataformatec/simple_form.git
+ revision: 9f7a7bcbb9323e91cf8b9261bf2b31c2a174b342
+ ref: 9f7a7bcbb9323e91cf8b9261bf2b31c2a174b342
+ specs:
+ simple_form (2.0.0.dev)
+ actionpack (~> 3.0)
+ activemodel (~> 3.0)
+
GEM
remote: https://rubygems.org/
specs:
+ POpen4 (0.1.4)
+ Platform (>= 0.4.0)
+ open4
+ Platform (0.4.0)
actionmailer (3.2.1)
actionpack (= 3.2.1)
mail (~> 2.4.0)
@@ -37,6 +50,8 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.2.0)
+ commonjs (0.2.0)
+ therubyracer (~> 0.9.9)
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
@@ -47,12 +62,21 @@ GEM
railties (>= 3.2.0.beta, < 5.0)
thor (~> 0.14)
json (1.6.5)
+ less (2.0.9)
+ commonjs (~> 0.2.0)
+ therubyracer (~> 0.9.9)
+ less-rails (2.1.5)
+ actionpack (>= 3.1)
+ less (~> 2.0.7)
+ libv8 (3.3.10.4)
mail (2.4.1)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.4)
+ open4 (1.3.0)
+ pg (0.12.2)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.1)
@@ -79,25 +103,28 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
- sass (3.1.12)
- sass-rails (3.2.4)
- railties (~> 3.2.0)
- sass (>= 3.1.10)
- tilt (~> 1.3)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
+ therubyracer (0.9.9)
+ libv8 (~> 3.3.10)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
+ twitter-bootstrap-rails (2.0)
+ actionpack (>= 3.2.1)
+ less-rails (~> 2.1.2)
+ railties (>= 3.2.1)
tzinfo (0.3.31)
uglifier (1.2.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
+ yui-compressor (0.9.6)
+ POpen4 (>= 0.1.4)
PLATFORMS
ruby
@@ -105,7 +132,11 @@ PLATFORMS
DEPENDENCIES
coffee-rails (~> 3.2.1)
jquery-rails
+ less-rails (~> 2.1.0)
+ pg
rails (= 3.2.1)
- sass-rails (~> 3.2.3)
+ simple_form!
sqlite3
+ twitter-bootstrap-rails
uglifier (>= 1.0.3)
+ yui-compressor
View
1  app/assets/javascripts/application.js
@@ -12,4 +12,5 @@
//
//= require jquery
//= require jquery_ujs
+//= require twitter/bootstrap
//= require_tree .
View
22 app/assets/javascripts/bootstrap.js.coffee
@@ -0,0 +1,22 @@
+$ ->
+ $(".alert-message").alert()
+$ ->
+ $(".tabs").button()
+$ ->
+ $(".carousel").carousel()
+$ ->
+ $(".collapse").collapse()
+$ ->
+ $(".dropdown-toggle").dropdown()
+$ ->
+ $(".modal").modal
+$ ->
+ $("a[rel]").popover
+$ ->
+ $(".navbar").scrollspy()
+$ ->
+ $(".tab").tab "show"
+$ ->
+ $(".tooltip").tooltip
+$ ->
+ $(".typeahead").typeahead()
View
1  app/assets/stylesheets/application.css
@@ -8,6 +8,7 @@
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
+ *= require twitter/bootstrap
*= require_self
*= require_tree .
*/
View
3  app/assets/stylesheets/bootstrap.css.less
@@ -0,0 +1,3 @@
+// Baseline grid
+@basefont: 13px;
+@baseline: 18px;
View
5 config/application.rb
@@ -55,5 +55,10 @@ class Application < Rails::Application
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
+
+ # Added from bootstrap
+ config.app_generators.stylesheet_engine :less
+ config.assets.initialize_on_precompile = false
+
end
end
View
3  config/environments/production.rb
@@ -13,6 +13,9 @@
# Compress JavaScripts and CSS
config.assets.compress = true
+
+ # Compress yui CSS
+ config.assets.css_compressor = :yui
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
View
148 config/initializers/simple_form.rb
@@ -0,0 +1,148 @@
+SimpleForm.setup do |config|
+ # Wrappers are used by the form builder to generate a complete input.
+ # You can remove any component from the wrapper, change the order or even
+ # add your own to the stack. The options given to the wrappers method
+ # are used to wrap the whole input (if any exists).
+ config.wrappers :bootstrap, :tag => 'fieldset', :class => 'control-group', :error_class => 'error' do |b|
+ b.use :placeholder
+ b.use :label, :class => 'control-label'
+ b.use :tag => 'div', :class => 'controls' do |ba|
+ ba.use :input
+ ba.use :error, :tag => 'span', :class => 'help-inline'
+ ba.use :hint, :tag => 'p', :class => 'help-block'
+ end
+ end
+
+ config.wrappers :checkbox, :tag => 'fieldset', :class => 'control-group', :error_class => 'error' do |b|
+ b.use :placeholder
+ b.use :label, :class => 'control-label'
+ b.use :tag => 'div', :class => 'controls' do |ba|
+ ba.use :tag => 'label', :class => 'checkbox' do |bb|
+ bb.use :input
+ end
+ ba.use :error, :tag => 'span', :class => 'help-inline'
+ ba.use :hint, :tag => 'p', :class => 'help-block'
+ end
+ end
+
+ config.wrappers :inline_checkbox, :tag => 'span', :error_class => 'error' do |b|
+ b.use :placeholder
+ b.use :input
+ b.use :label_text
+ b.use :error, :tag => 'span', :class => 'help-inline'
+ b.use :hint, :tag => 'p', :class => 'help-block'
+ end
+
+ config.wrappers :inline, :class => 'clearfix', :error_class => :error do |b|
+ b.use :placeholder
+ b.use :label
+ b.use :tag => 'div', :class => 'input' do |ba|
+ ba.use :input
+ ba.use :error, :tag => :span, :class => :'help-inline'
+ ba.use :hint, :tag => :span, :class => :'help-block'
+ end
+ end
+
+ config.wrappers :stacked, :class => "clearfix", :error_class => :error do |b|
+ b.use :placeholder
+ b.use :label
+ b.use :hint, :tag => :span, :class => :'help-block'
+ b.use :tag => 'div', :class => 'input' do |input|
+ input.use :input
+ input.use :error, :tag => :span, :class => :'help-inline'
+ end
+ end
+
+ config.wrappers :prepend, :class => "clearfix", :error_class => :error do |b|
+ b.use :placeholder
+ b.use :label
+ b.use :hint, :tag => :span, :class => :'help-block'
+ b.use :tag => 'div', :class => 'input' do |input|
+ input.use :tag => 'div', :class => 'input-prepend' do |prepend|
+ prepend.use :input
+ end
+ input.use :error, :tag => :span, :class => :'help-inline'
+ end
+ end
+
+ config.wrappers :append, :class => "clearfix", :error_class => :error do |b|
+ b.use :placeholder
+ b.use :label
+ b.use :hint, :tag => :span, :class => :'help-block'
+ b.use :tag => 'div', :class => 'input' do |input|
+ input.use :tag => 'div', :class => 'input-append' do |append|
+ append.use :input
+ end
+ input.use :error, :tag => :span, :class => :'help-inline'
+ end
+ end
+
+ # Method used to tidy up errors.
+ # config.error_method = :first
+
+ # Default tag used for error notification helper.
+ # config.error_notification_tag = :p
+
+ # CSS class to add for error notification helper.
+ # config.error_notification_class = :error_notification
+
+ # ID to add for error notification helper.
+ # config.error_notification_id = nil
+
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
+ # config.collection_wrapper_tag = nil
+
+ # You can wrap each item in a collection of radio/check boxes with a tag, defaulting to span.
+ # config.item_wrapper_tag = :span
+
+ # Series of attempts to detect a default label method for collection.
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
+
+ # Series of attempts to detect a default value method for collection.
+ # config.collection_value_methods = [ :id, :to_s ]
+
+ # How the label text should be generated altogether with the required text.
+ config.label_text = lambda { |label, required| "#{label} #{required}" }
+
+ # You can define the class to use on all labels. Default is nil.
+ # config.label_class = nil
+
+ # You can define the class to use on all forms. Default is simple_form.
+ # config.form_class = :simple_form
+
+ # Whether attributes are required by default (or not). Default is true.
+ # config.required_by_default = true
+
+ # Tell browsers whether to use default HTML5 validations (novalidate option).
+ # Default is enabled.
+ config.browser_validations = false
+
+ # Determines whether HTML5 types (:email, :url, :search, :tel) and attributes
+ # (e.g. required) are used or not. True by default.
+ # Having this on in non-HTML5 compliant sites can cause odd behavior in
+ # HTML5-aware browsers such as Chrome.
+ # config.html5 = true
+
+ # Custom mappings for input types. This should be a hash containing a regexp
+ # to match as key, and the input type that will be used when the field name
+ # matches the regexp as value.
+ # config.input_mappings = { /count/ => :integer }
+
+ # Collection of methods to detect if a file type was given.
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
+
+ # Default priority for time_zone inputs.
+ # config.time_zone_priority = nil
+
+ # Default priority for country inputs.
+ # config.country_priority = nil
+
+ # Default size for text inputs.
+ # config.default_input_size = 50
+
+ # When false, do not use translations for labels, hints or placeholders.
+ # config.translate = true
+
+ # Default class for buttons
+ config.button_class = 'btn'
+end
View
24 config/locales/simple_form.en.yml
@@ -0,0 +1,24 @@
+en:
+ simple_form:
+ "yes": 'Yes'
+ "no": 'No'
+ required:
+ text: 'required'
+ mark: '*'
+ # You can uncomment the line below if you need to overwrite the whole required html.
+ # When using html, text and mark won't be used.
+ # html: '<abbr title="required">*</abbr>'
+ error_notification:
+ default_message: "Some errors were found, please take a look:"
+ # Labels and hints examples
+ # labels:
+ # password: 'Password'
+ # user:
+ # new:
+ # email: 'E-mail para efetuar o sign in.'
+ # edit:
+ # email: 'E-mail.'
+ # hints:
+ # username: 'User name to sign in.'
+ # password: 'No special characters, please.'
+
View
13 lib/templates/erb/scaffold/_form.html.erb
@@ -0,0 +1,13 @@
+<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
+ <%%= f.error_notification %>
+
+ <div class="inputs">
+ <%- attributes.each do |attribute| -%>
+ <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
+ <%- end -%>
+ </div>
+
+ <div class="actions">
+ <%%= f.button :submit %>
+ </div>
+<%% end %>
Please sign in to comment.
Something went wrong with that request. Please try again.