Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to rails 3.0.4, fixes some security issues #12

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions Gemfile

This file was deleted.

47 changes: 44 additions & 3 deletions README.textile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Read the "Gemfile":blob/master/Gemfile to understand everything this template installs and pre-configures for you.
Read the "Gemfile":blob/master/files/Gemfile to understand everything this template installs and pre-configures for you.

One of gems, "Johnson":http://rubygems.org/gems/johnson, still has some issues compiling under Ruby 1.9.2 so you will need to use Ruby 1.8.7 instead.

Expand All @@ -8,10 +8,51 @@ This template is heavily dependent on wget so, if you're using a Mac, you will n

Since Github started forcing SSL in all its URLs, we need to download the template file separately:

<pre><code>wget --no-check-certificate https://github.com/dcrec1/rails3_template/raw/master/main.rb -O /tmp/rails3_template.rb</pre></code>
<pre><code>wget --no-check-certificate https://github.com/akitaonrails/rails3_template/raw/master/main.rb -O /tmp/rails3_template.rb</pre></code>

Then whenever you want to create a new project, just do:

<pre><code>rails new app_name -T -m /tmp/rails3_template.rb</code></pre>
<pre><code>rails new app_name -JT -m /tmp/rails3_template.rb</code></pre>

Change <tt>app_name</tt> for your project name. You can configure what you need and run <tt>rake db:migrate</tt> to get started.

h2. CRITERIA

This is intended to be an opinionated template. The options chosen have these reasons:

* Standard ERB instead of HAML - even though HAML is great the pros and cons are too balanced to justify replacing ERB.
* Simple Form instead of Formtastic - to me, "feels" simpler
* SASS instead of pure CSS - this undeniably adds value on top of CSS making it easier to organize
* JQuery instead of Prototype - no need to say more
* Kaminari instead of Will Paginate - cleaner solution for pagination
* Pure Javascript instead of CoffeeScript - as HAML, the syntax gets more elegant, but there is no inherent advantages
* RSpec, Factory Girl Cucumber, Spork, Capybara, Celerity, Faker, Metric Fu - this is the universally accepted main test package, so be it
* Evergreen - testing Javascript is great and this seems to be the best so far
* Devise - the best authentication system so far
* Inherited Resources - lighter controllers
* Compass, Asset Packager, Lemonade - easier way to deal with images and other assets
* Cells - this is experimental but does bring advantages in making controller less cluttered and isolating components

So, opinionated to a point, trying to stick to the basics where advantages are not so obvious.

h2. TESTING

Read Peter Cooper's "excellent tutorial":http://www.rubyinside.com/how-to-rails-3-and-rspec-2-4336.html on how to setup a fast testing environment:

This template tries to do so. Before starting just run:

<pre><code>spork</code></pre>

And in another terminal run:

<pre><code>rake watchr</code></pre>

Also do not forget to modify <tt>config/environments/test.rb</tt> to reload classes:

<pre><code>config.cache_classes = false</code></pre>

h2. CREDITS

This Template is based on "Diego Carrion's template":https://github.com/dcrec1/rails3_template. The changes include removing HAML, Hoptoad, Coffeescript (Barista), Remarkable, adding yajl for json, thin, replacing will_paginate for kaminari, replacing autotest for watchr, enabling spork, replacing formtastic for simple_form, bundling gems within the app,

Author: Fabio Akita (@AkitaOnRails)
18 changes: 0 additions & 18 deletions application.html.haml

This file was deleted.

5 changes: 0 additions & 5 deletions build.rake

This file was deleted.

2 changes: 0 additions & 2 deletions build.sh

This file was deleted.

57 changes: 57 additions & 0 deletions files/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
source 'http://rubygems.org'

gem 'rails', '3.0.5'

gem 'sqlite3-ruby', :require => 'sqlite3'

gem "rails_admin", :git => 'https://github.com/sferik/rails_admin.git'
gem "inherited_resources"
gem "kaminari"
gem "devise"
gem "simple_form"
gem "friendly_id"
gem "compass"
gem "lemonade"
gem "cells"
gem 'yajl-ruby', :require => 'yajl/json_gem'

group :development do
gem "watchr"
gem "rails3-generators", :git => "https://github.com/indirect/rails3-generators.git"
gem "metric_fu"
end

group :development, :test do
gem "spork"
gem "thin"
gem "evergreen"
gem "factory_girl_rails"
gem "rspec-rails"
gem "rspec-cells"
gem "faker"
gem "evergreen", :require => "evergreen/rails"
platforms :mri_18 do
gem "ruby-debug"
end
platforms :mri_19 do
gem "ruby-debug19", :require => 'ruby-debug'
end
end

group :test do
gem "rspec"
gem "capybara-envjs"
end

