Created
March 13, 2009 08:16
-
-
Save mrflip/78483 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://github.com/binarylogic/authlogic/tree/master | |
http://www.binarylogic.com/2008/11/21/tutorial-using-openid-with-authlogic | |
http://binarylogic.lighthouseapp.com/projects/18752-authlogic/tickets | |
http://github.com/mischa/auth_store/tree/master | |
http://github.com/josh/rack-openid/tree/master | |
-------------------- | |
http://guides.rubyonrails.org/2_3_release_notes.html | |
http://weblog.rubyonrails.org/2009/1/26/nested-model-forms | |
http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes | |
http://gist.github.com/78393 | |
http://github.com/alloy/complex-form-examples/tree/master | |
http://soylentfoo.jnewland.com/articles/2008/12/16/rails-metal-a-micro-framework-with-the-power-of-rails-m | |
-------------------- | |
http://www.viget.com/extend/oauth-by-example/ | |
http://blog.behindlogic.com/2008/01/activeresource-and-oauth-were-working.html | |
http://oauth.rubyforge.org/ | |
http://jystewart.net/process/2009/02/rails-23-and-theme_support-actionmailer/ | |
http://railapp.com/ | |
########################################################################### | |
# | |
# TEMPLATES & PLUGINS | |
# | |
http://github.com/jeremymcanally/rails-templates/tree/master | |
http://github.com/btakita/rr/tree/master | |
http://github.com/geemus/acts_as_taggable_redux | |
http://m.onkey.org/2008/12/4/rails-templates | |
http://m.onkey.org/2008/12/4/rails-templates | |
########################################################################### | |
# | |
# | |
# | |
http://github.com/freelancing-god/thinking-sphinx/tree/master | |
http://github.com/alloy/complex-form-examples/tree/master | |
http://www.locomotivation.com/blog/2008/07/10/its-double-coupon-days-generate-and-redeem-coupons-with-the-acts-as-redeemable-rails-plugin.html | |
http://github.com/squeejee/acts_as_redeemable/tree/master | |
http://railscasts.com/episodes/124-beta-invitations | |
########################################################################### | |
# | |
# http://gist.github.com/raw/55456/0d4d3cb8dfb012d4a391939ba0ff6cfcaaf86d57/gistfile1.rb | |
# | |
# Link to local copy of edge rails | |
# inside('vendor') { run 'ln -s ~/dev/rails/rails rails' } | |
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
#run "rm -f public/javascripts/*" | |
# Download JQuery | |
run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js > public/javascripts/jquery.js" | |
# Set up git repository | |
git :init | |
git :add => '.' | |
# Copy database.yml for distribution use | |
run "cp config/database.yml config/database.yml.example" | |
# Set up .gitignore files | |
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" | |
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore} | |
file '.gitignore', <<-END | |
.DS_Store | |
log/*.log | |
log/*.pid | |
tmp/**/* | |
config/database.yml | |
db/*.sqlite3 | |
doc/api | |
doc/app | |
END | |
#plugins | |
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git', :submodule => true | |
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git', :submodule => true | |
plugin 'asset_packager', :git => 'git://github.com/sbecker/asset_packager.git', :submodule => true | |
plugin 'aasm', :git => 'git://github.com/rubyist/aasm.git', :submodule => true | |
plugin 'haml_scaffold', :git => 'git://github.com/cnaths/haml_scaffold.git', :submodule => true | |
plugin 'resource_this', :git => 'git://github.com/jnewland/resource_this.git', :submodule => true | |
#http://video.railstips.org/giving-mailers-observers-and-sweepers-their-own-space/ | |
run("mkdir -p app/observers app/sweepers app/mailers/views") | |
file 'app/mailers/application_mailer.rb', <<-CODE | |
class ApplicationMailer < ActionMailer::Base | |
self.template_root = File.join(RAILS_ROOT, 'app', 'mailers', 'views') | |
end | |
CODE | |
file 'app/mailers/user_mailer.rb', <<-CODE | |
class UserMailer < ApplicationMailer | |
def invitation(user) | |
subject 'Invitation' | |
from "do-not-reply@foobar.com" | |
recipients user.email | |
body :user => user | |
end | |
end | |
CODE | |
file 'app/observers/user_observer.rb', <<-CODE | |
class UserObserver < ActiveRecord::Observer | |
def after_create(user) | |
UserMailer.deliver_invitation(user) | |
end | |
end | |
CODE | |
#environment.rb | |
file 'config/environment.rb', <<-CODE | |
# RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION | |
# Bootstrap the Rails environment, frameworks, and default configuration | |
require File.join(File.dirname(__FILE__), 'boot') | |
Rails::Initializer.run do |config| | |
config.time_zone = 'UTC' | |
config.action_controller.session = { | |
:session_key => "_app_session", | |
:secret => "#{(1..36).map { |x| (65 + rand(26)).chr }.join}" | |
} | |
%w(observers sweepers mailers).each do |dir| | |
config.load_paths << "\#\{RAILS_ROOT\}/app/\#\{dir\}" | |
end | |
config.active_record.observers = :user_observer | |
end | |
CODE | |
#gems | |
gem 'haml' | |
gem 'authlogic' | |
gem 'cucumber' | |
gem 'webrat' | |
gem 'rack', :version => '~>0.9.0' | |
gem 'sqlite3-ruby', :lib => 'sqlite3' | |
rake("gems:install", :sudo => true) | |
run('haml --rails .') | |
#Authlogic stuff | |
file 'db/migrate/001_create_users.rb', <<-CODE | |
class CreateUsers < ActiveRecord::Migration | |
def self.up | |
create_table :users do |t| | |
t.string :login, :null => false | |
t.string :crypted_password, :null => false | |
t.string :password_salt, :null => false # not needed if you are encrypting your pw instead of using a hash algorithm. | |
t.string :persistence_token, :null => false | |
t.string :single_access_token, :null => false # optional, see the tokens section below. | |
t.string :perishable_token, :null => false # optional, see the tokens section below. | |
t.integer :login_count, :null => false, :default => 0 # optional, this is a "magic" column, see the magic columns section below | |
end | |
end | |
def self.down | |
drop_table :posts | |
end | |
end | |
CODE | |
file 'app/models/user.rb', <<-CODE | |
class User < ActiveRecord::Base | |
end | |
CODE | |
rake("db:migrate") | |
generate(:session, "user_session") | |
file 'app/models/user.rb', <<-CODE | |
class User < ActiveRecord::Base | |
acts_as_authentic # for options see documentation: Authlogic::ORMAdapters::ActiveRecordAdapter::ActsAsAuthentic::Config | |
end | |
CODE | |
# fixing application_controller | |
run("mv app/controllers/application.rb app/controllers/application_controller.rb") | |
generate("rspec") | |
generate("cucumber") | |
#webrat support for features | |
file 'features/support/env.rb', <<-CODE | |
# Sets up the Rails environment for Cucumber | |
ENV["RAILS_ENV"] = "test" | |
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') | |
require 'cucumber/rails/world' | |
#require 'cucumber/formatters/unicode' # Comment out this line if you don't want Cucumber Unicode support | |
Cucumber::Rails.use_transactional_fixtures | |
require 'webrat/rails' | |
# Comment out the next two lines if you're not using RSpec's matchers (should / should_not) in your steps. | |
require 'cucumber/rails/rspec' | |
require 'webrat/rspec-rails' | |
require "webrat" | |
Webrat.configure do |config| | |
config.mode = :rails | |
end | |
CODE | |
git :commit => "-a -m 'Setting up a new rails app. Copy config/database.yml.sample to config/database.yml and customize.'" | |
########################################################################### | |
# | |
# https://gist.github.com/raw/40157/cbf121a820679332a96c24c05f1093ea5288b75c/gistfile1.rb | |
# | |
# SUPER DARING APP TEMPLATE 1.0 | |
# By Peter Cooper | |
# modified to use authlogic, as per the tutorial here: http://www.binarylogic.com/2008/11/3/tutorial-authlogic-basic-setup | |
# Link to local copy of edge rails | |
inside('vendor') { run 'ln -s ~/src/ext/git/rails rails' } | |
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
run "rm -f public/javascripts/*" | |
# Download JQuery | |
run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js > public/javascripts/jquery.js" | |
run "curl -L http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js > public/javascripts/jquery.form.js" | |
# Set up git repository | |
git :init | |
git :add => '.' | |
# Copy database.yml for distribution use | |
run "cp config/database.yml config/database.yml.example" | |
# Set up .gitignore files | |
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" | |
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore} | |
file '.gitignore', <<-END | |
.DS_Store | |
log/*.log | |
tmp/**/* | |
config/database.yml | |
db/*.sqlite3 | |
END | |
# Set up sessions, RSpec, user model, OpenID, etc | |
generate("rspec") | |
generate("session", "user_session") | |
generate("controller", "user_sessions") | |
generate("rspec_scaffold", "user", "login:string", "crypted_password:string", "password_salt:string", "persistence_token:string", "login_count:integer", "last_request_at:datetime", "last_login_at:datetime", "current_login_at:datetime", "last_login_ip:string", "current_login_ip:string") | |
# set the default controller | |
route "map.resource :user_session" | |
route "map.root :controller => 'user_sessions', :action => 'new'" | |
route "map.resource :account, :controller => 'users'" | |
route "map.resources :users" | |
# set up user_sessions_controller | |
file 'app/controllers/user_sessions_controller.rb', | |
%q{class UserSessionsController < ApplicationController | |
before_filter :require_no_user, :only => [:new, :create] | |
before_filter :require_user, :only => :destroy | |
def new | |
@user_session = UserSession.new | |
end | |
def create | |
@user_session = UserSession.new(params[:user_session]) | |
if @user_session.save | |
flash[:notice] = "Login successful!" | |
redirect_back_or_default account_url | |
else | |
render :action => :new | |
end | |
end | |
def destroy | |
current_user_session.destroy | |
flash[:notice] = "Logout successful!" | |
redirect_back_or_default new_user_session_url | |
end | |
end | |
} | |
# set up user model | |
file 'app/models/user.rb', | |
%q{class User < ActiveRecord::Base | |
acts_as_authentic | |
end | |
} | |
# set up the users_controller | |
file 'app/controllers/users_controller.rb', | |
%q{class UsersController < ApplicationController | |
before_filter :require_no_user, :only => [:new, :create] | |
before_filter :require_user, :only => [:show, :edit, :update] | |
def new | |
@user = User.new | |
end | |
def create | |
@user = User.new(params[:user]) | |
if @user.save | |
flash[:notice] = "Account registered!" | |
redirect_back_or_default account_url | |
else | |
render :action => :new | |
end | |
end | |
def show | |
@user = @current_user | |
end | |
def edit | |
@user = @current_user | |
end | |
def update | |
@user = @current_user # makes our views "cleaner" and more consistent | |
if @user.update_attributes(params[:user]) | |
flash[:notice] = "Account updated!" | |
redirect_to account_url | |
else | |
render :action => :edit | |
end | |
end | |
end | |
} | |
# set up the application controller | |
file 'app/controllers/application_controller.rb', | |
%q{# Filters added to this controller apply to all controllers in the application. | |
# Likewise, all the methods added will be available for all controllers. | |
class ApplicationController < ActionController::Base | |
helper :all # include all helpers, all the time | |
protect_from_forgery # See ActionController::RequestForgeryProtection for details | |
# Scrub sensitive parameters from your log | |
# filter_parameter_logging :password | |
filter_parameter_logging :password, :password_confirmation | |
helper_method :current_user_session, :current_user | |
private | |
def current_user_session | |
return @current_user_session if defined?(@current_user_session) | |
@current_user_session = UserSession.find | |
end | |
def current_user | |
return @current_user if defined?(@current_user) | |
@current_user = current_user_session && current_user_session.user | |
end | |
def require_user | |
unless current_user | |
store_location | |
flash[:notice] = "You must be logged in to access this page" | |
redirect_to new_user_session_url | |
return false | |
end | |
end | |
def require_no_user | |
if current_user | |
store_location | |
flash[:notice] = "You must be logged out to access this page" | |
redirect_to account_url | |
return false | |
end | |
end | |
def store_location | |
session[:return_to] = request.request_uri | |
end | |
def redirect_back_or_default(default) | |
redirect_to(session[:return_to] || default) | |
session[:return_to] = nil | |
end | |
end | |
} | |
# set up some views | |
file 'app/views/password_resets/edit.html.erb', | |
%q{<h1>Change My Password</h1> | |
<% form_for @user, :url => password_reset_path, :method => :put do |f| %> | |
<%= f.error_messages %> | |
<%= f.label :password %><br /> | |
<%= f.password_field :password %><br /> | |
<br /> | |
<%= f.label :password_confirmation %><br /> | |
<%= f.password_field :password_confirmation %><br /> | |
<br /> | |
<%= f.submit "Update my password and log me in" %> | |
<% end %> | |
} | |
file 'app/views/password_resets/new.html.erb', | |
%q{<h1>Forgot Password</h1> | |
Fill out the form below and instructions to reset your password will be emailed to you:<br /> | |
<br /> | |
<% form_tag password_resets_path do %> | |
<label>Email:</label><br /> | |
<%= text_field_tag "email" %><br /> | |
<br /> | |
<%= submit_tag "Reset my password" %> | |
<% end %> | |
} | |
file 'app/views/user_sessions/new.html.erb', | |
%q{<h1>Login</h1> | |
<% form_for @user_session, :url => user_session_path do |f| %> | |
<%= f.error_messages %> | |
<%= f.label :login %><br /> | |
<%= f.text_field :login %><br /> | |
<br /> | |
<%= f.label :password %><br /> | |
<%= f.password_field :password %><br /> | |
<br /> | |
<%= f.check_box :remember_me %><%= f.label :remember_me %><br /> | |
<br /> | |
<%= f.submit "Login" %> | |
<% end %> | |
} | |
file 'app/views/user_sessions/new.html.erb', | |
%q{<h1>Login</h1> | |
<% form_for @user_session, :url => user_session_path do |f| %> | |
<%= f.error_messages %> | |
<%= f.label :login %><br /> | |
<%= f.text_field :login %><br /> | |
<br /> | |
<%= f.label :password %><br /> | |
<%= f.password_field :password %><br /> | |
<br /> | |
<%= f.check_box :remember_me %><%= f.label :remember_me %><br /> | |
<br /> | |
<%= f.submit "Login" %> | |
<% end %> | |
} | |
file 'app/views/users/_form.html.erb', | |
%q{<%= form.label :login %><br /> | |
<%= form.text_field :login %><br /> | |
<br /> | |
<%= form.label :password, form.object.new_record? ? nil : "Change password" %><br /> | |
<%= form.password_field :password %><br /> | |
<br /> | |
<%= form.label :password_confirmation %><br /> | |
<%= form.password_field :password_confirmation %><br /> | |
<br /> | |
} | |
file 'app/views/users/edit.html.erb', | |
%q{<h1>Edit My Account</h1> | |
<% form_for @user, :url => account_path do |f| %> | |
<%= f.error_messages %> | |
<%= render :partial => "form", :object => f %> | |
<%= f.submit "Update" %> | |
<% end %> | |
<br /><%= link_to "My Profile", account_path %> | |
} | |
file 'app/views/users/new.html.erb', | |
%q{<h1>Register</h1> | |
<% form_for @user, :url => account_path do |f| %> | |
<%= f.error_messages %> | |
<%= render :partial => "form", :object => f %> | |
<%= f.submit "Register" %> | |
<% end %> | |
} | |
file 'app/views/users/show.html.erb', | |
%q{<p> | |
<b>Login:</b> | |
<%=h @user.login %> | |
</p> | |
<p> | |
<b>Login count:</b> | |
<%=h @user.login_count %> | |
</p> | |
<p> | |
<b>Last request at:</b> | |
<%=h @user.last_request_at %> | |
</p> | |
<p> | |
<b>Last login at:</b> | |
<%=h @user.last_login_at %> | |
</p> | |
<p> | |
<b>Current login at:</b> | |
<%=h @user.current_login_at %> | |
</p> | |
<p> | |
<b>Last login ip:</b> | |
<%=h @user.last_login_ip %> | |
</p> | |
<p> | |
<b>Current login ip:</b> | |
<%=h @user.current_login_ip %> | |
</p> | |
<%= link_to 'Edit', edit_account_path %> | |
} | |
# run migrations | |
rake('db:migrate') | |
# Install all gems | |
gem 'authlogic' | |
# gem 'rspec' | |
# gem 'rspec-rails' | |
# rake('gems:install', :sudo => true) | |
# Initialize submodules | |
# git :submodule => "init" | |
# Commit all work so far to the repository | |
git :add => '.' | |
git :commit => "-a -m 'Initial commit'" | |
# Success! | |
puts "SUCCESS!" | |
########################################################################### | |
# | |
# https://gist.github.com/raw/55456/d3662cf91e4d900141fcd02267bfadcab663407c/gistfile1.rb | |
# | |
# Link to local copy of edge rails | |
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' } | |
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
run "rm -f public/javascripts/*" | |
# Download JQuery | |
run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js > public/javascripts/jquery.js" | |
# Set up git repository | |
git :init | |
git :add => '.' | |
# Copy database.yml for distribution use | |
run "cp config/database.yml config/database.yml.example" | |
# Set up .gitignore files | |
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" | |
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore} | |
file '.gitignore', <<-END | |
.DS_Store | |
log/*.log | |
log/*.pid | |
tmp/**/* | |
config/database.yml | |
db/*.sqlite3 | |
doc/api | |
doc/app | |
db/*.sqlite3 | |
END | |
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git', :submodule => true | |
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git', :submodule => true | |
plugin 'asset_packager', :git => 'git://github.com/sbecker/asset_packager.git', :submodule => true | |
plugin 'aasm', :git => 'git://github.com/rubyist/aasm.git', :submodule => true | |
plugin 'haml_scaffold', :git => 'git://github.com/cnaths/haml_scaffold.git', :submodule => true | |
plugin 'resource_this', :git => 'git://github.com/jnewland/resource_this.git', :submodule => true | |
gem 'haml' | |
gem 'authlogic' | |
gem 'cucumber' | |
gem 'webrat' | |
gem 'rack', :version => '~>0.9.0' | |
gem 'sqlite3-ruby', :lib => 'sqlite3' | |
rake("gems:install", :sudo => true) | |
run('haml --rails .') | |
file 'config/environment.rb', <<-CODE | |
# RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION | |
# Bootstrap the Rails environment, frameworks, and default configuration | |
require File.join(File.dirname(__FILE__), 'boot') | |
Rails::Initializer.run do |config| | |
config.time_zone = 'UTC' | |
config.action_controller.session = { | |
:session_key => '_app_session', | |
:secret => '#{(1..6).map { |x| (65 + rand(26)).chr }.join}' | |
} | |
%w(observers sweepers mailers).each do |dir| | |
config.load_paths << "#{RAILS_ROOT}/app/#{dir}" | |
end | |
config.active_record.observers = :user_observer | |
end | |
CODE | |
#generate(:haml_scaffold, "Post title:string body:text") | |
generate(:session, "user_session") | |
file 'db/migrate/001_create_users.rb', <<-CODE | |
class CreateUsers < ActiveRecord::Migration | |
def self.up | |
create_table :users do |t| | |
t.string :login, :null => false | |
t.string :crypted_password, :null => false | |
t.string :password_salt, :null => false # not needed if you are encrypting your pw instead of using a hash algorithm. | |
t.string :persistence_token, :null => false | |
t.string :single_access_token, :null => false # optional, see the tokens section below. | |
t.string :perishable_token, :null => false # optional, see the tokens section below. | |
t.integer :login_count, :null => false, :default => 0 # optional, this is a "magic" column, see the magic columns section below | |
end | |
end | |
def self.down | |
drop_table :posts | |
end | |
end | |
CODE | |
file 'app/models/user.rb', <<-CODE | |
class User < ActiveRecord::Base | |
acts_as_authentic # for options see documentation: Authlogic::ORMAdapters::ActiveRecordAdapter::ActsAsAuthentic::Config | |
end | |
CODE | |
generate("rspec") | |
generate("cucumber") | |
file 'features/support/env.rb', <<-CODE | |
# Sets up the Rails environment for Cucumber | |
ENV["RAILS_ENV"] = "test" | |
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') | |
require 'cucumber/rails/world' | |
require 'cucumber/formatters/unicode' # Comment out this line if you don't want Cucumber Unicode support | |
Cucumber::Rails.use_transactional_fixtures | |
require 'webrat/rails' | |
# Comment out the next two lines if you're not using RSpec's matchers (should / should_not) in your steps. | |
require 'cucumber/rails/rspec' | |
require 'webrat/rspec-rails' | |
require "webrat" | |
Webrat.configure do |config| | |
config.mode = :rails | |
end | |
CODE | |
#route "map.root :controller => 'posts'" | |
#rake("db:migrate") | |
########################################################################### | |
# | |
# http://gist.github.com/raw/52982/2561cbe818b40b0b84557f2ec41e3d33dcb32c99/gistfile1.rb | |
# | |
# App Template | |
# By Matt Polito | |
# Link to local copy of edge rails | |
rake('rails:freeze:gems') | |
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
run "rm -f public/javascripts/*" | |
# # Download JQuery | |
# inside('public/javascripts') do | |
# run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.3.min.js > jquery.js" | |
# run "curl -d 'version=1.6rc5&compression=jsmin&files%5B%5D=ui.core.js&files%5B%5D=ui.draggable.js&files%5B%5D=ui.droppable.js&files%5B%5D=ui.resizable.js&files%5B%5D=ui.selectable.js&files%5B%5D=ui.sortable.js&files%5B%5D=ui.accordion.js&files%5B%5D=ui.dialog.js&files%5B%5D=ui.slider.js&files%5B%5D=ui.tabs.js&files%5B%5D=ui.datepicker.js&files%5B%5D=ui.progressbar.js&files%5B%5D=effects.core.js&files%5B%5D=effects.blind.js&files%5B%5D=effects.bounce.js&files%5B%5D=effects.clip.js&files%5B%5D=effects.drop.js&files%5B%5D=effects.explode.js&files%5B%5D=effects.fold.js&files%5B%5D=effects.highlight.js&files%5B%5D=effects.pulsate.js&files%5B%5D=effects.scale.js&files%5B%5D=effects.shake.js&files%5B%5D=effects.slide.js&files%5B%5D=effects.transfer.js' http://ui.jquery.com/actions/download_builder.php -L > jqueryui.zip" | |
# run "curl -L http://ui.jquery.com/applications/themeroller/download.php?href=/applications/themeroller/css/parseTheme.css.php?ctl=themeroller > theme.zip" | |
# run "unzip theme.zip -d jquery-ui-theme" | |
# run "rm theme.zip" | |
# run "unzip jqueryui.zip" | |
# run "rm jqueryui.zip" | |
# run "rm -rf ui" | |
# run "find . -name \"jquery-ui*.js\" | xargs -I xxx mv xxx jquery-ui.js" | |
# end | |
# Set up git repository | |
git :init | |
git :add => '.' | |
# Copy database.yml for distribution use | |
run "cp config/database.yml config/database.yml.example" | |
# Set up .gitignore files | |
run "touch tmp/.gitignore log/.gitignore" | |
run %{find . -type d -empty | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore} | |
file '.gitignore', <<-END | |
.DS_Store | |
log/*.log | |
tmp/**/* | |
config/database.yml | |
db/*.sqlite3 | |
END | |
# Set up session store initializer | |
initializer 'session_store.rb', <<-END | |
ActionController::Base.session = { :session_key => '_#{(1..6).map { |x| (65 + rand(26)).chr }.join}_session', :secret => '#{(1..40).map { |x| (65 + rand(26)).chr }.join}' } | |
ActionController::Base.session_store = :active_record_store | |
END | |
# Install all plugins | |
plugin 'jrails', :git => 'git://github.com/aaronchi/jrails.git', :submodule => true | |
plugin 'open_id_authentication', :git => 'git://github.com/rails/open_id_authentication.git', :submodule => true | |
plugin 'seed-fu', :git => 'git://github.com/mbleigh/seed-fu.git', :submodule => true | |
# Install all gems | |
gem 'authlogic', :version => '>= 1.4.0' | |
gem 'gravtastic', :version => '>= 2.0.0' | |
gem 'haml', :version => '>= 2.0.7' | |
gem 'ruby-openid', :lib => 'openid' | |
gem 'settingslogic' | |
# gem 'mislav-will_paginate', :version => '~> 2.2.3', :lib => 'will_paginate', :source => 'http://gems.github.com' | |
rake('gems:install', :sudo => true) | |
rake('gems:unpack') | |
# Create DB | |
rake('db:create') | |
# Initialize submodules | |
git :submodule => "init" | |
# Commit all work so far to the repository | |
git :add => '.' | |
git :commit => "-a -m 'Initial commit'" | |
# Generate Authlogic code | |
generate("session", "user_session") | |
generate("controller", "user_sessions") | |
generate("scaffold", "user login:string crypted_password:string persistence_token:string login_count:integer last_request_at:datetime last_login_at:datetime current_login_at:datetime last_login_ip:string current_login_ip:string") | |
# Remove auto generated users migration | |
run "rm db/migrate/*_create_users.rb" | |
# Create new users migration with all needed fields | |
file "db/migrate/#{Time.now.strftime("%Y%m%d%H%M%S")}_create_users.rb", <<-END | |
class CreateUsers < ActiveRecord::Migration | |
def self.up | |
create_table "users", :force => true do |t| | |
t.string "login" | |
t.string "crypted_password" | |
t.string "password_salt" | |
t.string "persistence_token" | |
t.integer "login_count" | |
t.datetime "last_request_at" | |
t.datetime "last_login_at" | |
t.datetime "current_login_at" | |
t.string "last_login_ip" | |
t.string "current_login_ip" | |
t.string "openid_identifier" | |
t.string "perishable_token", :default => "", :null => false | |
t.string "email", :default => "", :null => false | |
t.timestamps | |
end | |
add_index "users", ["email"], :name => "index_users_on_email" | |
add_index "users", ["openid_identifier"], :name => "index_users_on_openid_identifier" | |
add_index "users", ["perishable_token"], :name => "index_users_on_perishable_token" | |
end | |
def self.down | |
drop_table :users | |
end | |
end | |
END | |
# Set up sessions, RSpec, user model, OpenID, etc, and run migrations | |
rake('db:sessions:create') | |
# generate("roles", "Role User") | |
rake('open_id_authentication:db:create') | |
rake('db:migrate:reset') | |
# Remove unnecessary erb files | |
run "rm views/layouts/users.html.erb" | |
run "rm views/users/edit.html.erb" | |
run "rm views/users/new.html.erb" | |
run "rm views/users/show.html.erb" | |
### Config ### | |
file 'config/routes.rb', <<-END | |
ActionController::Routing::Routes.draw do |map| | |
# The priority is based upon order of creation: first created -> highest priority. | |
# Sample of regular route: | |
# map.connect 'products/:id', :controller => 'catalog', :action => 'view' | |
# Keep in mind you can assign values other than :controller and :action | |
# Sample of named route: | |
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' | |
# This route can be invoked with purchase_url(:id => product.id) | |
map.login '/login', :controller => 'user_sessions', :action => 'new' | |
map.logout '/logout', :controller => 'user_sessions', :action => 'destroy' | |
# Sample resource route (maps HTTP verbs to controller actions automatically): | |
# map.resources :products | |
# Sample resource route with options: | |
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get } | |
# Sample resource route with sub-resources: | |
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller | |
# Sample resource route with more complex sub-resources | |
# map.resources :products do |products| | |
# products.resources :comments | |
# products.resources :sales, :collection => { :recent => :get } | |
# end | |
# Sample resource route within a namespace: | |
# map.namespace :admin do |admin| | |
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb) | |
# admin.resources :products | |
# end | |
map.resources :users | |
map.resource :account, :controller => :users | |
map.resource :user_sessions | |
# You can have the root of your site routed with map.root -- just remember to delete public/index.html. | |
# map.root :controller => "welcome" | |
map.root :controller => 'user_sessions', :action => 'new' | |
# See how all your routes lay out with "rake routes" | |
# Install the default routes as the lowest priority. | |
# Note: These default routes make all actions in every controller accessible via GET requests. You should | |
# consider removing the them or commenting them out if you're using named routes and resources. | |
map.connect ':controller/:action/:id' | |
map.connect ':controller/:action/:id.:format' | |
end | |
END | |
### Controllers ### | |
file 'app/controllers/application_controller.rb', <<-END | |
class ApplicationController < ActionController::Base | |
helper :all | |
helper_method :current_user_session, :current_user | |
filter_parameter_logging :password, :password_confirmation | |
private | |
def current_user_session | |
return @current_user_session if defined?(@current_user_session) | |
@current_user_session = UserSession.find | |
end | |
def current_user | |
return @current_user if defined?(@current_user) | |
@current_user = current_user_session && current_user_session.record | |
end | |
def require_user | |
unless current_user | |
store_location | |
flash[:notice] = "You must be logged in to access this page" | |
redirect_to new_user_session_url | |
return false | |
end | |
end | |
def require_no_user | |
if current_user | |
store_location | |
flash[:notice] = "You must be logged out to access this page" | |
redirect_to account_url | |
return false | |
end | |
end | |
def store_location | |
session[:return_to] = request.request_uri | |
end | |
def redirect_back_or_default(default) | |
redirect_to(session[:return_to] || default) | |
session[:return_to] = nil | |
end | |
end | |
END | |
file 'app/controllers/users_controller.rb', <<-END | |
class UsersController < ApplicationController | |
before_filter :require_no_user, :only => [:new, :create] | |
before_filter :require_user, :only => [:show, :edit, :update] | |
def new | |
@user = User.new | |
end | |
def create | |
@user = User.new(params[:user]) | |
if @user.save | |
flash[:notice] = "Account registered!" | |
redirect_back_or_default account_url | |
else | |
render :action => :new | |
end | |
end | |
def show | |
@user = @current_user | |
end | |
def edit | |
@user = @current_user | |
end | |
def update | |
@user = @current_user # makes our views "cleaner" and more consistent | |
if @user.update_attributes(params[:user]) | |
flash[:notice] = "Account updated!" | |
redirect_to account_url | |
else | |
render :action => :edit | |
end | |
end | |
end | |
END | |
file 'app/controllers/user_sessions_controller.rb', <<-END | |
class UserSessionsController < ApplicationController | |
before_filter :require_no_user, :only => [:new, :create] | |
before_filter :require_user, :only => :destroy | |
def new | |
@user_session = UserSession.new | |
end | |
def create | |
@user_session = UserSession.new(params[:user_session]) | |
if @user_session.save | |
flash[:notice] = "Login successful!" | |
redirect_back_or_default account_url | |
else | |
render :action => :new | |
end | |
end | |
def destroy | |
current_user_session.destroy | |
flash[:notice] = "Logout successful!" | |
redirect_back_or_default new_user_session_url | |
end | |
end | |
END | |
### Models ### | |
file 'app/models/user.rb', <<-END | |
class User < ActiveRecord::Base | |
acts_as_authentic | |
def deliver_password_reset_instructions! | |
reset_perishable_token! | |
Notifier.deliver_password_reset_instructions(self) | |
end | |
end | |
END | |
file 'app/models/user_session.rb', <<-END | |
class UserSession < Authlogic::Session::Base | |
attr_accessor :openid_identifier | |
def authenticating_with_openid? | |
!openid_identifier.blank? || controller.params[:open_id_complete] | |
end | |
def save(&block) | |
if authenticating_with_openid? | |
raise ArgumentError.new("You must supply a block to authenticate with OpenID") unless block_given? | |
controller.send(:authenticate_with_open_id, openid_identifier) do |result, openid_identifier| | |
if !result.successful? | |
errors.add_to_base(result.message) | |
yield false | |
return | |
end | |
record = klass.find_by_openid_identifier(openid_identifier) | |
if !record | |
errors.add(:openid_identifier, "did not match any users in our database, have you set up your account to use OpenID?") | |
yield false | |
return | |
end | |
self.unauthorized_record = record | |
super | |
end | |
else | |
super | |
end | |
end | |
end | |
END | |
### Helpers ### | |
file 'app/helpers/application_helper.rb', <<-END | |
# Methods added to this helper will be available to all templates in the application. | |
module ApplicationHelper | |
def display_none_unless_openid_is_blank(user_session) | |
user_session.openid_identifier.blank? ? {} : { :style => 'display: none;' } | |
end | |
def display_none_if_openid_is_blank(user_session) | |
user_session.openid_identifier.blank? ? { :style => 'display: none;' } : {} | |
end | |
def is_new_action? | |
controller.action_name == 'new' | |
end | |
end | |
END | |
### Views ### | |
# Notifier | |
file 'app/views/notifier/password_reset_instructions.html.haml', <<-END | |
A request to reset your password has been made. | |
If you did not make this request, simply ignore this email. | |
If you did make this request just click the link below: | |
= @edit_password_reset_url | |
If the above URL does not work try copying and pasting it into your browser. | |
If you continue to have problem please feel free to contact us. | |
END | |
# Password Resets | |
file 'app/views/password_resets/edit.html.haml', <<-END | |
%h1 Change My Password | |
- form_for @user, :url => password_reset_path, :method => :put do |f| | |
= f.error_messages | |
= f.label :password | |
%br | |
= f.password_field :password | |
%br | |
%br | |
= f.label :password_confirmation | |
%br | |
= f.password_field :password_confirmation | |
%br | |
%br | |
= f.submit "Update my password and log me in" | |
END | |
file 'app/views/password_resets/new.html.haml', <<-END | |
%h1 Forgot Password | |
%p Fill out the form below and instructions to reset your password will be emailed to you: | |
- form_tag password_resets_path do | |
%label Email: | |
%p= text_field_tag "email" | |
%p= submit_tag "Reset my password" | |
END | |
# User Sessions | |
file 'app/views/user_sessions/new.html.haml', <<-END | |
%h1 Login | |
- form_for @user_session, :url => user_sessions_path do |f| | |
= f.error_messages | |
#login_container{ display_none_unless_openid_is_blank(@user_session) } | |
%p | |
= f.label :login | |
(or | |
= link_to_function "login using OpenID", "$('login_container').toggle(); $('openid_container').toggle();" | |
) | |
%br/ | |
= f.text_field :login | |
%p | |
= f.label :password | |
%br/ | |
= f.password_field :password | |
#openid_container{ display_none_if_openid_is_blank(@user_session) } | |
= f.label :openid_identifier, "OpenID" | |
(or | |
= link_to_function "login using a standard username / password", "$('login_container').toggle(); $('openid_container').toggle();" | |
) | |
%br/ | |
= f.text_field :openid_identifier | |
%p | |
= f.check_box :remember_me | |
= f.label :remember_me | |
%p | |
= f.submit "Login" | |
END | |
# Users | |
file 'app/views/users/_form.html.haml', <<-END | |
= form.label :login | |
%br/ | |
= form.text_field :login | |
%br/ | |
%br/ | |
= form.label :password, form.object.new_record? ? nil : "Change password" | |
%br/ | |
= form.password_field :password | |
%br/ | |
%br/ | |
= form.label :password_confirmation | |
%br/ | |
= form.password_field :password_confirmation | |
%br/ | |
%br/ | |
= form.label :openid_identifier, "Or use OpenID instead of a standard login / password" | |
%br/ | |
= form.text_field :openid_identifier | |
%br/ | |
%br/ | |
= form.label :email | |
%br/ | |
= form.text_field :email | |
%br/ | |
%br/ | |
END | |
file 'app/views/users/edit.html.haml', <<-END | |
%h1 Edit My Account | |
- form_for @user, :url => account_path do |f| | |
= f.error_messages | |
= render :partial => "form", :object => f | |
= f.submit "Update" | |
%br/ | |
= link_to "My Profile", account_path | |
END | |
file 'app/views/users/new.html.haml', <<-END | |
%h1 Register | |
- form_for @user, :url => account_path do |f| | |
= f.error_messages | |
= render :partial => "form", :object => f | |
= f.submit "Register" | |
END | |
file 'app/views/users/show.html.haml', <<-END | |
- if @user.openid_identifier.blank? | |
%p | |
%strong Login: | |
=h @user.login | |
- else | |
%p | |
%strong OpenID: | |
=h @user.openid_identifier | |
%p | |
%strong Email: | |
=h @user.email | |
%p | |
%strong Login count: | |
=h @user.login_count | |
%p | |
%strong Last request at: | |
=h @user.last_request_at | |
%p | |
%strong Last login at: | |
=h @user.last_login_at | |
%p | |
%strong Current login at: | |
=h @user.current_login_at | |
%p | |
%strong Last login ip: | |
=h @user.last_login_ip | |
%p | |
%strong Current login ip: | |
=h @user.current_login_ip | |
= link_to 'Edit', edit_account_path | |
END | |
# file 'app/models/notifier.rb', <<-END | |
# class Notifier < ActionMailer::Base | |
# default_url_options[:host] = "" | |
# | |
# def password_reset_instructions(user) | |
# subject "Password Reset Instructions" | |
# from "Binary Logic Notifier <noreply@binarylogic.com>" | |
# recipients user.email | |
# sent_on Time.now | |
# body :edit_password_reset_url => edit_password_reset_url(user.perishable_token) | |
# end | |
# end | |
# END | |
# Success! | |
puts "" | |
puts "" | |
puts "**************************************" | |
puts "*** ***" | |
puts "*** Yippie, I just made something! ***" | |
puts "*** ***" | |
puts "**************************************" | |
puts "" | |
puts "" | |
########################################################################### | |
# | |
# http://gist.github.com/raw/63953/f9b4edad9e393e933a7d53dff1d6d403c6d9cdee/gistfile1 | |
# | |
# File management | |
run "rm README" | |
file "README.rdoc", "TODO add readme content" | |
run "cp config/database.yml config/database.example.yml" | |
run "rm public/index.html" | |
# RSpec as plugin, because it won't freeze easily as gem | |
plugin "rspec", :git => "git://github.com/dchelimsky/rspec.git" | |
plugin "rspec-rails", :git => "git://github.com/dchelimsky/rspec-rails.git" | |
generate :rspec | |
run "rm -r test/" | |
# Bunch of gems! | |
gem 'authlogic' | |
gem 'haml' | |
gem 'faker' | |
gem 'cucumber' | |
gem 'RedCloth', :lib => 'redcloth' | |
gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com' | |
gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => 'http://gems.github.com' | |
gem 'brynary-webrat', :lib => 'webrat', :source => 'http://gems.github.com' | |
rake "gems:unpack" | |
rake "rails:freeze:gems" | |
generate :cucumber | |
# My favorite plugins | |
plugin "mr.-t", :git => "git://github.com/iain/mr.-t.git" | |
plugin "acts_as_translatable_model", :git => "git://github.com/iain/acts_as_translatable_model.git" | |
plugin "i18n_label", :git => "git://github.com/iain/i18n_label.git" | |
if yes?("Do you need to use subversion?") | |
plugin "rake_svn", :git => "git://github.com/iain/rake_svn.git" | |
rake "svn:init_rails" if system("svn info") | |
else | |
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" | |
file ".gitignore", <<-END | |
log/*.log | |
tmp/**/* | |
config/database.yml | |
db/*.sqlite3 | |
END | |
git :init | |
git :add => '.', :commit => '-m "Initial Commit"' | |
end | |
########################################################################### | |
# | |
# http://github.com/jeremymcanally/rails-templates/blob/68bada09dbd577b277a49ee4f3fea30fb0bc618c/sethbc.rb | |
# | |
# Link to local copy of edge rails | |
inside('vendor') { run 'ln -s ~/Development/rails/rails rails' } | |
# Delete unnecessary files | |
run "rm README" | |
run "rm doc/README_FOR_APP" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
# Set up git repository | |
git :init | |
# Copy database.yml for distribution use | |
run "cp config/database.yml config/database.yml.example" | |
# Set up .gitignore files | |
run %{find . -type d -empty | xargs -I xxx touch xxx/.gitignore} | |
file '.gitignore', <<-END | |
.DS_Store | |
coverage/* | |
log/*.log | |
db/*.db | |
db/*.sqlite3 | |
db/schema.rb | |
tmp/**/* | |
doc/api | |
doc/app | |
config/database.yml | |
coverage/* | |
END | |
# Install plugins as git submodules | |
plugin 'acts_as_taggable_redux', :git => 'git://github.com/geemus/acts_as_taggable_redux.git', :submodule => true | |
plugin 'exception_notifier', :git => 'git://github.com/rails/exception_notification.git', :submodule => true | |
plugin 'asset_packager', :git => 'git://github.com/sbecker/asset_packager.git', :submodule => true | |
plugin 'authlogic', :git => 'git://github.com/binarylogic/authlogic.git', :submodule => true | |
plugin 'shoulda', :git => 'git://github.com/thoughtbot/shoulda.git', :submodule => true | |
plugin 'factory_girl', :git => 'git://github.com/thoughtbot/factory_girl.git', :submodule => true | |
plugin 'quietbacktrace', :git => 'git://github.com/thoughtbot/quietbacktrace.git', :submodule => true | |
plugin 'rr', :git => 'git://github.com/btakita/rr.git', :submodule => true | |
plugin 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git', :submodule => true | |
# Install all gems | |
gem 'RedCloth' | |
# Initialize submodules | |
git :submodule => "init" | |
rake('gems:install', :sudo => true) | |
# Set up sessions, RSpec, user model, OpenID, etc, and run migrations | |
rake('db:sessions:create') | |
generate("authlogic", "user session") | |
rake('acts_as_taggable:db:create') | |
rake('db:migrate') | |
# Commit all work so far to the repository | |
git :add => '.' | |
git :commit => "-a -m 'Initial commit'" | |
# Success! | |
puts "SUCCESS!" | |
########################################################################### | |
# | |
# http://github.com/jeremymcanally/rails-templates/raw/68bada09dbd577b277a49ee4f3fea30fb0bc618c/daring.rb | |
# | |
# daring.rb | |
# from Peter Cooper | |
# Link to local copy of edge rails | |
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' } | |
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
run "rm -f public/javascripts/*" | |
# Download JQuery | |
run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js > public/javascripts/jquery.js" | |
run "curl -L http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js > public/javascripts/jquery.form.js" | |
# Set up git repository | |
git :init | |
git :add => '.' | |
# Copy database.yml for distribution use | |
run "cp config/database.yml config/database.yml.example" | |
# Set up .gitignore files | |
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" | |
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore} | |
file '.gitignore', <<-END | |
.DS_Store | |
log/*.log | |
tmp/**/* | |
config/database.yml | |
db/*.sqlite3 | |
END | |
# Install submoduled plugins | |
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git', :submodule => true | |
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git', :submodule => true | |
plugin 'asset_packager', :git => 'git://github.com/sbecker/asset_packager.git', :submodule => true | |
plugin 'open_id_authentication', :git => 'git://github.com/rails/open_id_authentication.git', :submodule => true | |
plugin 'role_requirement', :git => 'git://github.com/timcharper/role_requirement.git', :submodule => true | |
plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => true | |
plugin 'acts_as_taggable_redux', :git => 'git://github.com/monki/acts_as_taggable_redux.git', :submodule => true | |
plugin 'aasm', :git => 'git://github.com/rubyist/aasm.git', :submodule => true | |
# Install all gems | |
gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => 'http://gems.github.com' | |
gem 'ruby-openid', :lib => 'openid' | |
gem 'sqlite3-ruby', :lib => 'sqlite3' | |
gem 'hpricot', :source => 'http://code.whytheluckystiff.net' | |
gem 'RedCloth', :lib => 'redcloth' | |
rake('gems:install', :sudo => true) | |
# Set up sessions, RSpec, user model, OpenID, etc, and run migrations | |
rake('db:sessions:create') | |
generate("authenticated", "user session") | |
generate("roles", "Role User") | |
generate("rspec") | |
rake('acts_as_taggable:db:create') | |
rake('open_id_authentication:db:create') | |
rake('db:migrate') | |
# Set up session store initializer | |
initializer 'session_store.rb', <<-END | |
ActionController::Base.session = { :session_key => '_#{(1..6).map { |x| (65 + rand(26)).chr }.join}_session', :secret => '#{(1..40).map { |x| (65 + rand(26)).chr }.join}' } | |
ActionController::Base.session_store = :active_record_store | |
END | |
# Initialize submodules | |
git :submodule => "init" | |
# Commit all work so far to the repository | |
git :add => '.' | |
git :commit => "-a -m 'Initial commit'" | |
# Success! | |
puts "SUCCESS!" | |
########################################################################### | |
# | |
# https://gist.github.com/raw/57042/71e8f27db0a3c8797472fd21c8800309976ab68e/bz.rb | |
# | |
if yes? "Do you want to link a local copy of edge rails?" | |
inside('vendor') { run 'ln -s ~/src/git/rails rails' } | |
end | |
# Remove files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
run "rm public/images/rails.png" | |
run "rm -f public/javascripts/*" | |
# Download JQuery | |
run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js > public/javascripts/jquery.js" | |
run "curl -L http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js > public/javascripts/jquery.form.js" | |
# Set up git repository | |
git :init | |
git :add => '.' | |
# Copy database.yml for distribution use | |
run "cp config/database.yml config/database.yml.example" | |
# Set up .gitignore files | |
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" | |
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore} | |
file '.gitignore', <<-END | |
.DS_Store | |
log/*.log | |
tmp/**/* | |
config/database.yml | |
db/*.sqlite3 | |
END | |
# Set up session store initializer | |
initializer 'session_store.rb', <<-END | |
ActionController::Base.session = { :session_key => '_#{(1..6).map { |x| (65 + rand(26)).chr }.join}_session', :secret => '#{(1..40).map { |x| (65 + rand(26)).chr }.join}' } | |
ActionController::Base.session_store = :active_record_store | |
END | |
# Gems | |
gem 'mislav-will-paginate', :lib => 'will-paginate', :source => 'http://gems.github.com' | |
gem 'thoughtbot-paperclip', :lib => 'paperclip', :source => 'http://gems.github.com' | |
gem 'rubyist-aasm', :lib => 'aasm', :source => 'http://gems.github.com' | |
gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => 'http://gems.github.com' | |
gem 'ruby-openid', :lib => 'openid' | |
gem 'sqlite3-ruby', :lib => 'sqlite3' | |
gem 'hpricot', :source => 'http://code.whytheluckystiff.net' | |
gem 'mbleigh-acts-as-taggable-on', :lib => 'acts-as-taggable-on', :source => 'http://gems.github.com' | |
gem 'rtomayko-rdiscount', :lib => 'rdiscount', :source => 'http://gems.github.com' | |
if yes?("Do you have libxslt1-dev & libxml2-dev and want Webrat/Cucumber?") | |
gem 'webrat' | |
gem 'rspec' | |
gem 'rspec-rails' | |
gem 'aslakhellesoy-cucumber', :lib => 'cucumber', :source => 'http://gem.github.com' | |
end | |
# Plugins | |
plugin 'make_resourceful', :git => 'git://github.com/hcatlin/make_resourceful.git', :submodule => true | |
plugin 'asset_packager', :git => 'git://github.com/sbecker/asset_packager.git', :submodule => true | |
plugin 'open_id_authentication', :git => 'git://github.com/rails/open_id_authentication.git', :submodule => true | |
plugin 'role_requirement', :git => 'git://github.com/timcharper/role_requirement.git', :submodule => true | |
plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => true | |
plugin 'aasm', :git => 'git://github.com/rubyist/aasm.git', :submodule => true | |
plugin 'exception_notifier', :git => 'git://github.com/rails/exception_notification.git', :submodule => true | |
# Submodules | |
rake('gems:install', :sudo => true) | |
git :submodule => "init" | |
# Generators | |
rake('db:sessions:create') | |
generate("authenticated", "user session") | |
generate("roles", "Role User") | |
generate("cucumber") | |
generate("rspec") | |
generate("acts_as_taggable_on_migration") | |
rake('open_id_authentication:db:create') | |
rake('db:migrate') | |
# GIT | |
git :add => "." | |
git :commit => "-a -m 'Setting up a new rails app, with some Zest!'" | |
puts "Zing!" | |
########################################################################### | |
# | |
# https://gist.github.com/raw/55456/d3662cf91e4d900141fcd02267bfadcab663407c/gistfile1.rb | |
# | |
# | |
# Link to local copy of edge rails | |
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' } | |
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
run "rm -f public/javascripts/*" | |
# Download JQuery | |
run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js > public/javascripts/jquery.js" | |
# Set up git repository | |
git :init | |
git :add => '.' | |
# Copy database.yml for distribution use | |
run "cp config/database.yml config/database.yml.example" | |
# Set up .gitignore files | |
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" | |
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore} | |
file '.gitignore', <<-END | |
.DS_Store | |
log/*.log | |
log/*.pid | |
tmp/**/* | |
config/database.yml | |
db/*.sqlite3 | |
doc/api | |
doc/app | |
db/*.sqlite3 | |
END | |
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git', :submodule => true | |
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git', :submodule => true | |
plugin 'asset_packager', :git => 'git://github.com/sbecker/asset_packager.git', :submodule => true | |
plugin 'aasm', :git => 'git://github.com/rubyist/aasm.git', :submodule => true | |
plugin 'haml_scaffold', :git => 'git://github.com/cnaths/haml_scaffold.git', :submodule => true | |
plugin 'resource_this', :git => 'git://github.com/jnewland/resource_this.git', :submodule => true | |
gem 'haml' | |
gem 'authlogic' | |
gem 'cucumber' | |
gem 'webrat' | |
gem 'rack', :version => '~>0.9.0' | |
gem 'sqlite3-ruby', :lib => 'sqlite3' | |
rake("gems:install", :sudo => true) | |
run('haml --rails .') | |
file 'config/environment.rb', <<-CODE | |
# RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION | |
# Bootstrap the Rails environment, frameworks, and default configuration | |
require File.join(File.dirname(__FILE__), 'boot') | |
Rails::Initializer.run do |config| | |
config.time_zone = 'UTC' | |
config.action_controller.session = { | |
:session_key => '_app_session', | |
:secret => '#{(1..6).map { |x| (65 + rand(26)).chr }.join}' | |
} | |
%w(observers sweepers mailers).each do |dir| | |
config.load_paths << "#{RAILS_ROOT}/app/#{dir}" | |
end | |
config.active_record.observers = :user_observer | |
end | |
CODE | |
#generate(:haml_scaffold, "Post title:string body:text") | |
generate(:session, "user_session") | |
file 'db/migrate/001_create_users.rb', <<-CODE | |
class CreateUsers < ActiveRecord::Migration | |
def self.up | |
create_table :users do |t| | |
t.string :login, :null => false | |
t.string :crypted_password, :null => false | |
t.string :password_salt, :null => false # not needed if you are encrypting your pw instead of using a hash algorithm. | |
t.string :persistence_token, :null => false | |
t.string :single_access_token, :null => false # optional, see the tokens section below. | |
t.string :perishable_token, :null => false # optional, see the tokens section below. | |
t.integer :login_count, :null => false, :default => 0 # optional, this is a "magic" column, see the magic columns section below | |
end | |
end | |
def self.down | |
drop_table :posts | |
end | |
end | |
CODE | |
file 'app/models/user.rb', <<-CODE | |
class User < ActiveRecord::Base | |
acts_as_authentic # for options see documentation: Authlogic::ORMAdapters::ActiveRecordAdapter::ActsAsAuthentic::Config | |
end | |
CODE | |
generate("rspec") | |
generate("cucumber") | |
file 'features/support/env.rb', <<-CODE | |
# Sets up the Rails environment for Cucumber | |
ENV["RAILS_ENV"] = "test" | |
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') | |
require 'cucumber/rails/world' | |
require 'cucumber/formatters/unicode' # Comment out this line if you don't want Cucumber Unicode support | |
Cucumber::Rails.use_transactional_fixtures | |
require 'webrat/rails' | |
# Comment out the next two lines if you're not using RSpec's matchers (should / should_not) in your steps. | |
require 'cucumber/rails/rspec' | |
require 'webrat/rspec-rails' | |
require "webrat" | |
Webrat.configure do |config| | |
config.mode = :rails | |
end | |
CODE | |
#route "map.root :controller => 'posts'" | |
#rake("db:migrate") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment