Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Last update before moving to MBP

  • Loading branch information...
commit c68854da1d4428773f0cd1582aeb49e3b67a6ee7 1 parent 190d9f2
@safarista authored
View
11 Gemfile
@@ -5,12 +5,8 @@ gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
-gem 'sqlite3', group: [:development, :test]
-
-group :production do
- gem 'pg'
- gem 'thin'
-end
+gem 'pg'
+gem 'thin'
# Gems used only for assets and not required
# in production environments by default.
@@ -22,7 +18,7 @@ group :assets do
gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
- gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
+ gem 'bootstrap-sass'
end
gem 'jquery-rails'
@@ -58,3 +54,4 @@ gem 'mini_magick'
# Pagination and scrolling log articles
gem 'kaminari'
+gem 'simple_form'
View
55 Gemfile.lock
@@ -5,15 +5,6 @@ GIT
specs:
cancan (2.0.0.alpha)
-GIT
- remote: git://github.com/seyhunak/twitter-bootstrap-rails.git
- revision: eb348d89373bd3828848887bc0f7c3a6aed236d9
- specs:
- twitter-bootstrap-rails (2.0.6)
- actionpack (>= 3.1)
- less-rails (~> 2.2.0)
- railties (>= 3.1)
-
GEM
remote: https://rubygems.org/
specs:
@@ -44,9 +35,9 @@ GEM
activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
- addressable (2.2.7)
arel (3.0.2)
bcrypt-ruby (3.0.1)
+ bootstrap-sass (2.0.3.1)
builder (3.0.0)
carrierwave (0.6.2)
activemodel (>= 3.2.0)
@@ -57,18 +48,15 @@ GEM
coffee-script (2.2.0)
coffee-script-source
execjs
- coffee-script-source (1.3.1)
- commonjs (0.2.5)
+ coffee-script-source (1.3.3)
daemons (1.1.8)
erubis (2.7.0)
eventmachine (0.12.10)
excon (0.13.4)
- execjs (1.3.0)
+ execjs (1.4.0)
multi_json (~> 1.0)
- faraday (0.7.6)
- addressable (~> 2.2)
+ faraday (0.8.1)
multipart-post (~> 1.1)
- rack (~> 1.1)
fog (1.3.1)
builder
excon (~> 0.13.0)
@@ -79,25 +67,19 @@ GEM
net-ssh (>= 2.1.3)
nokogiri (~> 1.5.0)
ruby-hmac
- formatador (0.2.1)
- friendly_id (4.0.4)
+ formatador (0.2.3)
+ friendly_id (4.0.6)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
jquery-rails (2.0.2)
railties (< 5.0, >= 3.2.0)
thor (~> 0.14)
- json (1.6.6)
+ json (1.7.3)
kaminari (0.13.0)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
- less (2.1.0)
- commonjs (~> 0.2.0)
- therubyracer (~> 0.10.0)
- less-rails (2.2.1)
- actionpack (>= 3.1)
- less (~> 2.1.0)
libv8 (3.3.10.4)
mail (2.4.4)
i18n (>= 0.4.0)
@@ -106,13 +88,13 @@ GEM
mime-types (1.18)
mini_magick (3.4)
subexec (~> 0.2.1)
- multi_json (1.3.2)
+ multi_json (1.3.6)
multipart-post (1.1.5)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
- net-ssh (2.3.0)
+ net-ssh (2.5.2)
nokogiri (1.5.2)
- oauth (0.4.5)
+ oauth (0.4.6)
oauth2 (0.5.2)
faraday (~> 0.7)
multi_json (~> 1.0)
@@ -145,19 +127,22 @@ GEM
json (~> 1.4)
redcarpet (2.1.1)
ruby-hmac (0.4.0)
- sass (3.1.15)
+ sass (3.1.19)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
- sorcery (0.7.11)
+ simple_form (2.0.2)
+ actionpack (~> 3.0)
+ activemodel (~> 3.0)
+ sorcery (0.7.12)
+ bcrypt-ruby (~> 3.0.0)
oauth (~> 0.4.4)
oauth2 (~> 0.5.1)
- sprockets (2.1.2)
+ sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
- tilt (!= 1.3.0, ~> 1.1)
- sqlite3 (1.3.6)
+ tilt (~> 1.1, != 1.3.0)
subexec (0.2.2)
therubyracer (0.10.1)
libv8 (~> 3.3.10)
@@ -180,6 +165,7 @@ PLATFORMS
DEPENDENCIES
bcrypt-ruby (~> 3.0.0)
+ bootstrap-sass
cancan!
carrierwave
coffee-rails (~> 3.2.1)
@@ -192,9 +178,8 @@ DEPENDENCIES
rails (= 3.2.3)
redcarpet
sass-rails (~> 3.2.3)
+ simple_form
sorcery
- sqlite3
therubyracer
thin
- twitter-bootstrap-rails!
uglifier (>= 1.0.3)
View
2  app/assets/javascripts/application.js
@@ -12,5 +12,5 @@
//
//= require jquery
//= require jquery_ujs
-//= require twitter/bootstrap
+//= require bootstrap
//= require_tree .
View
42 ...lesheets/bootstrap_and_overrides.css.less → ...lesheets/bootstrap_and_overrides.css.scss
@@ -1,33 +1,20 @@
-@import "twitter/bootstrap/bootstrap";
-body { padding-top: 60px; }
+// Set the correct sprite paths
+$iconSpritePath: image-path('glyphicons-halflings.png');
+$iconWhiteSpritePath: image-path('glyphicons-halflings-white.png');
-@import "twitter/bootstrap/responsive";
+//$navbarBackground: #555;
+//$navbarBackgroundHighlight: #888;
+//$navbarText: #eee;
+//$navbarLinkColor: #eee;
-// Set the correct sprite paths
-@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
-@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
-
-// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
-@fontAwesomeEotPath: asset-path('fontawesome-webfont.eot');
-@fontAwesomeWoffPath: asset-path('fontawesome-webfont.woff');
-@fontAwesomeTtfPath: asset-path('fontawesome-webfont.ttf');
-@fontAwesomeSvgzPath: asset-path('fontawesome-webfont.svgz');
-@fontAwesomeSvgPath: asset-path('fontawesome-webfont.svg');
-
-// Font Awesome
-@import "fontawesome";
-
-// Your custom LESS stylesheets goes here
-//
-// Since bootstrap was imported above you have access to its mixins which
-// you may use and inherit here
-//
-// If you'd like to override bootstrap's own variables, you can do so here as well
-// See http://twitter.github.com/bootstrap/less.html for their names and documentation
-//
-// Example:
-// @linkColor: #ff0000;
+@import "bootstrap";
+body { padding-top: 60px; }
+
+@import "bootstrap-responsive";
+.navbar .brand {
+ color: #fff;
+}
// .span3{margin-left:20px;width:220px;}
// .masthead {
// padding-top: 36px;
@@ -194,3 +181,4 @@ color: #999;
}
}
+.field_with_error input{border: 1px dashed red;}
View
4 app/controllers/posts_controller.rb
@@ -63,9 +63,7 @@ def create
# PUT /posts/1
# PUT /posts/1.json
def update
- @post = Post.try(:find, params[:id])
- @post.published = Time.now # if !params[:post][:published].blank?
-
+ @post = Post.try(:find, params[:id])
respond_to do |format|
if @post.update_attributes(params[:post])
View
4 app/controllers/safaris_controller.rb
@@ -2,8 +2,8 @@ class SafarisController < ApplicationController
# # Filters and Authorization
skip_before_filter :require_login, :only => [:index, :show]
- # load_and_authorize_resource :safari # no customization needed here
- # load_and_authorize_resource :destination, :through => :safari
+ load_and_authorize_resource :safari # no customization needed here
+ load_and_authorize_resource :destination, :through => :safari
# before_filter :authorize_parent
# GET /safaris
View
6 app/models/comment.rb
@@ -1,7 +1,11 @@
class Comment < ActiveRecord::Base
+
+ # Associations
belongs_to :post
+
+ # MassAssignment protection
attr_accessible :comment_email, :commenter, :content, :ip_address_info, :comment_url
# Validations
- validates :comment_email, :commenter, :content, presence: true
+ validates :comment_email, :commenter, :content, :comment_url, presence: true
end
View
5 app/views/posts/_form.html.erb
@@ -16,7 +16,7 @@
<div class="control-group">
<%= f.label :title, :class => 'control-label' %>
<div class="controls">
- <%= f.text_field :title, required: true, :class => 'span6' %>
+ <%= f.text_field :title, required: true, autofocus: true, :class => 'span6' %>
</div>
</div>
@@ -26,13 +26,14 @@
<%= f.text_area :content, :class => 'span7', rows: 9, required: true %>
</div>
</div>
-
+ <!-- === Disable until I can fix it ===
<div class="control-group">
<%= f.label :published, :class => 'control-label' %>
<div class="controls">
<%= f.check_box :published %>
</div>
</div>
+ -->
<div class="control-group">
<%= f.label :ban_comments, :class => 'control-label' %>
<div class="controls">
View
2  app/views/posts/index.html.erb
@@ -10,7 +10,7 @@
<h1><%= link_to post.title, post_path(post), title: post.title %></h1>
<p>
<small>
- <%= time_tag post.published, format: '%m %b %Y', pubdate: true if post.published? %>
+ <%= time_tag post.published, pubdate: true if post.published? %>
<b>By:</b> <%= link_to post.user.full_name, user_path(post.user), title: post.user.full_name %>
&bull;
<i>(<%= post.comments.count %>) Comments</i>
View
2  app/views/posts/show.html.erb
@@ -33,7 +33,7 @@
<table class="table">
<tr>
<td class="span2">
- <p><%= link_to comment.commenter, comment.comment_url? ? comment.comment_url : '#', title: comment.commenter, target: '_blank' %><br>
+ <p><%= link_to comment.commenter, comment.comment_url? ? comment.comment_url : 'http://beachboy.herokuapp.com/', title: comment.commenter, target: '_blank' %><br>
<small><%= distance_of_time_in_words comment.created_at, Time.now %> ago</small></p>
</td>
<td><%= markdown comment.content %></td>
View
4 app/views/sessions/new.html.erb
@@ -3,13 +3,13 @@
<div class="control-group">
<%= label_tag :username, nil, class: 'control-label' %>
<div class="controls">
- <%= text_field_tag :username, nil, placeholder: 'Username' %>
+ <%= text_field_tag :username, nil, autofocus: true, required: true, placeholder: 'Username' %>
</div>
</div>
<div class="control-group">
<%= label_tag :password, nil, class: 'control-label' %>
<div class="controls">
- <%= password_field_tag :password, nil, placeholder: 'Password' %>
+ <%= password_field_tag :password, nil, required: true, placeholder: 'Password' %>
</div>
</div>
View
30 config/database.yml
@@ -1,25 +1,23 @@
-# SQLite version 3.x
-# gem install sqlite3
+# Postgresql version 9.1.3
+# gem install pg
#
-# Ensure the SQLite 3 gem is defined in your Gemfile
-# gem 'sqlite3'
+# Ensure the Postgresql gem is defined in your Gemfile
+# gem 'pg'
development:
- adapter: sqlite3
- database: db/development.sqlite3
+ adapter: postgresql
+ encoding: unicode
+ database: bats_development
pool: 5
- timeout: 5000
+ username: safarista
+ password:
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
- adapter: sqlite3
- database: db/test.sqlite3
+ adapter: postgresql
+ encoding: unicode
+ database: bats_test
pool: 5
- timeout: 5000
-
-production:
- adapter: sqlite3
- database: db/production.sqlite3
- pool: 5
- timeout: 5000
+ username: safarista
+ password:
View
178 config/initializers/simple_form.rb
@@ -0,0 +1,178 @@
+# Use this setup block to configure all options available in SimpleForm.
+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 below are used to wrap the
+ # whole input.
+ config.wrappers :default, :class => :input,
+ :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
+ ## Extensions enabled by default
+ # Any of these extensions can be disabled for a
+ # given input by passing: `f.input EXTENSION_NAME => false`.
+ # You can make any of these extensions optional by
+ # renaming `b.use` to `b.optional`.
+
+ # Determines whether to use HTML5 (:email, :url, ...)
+ # and required attributes
+ b.use :html5
+
+ # Calculates placeholders automatically from I18n
+ # You can also pass a string as f.input :placeholder => "Placeholder"
+ b.use :placeholder
+
+ ## Optional extensions
+ # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
+ # to the input. If so, they will retrieve the values from the model
+ # if any exists. If you want to enable the lookup for any of those
+ # extensions by default, you can change `b.optional` to `b.use`.
+
+ # Calculates maxlength from length validations for string inputs
+ b.optional :maxlength
+
+ # Calculates pattern from format validations for string inputs
+ b.optional :pattern
+
+ # Calculates min and max from length validations for numeric inputs
+ b.optional :min_max
+
+ # Calculates readonly automatically from readonly attributes
+ b.optional :readonly
+
+ ## Inputs
+ b.use :label_input
+ b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
+ b.use :error, :wrap_with => { :tag => :span, :class => :error }
+ end
+
+ config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
+ b.use :html5
+ b.use :placeholder
+ b.use :label
+ b.wrapper :tag => 'div', :class => 'controls' do |ba|
+ ba.use :input
+ ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
+ ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
+ end
+ end
+
+ config.wrappers :prepend, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
+ b.use :html5
+ b.use :placeholder
+ b.use :label
+ b.wrapper :tag => 'div', :class => 'controls' do |input|
+ input.wrapper :tag => 'div', :class => 'input-prepend' do |prepend|
+ prepend.use :input
+ end
+ input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
+ input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
+ end
+ end
+
+ config.wrappers :append, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
+ b.use :html5
+ b.use :placeholder
+ b.use :label
+ b.wrapper :tag => 'div', :class => 'controls' do |input|
+ input.wrapper :tag => 'div', :class => 'input-append' do |append|
+ append.use :input
+ end
+ input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
+ input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
+ end
+ end
+
+ # Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
+ # Check the Bootstrap docs (http://twitter.github.com/bootstrap)
+ # to learn about the different styles for forms and inputs,
+ # buttons and other elements.
+ config.default_wrapper = :bootstrap
+
+ # Define the way to render check boxes / radio buttons with labels.
+ # Defaults to :nested for bootstrap config.
+ # :inline => input + label
+ # :nested => label > input
+ config.boolean_style = :nested
+
+ # Default class for buttons
+ config.button_class = 'btn'
+
+ # Method used to tidy up errors. Specify any Rails Array method.
+ # :first lists the first message for each field.
+ # Use :to_sentence to list all errors for each field.
+ # config.error_method = :first
+
+ # Default tag used for error notification helper.
+ config.error_notification_tag = :div
+
+ # CSS class to add for error notification helper.
+ config.error_notification_class = 'alert alert-error'
+
+ # ID to add for error notification helper.
+ # config.error_notification_id = nil
+
+ # 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 ]
+
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
+ # config.collection_wrapper_tag = nil
+
+ # You can define the class to use on all collection wrappers. Defaulting to none.
+ # config.collection_wrapper_class = nil
+
+ # You can wrap each item in a collection of radio/check boxes with a tag,
+ # defaulting to :span. Please note that when using :boolean_style = :nested,
+ # SimpleForm will force this option to be a label.
+ # config.item_wrapper_tag = :span
+
+ # You can define a class to use in all item wrappers. Defaulting to none.
+ # config.item_wrapper_class = nil
+
+ # How the label text should be generated altogether with the required text.
+ # config.label_text = lambda { |label, required| "#{required} #{label}" }
+
+ # You can define the class to use on all labels. Default is nil.
+ config.label_class = 'control-label'
+
+ # You can define the class to use on all forms. Default is simple_form.
+ # config.form_class = :simple_form
+
+ # You can define which elements should obtain additional classes
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
+
+ # 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
+
+ # Collection of methods to detect if a file type was given.
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
+
+ # 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 }
+
+ # 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.
+ # config.translate_labels = true
+
+ # Automatically discover new inputs in Rails' autoload path.
+ # config.inputs_discovery = true
+
+ # Cache SimpleForm inputs discovery
+ # config.cache_discovery = !Rails.env.development?
+end
View
26 config/locales/simple_form.en.yml
@@ -0,0 +1,26 @@
+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: "Please review the problems below:"
+ # Labels and hints examples
+ # labels:
+ # defaults:
+ # password: 'Password'
+ # user:
+ # new:
+ # email: 'E-mail to sign in.'
+ # edit:
+ # email: 'E-mail.'
+ # hints:
+ # defaults:
+ # 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="form-inputs">
+ <%- attributes.each do |attribute| -%>
+ <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
+ <%- end -%>
+ </div>
+
+ <div class="form-actions">
+ <%%= f.button :submit %>
+ </div>
+<%% end %>
Please sign in to comment.
Something went wrong with that request. Please try again.