group :cucumber do
gem "cucumber"
gem "cucumber-rails"
gem "capybara"
gem "database_cleaner"
gem "spork"
gem "pickle"
end

group :production do
gem "newrelic_rpm"
end
1 change: 1 addition & 0 deletions files/application.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- Add the rendered HTML from your application over which the javascript will act -->
29 changes: 29 additions & 0 deletions files/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en" xml:lang="en">
<head>
<title>TITLE</title>
<%= raw stylesheet_link_merged('screen', :media => 'screen, projection') %>
<%= raw stylesheet_link_merged('simple_form', :media => 'screen, projection') %>
<%= raw stylesheet_link_merged('print', :media => 'print') %>
<!--[if lt IE 9]>
<%= javascript_include_tag 'html5' %>
<%= raw stylesheet_link_merged('ie', :media => 'screen, projection') %>
<![endif]-->
<%= csrf_meta_tag %>
</head>
<body>
<div id="container">
<header>HEADER</header>
<sidebar>SIDEBAR</sidebar>
<section id="content">
<% content_for :notice do %><p class="notice"><%= notice %></p><% end %>
<% content_for :alert do %><p class="alert"><%= alert %></p><% end %>
<%= yield %>
</section>
<footer>FOOTER</footer>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js"></script>
<%= raw javascript_include_merged(:base) %>
</body>
</html>
39 changes: 39 additions & 0 deletions files/application_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Example of how to add javascript specs
//
// require("/jquery.js");
// require("/jquery-ui.js");
// require("/application.js");
// $.ready();
//
// describe("with main template", function() {
// template('application.html');
//
// describe("on load", function() {
// beforeEach(function() {
// });
//
// it("should set select as text inputs", function() {
// expect($("#sign_in")).toBeATextInput();
// });
//
// it("should not set all select as text inputs", function() {
// expect($("#select")).not.toBeATextInput();
// });
//
// it("should hide the anchor", function() {
// $("#container a.next").show();
// $("#container a.next").click();
// expect($("#playboard a.next")).toBeHidden();
// });
//
// it("should show .matches nav a.prev", function() {
// $("#container a.prev").hide();
// $("#container a.next").click();
// expect($("#playboard a.prev")).toBeVisible();
// });
//
// it("should prevent the event default", function() {
// expect(eventForSelectorHandler("#container a.prev", "click")).toBeDefaultPrevented();
// });
// })
// })
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions files/build.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
task :clean do
system "rm rerun.txt"
end

task :build => [:clean, 'db:migrate', :spec, 'spec:javascripts', :cucumber, 'metrics:all']
2 changes: 2 additions & 0 deletions files/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bundle install --without=production
rake build
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
6 changes: 6 additions & 0 deletions files/html5.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes
File renamed without changes.
23 changes: 23 additions & 0 deletions files/rails_admin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
RailsAdmin.authenticate_with { authenticate_admin! }

# Read https://github.com/sferik/rails_admin for more options
# Examples:
#
# RailsAdmin.config do |config|
# config.models do
# list do
# sort_by :updated_at
# sort_reverse true
# end
# end
#
# config.model MyModel do
# edit do
# field :description, :text do
# ckeditor do
# true
# end
# end
# end
# end
# end
File renamed without changes.
43 changes: 43 additions & 0 deletions files/simple_form.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.simple_form {
label {
float: left;
width: 100px;
text-align: right;
margin: 2px 10px;
}

div.input {
margin-bottom: 10px;
}

div.boolean, .simple_form input[type='submit'] {
margin-left: 120px;
}

div.boolean label, .simple_form label.collection_radio {
float: none;
margin: 0;
}

label.collection_radio {
margin-right: 10px;
margin-left: 2px;
}

.error {
clear: left;
margin-left: 120px;
font-size: 12px;
color: #D00;
display: block;
}

.hint {
clear: left;
margin-left: 120px;
font-size: 12px;
color: #555;
display: block;
font-style: italic;
}
}
36 changes: 36 additions & 0 deletions files/spec_helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function eventForSelectorHandler(selector, eventType) {
var lives = jQuery.data(document, "events").live;
for (var i = 0; i < lives.length; i++) {
var live = lives[i];
if ($(selector).is(live.selector)) {
var event = $.Event(eventType);
live.handler.call($(selector)[0], event);
return event;
}
}
}

beforeEach(function() {
this.addMatchers({
toBeATextInput: function() {
return this.actual.is(":text");
},

toBeDefaultPrevented: function() {
return this.actual.isDefaultPrevented();
},

toBeHidden: function() {
return this.actual.is(":hidden");
},

toBeVisible: function() {
return this.actual.is(":visible");
},

toHaveClass: function(className) {
return this.actual.hasClass(className);
}
});
});

Loading