Skip to content

Instantly share code, notes, and snippets.

@jmazzi
Forked from rrichards/rhino_template.rb
Created April 15, 2009 15:49
Show Gist options
  • Save jmazzi/95857 to your computer and use it in GitHub Desktop.
Save jmazzi/95857 to your computer and use it in GitHub Desktop.
#
# rails template for skeleton app, haml, sass, shoulda, factory_girl, jquery
#
# TO-DO: Change the location of edge rails or equiv to match env.
#
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/code/rails-edge 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/*
public/stylesheets/*.css
END
# get jquery and plugins
run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.3.2.js > public/javascripts/jquery.js"
run "curl -L http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js > public/javascripts/jquery.form.js"
# 960.gs
run "curl -L http://github.com/nathansmith/960-grid-system/tree/master/code/css/uncompressed/960.css > public/stylesheets/960.css"
run "curl -L http://github.com/nathansmith/960-grid-system/tree/master/code/css/uncompressed/reset.css > public/stylesheets/reset.css"
run "curl -L http://github.com/nathansmith/960-grid-system/tree/master/code/css/uncompressed/text.css > public/stylesheets/text.css"
# SASS
#run "mkdir public/stylesheets/sass"
#run "css2sass 960.css public/stylesheets/sass/960.sass"
#run "css2sass text.css public/stylesheets/sass/text60.sass"
#run "css2sass reset.css public/stylesheets/sass/reset.sass"
#run 'rm *.css'
# environment
file 'config/environment.rb', <<-FILE
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
# config.load_paths += %W( \#{RAILS_ROOT}/extras )
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# config.time_zone = 'UTC'
end
FILE
# application layout
file 'app/views/layouts/application.html.haml', <<-FILE
!!!
%html{ "xml:lang" => "en", :lang => "en", :xmlns => "http://www.w3.org/1999/xhtml" }
%head
%meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-type" }
%title
\#{app_name}
<%= stylesheet_link_tag 'screen', 'datePicker', :media => 'screen, projection' %>
<%= stylesheet_link_tag 'print', :media => 'print' %>
/
[if IE]>
<%= stylesheet_link_tag 'ie', :media => 'all' %>
<![endif]
<%= javascript_include_tag 'jquery', 'jquery.form.js', 'date', 'jquery.datePicker.js', :cache => true %>
<%= yield(:head) %>
%script{ :type => "text/javascript" }
$(function() {
<%= yield(:jquery) %>
});
%body
#navigation
#content
<%- if flash[:notice] -%>
#flash
<%= flash[:notice] %>
<%- end -%>
<%= yield %>
FILE
# Install plugins as git submodules
plugin 'asset_packager', :git => 'git://github.com/sbecker/asset_packager.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 'jrails', :git => 'git://github.com/aaronchi/jrails.git', :submodule => true
# Install all gems
gem 'haml'
# Setup HAML
run %{haml .}
# 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')
rake('db:migrate')
# Commit all work so far to the repository
git :add => '.'
git :commit => "-a -m 'Initial commit'"
# Success!
puts "SUCCESS!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment