Skip to content

Instantly share code, notes, and snippets.

@octopusinc
Created March 20, 2010 21:31
Show Gist options
  • Save octopusinc/338923 to your computer and use it in GitHub Desktop.
Save octopusinc/338923 to your computer and use it in GitHub Desktop.
Rails template for basic application
# shoestring.rb
# Rails template
# from Judd Kussrow of Octopus Inc
# $ rails new Project -Jm http://octopusinc.com/shoestring.rb
################################### MAINTENANCE ######
gem 'rails3-generators', :group => 'development'
gem 'nifty-generators', :group => 'development'
remove_file 'public/index.html'
remove_file 'public/favicon.ico'
remove_file 'public/images/rails.png'
remove_file 'README'
remove_file 'public/robots.txt'
remove_file 'config/database.yml'
run 'rmdir tmp/{pids,sessions,sockets,cache}'
run 'mkdir public/{fonts,videos}'
###################################### SHOEHORN ######
shoehorn = 'https://github.com/octopusinc/shoehorn/raw/master/'
create_file 'README'
%w[
config/database.yml
app/helpers/layout_helper.rb
public/crossdomain.xml
public/foaf.rdf
public/nginx.conf
public/p3p.xml
public/robots.txt
public/sitemap.xml
public/assets/alpha.htc
public/assets/blank.gif
public/assets/border.htc
public/assets/hover.htc
public/javascripts/belatedpng.min.js
public/javascripts/modernizr.min.js
public/javascripts/selectivizr.min.js
public/stylesheets/960.css
public/stylesheets/application.css
public/stylesheets/common.css
public/stylesheets/hack.css
public/stylesheets/handheld.css
public/stylesheets/ie.css
public/stylesheets/print.css
public/stylesheets/reset.css
public/stylesheets/shortcut.css
].each {|file| get shoehorn + file, file}
########################################## HAML ######
if yes? 'Using HAML? (yes/no)'
gem 'haml'
gem 'haml-rails', :group => 'development'
remove_file 'app/views/layouts/application.html.erb'
%w[
app/views/layouts/application.html.haml
app/views/shared/_footer.html.haml
app/views/shared/_header.html.haml
app/views/shared/_link.html.haml
app/views/shared/_meta.html.haml
app/views/shared/_script.html.haml
].each {|file| get shoehorn + file, file}
end
####################################### COMPASS ######
if yes? 'Using Compass? (yes/no)'
gem 'compass'
css_dir = 'public/stylesheets/compiled'
sass_dir = 'app/stylesheets'
compass = "compass init rails . --using blueprint/semantic --css-dir=#{css_dir} --sass-dir=#{sass_dir}"
end
###################################### OMNIAUTH ######
if yes? 'Using Omniauth? (yes/no)'
gem 'omniauth'
gem 'oa-oauth'
end
######################################## GITHUB ######
if yes? 'Using GitHub? (yes/no)'
#run 'find . -type d -empty -exec touch {}/.gitkeep \\;'
create_file 'log/.gitkeep'
create_file 'tmp/.gitkeep'
create_file 'archive/.gitkeep'
create_file 'legal/.gitkeep'
create_file 'source/.gitkeep'
create_file 'reference/.gitkeep'
get shoehorn + '.gitignore', '.gitignore'
git :init
git :add => '.', :commit => "-m 'Initial commit'"
user = ask "\nGitHub Account:"
repo = ask "\nRepository Name:"
run "git remote add origin [email protected]:#{user}/#{repo}.git"
run 'git push origin master'
end
######################################## HEROKU ######
if yes? 'Using Heroku? (yes/no)'
app = ask "\nApplication Name:"
domain = ask "\nDomain Name:"
run "heroku create #{app}"
run 'heroku addons:add custom_domains:basic'
run "heroku domains:add #{domain}"
run "heroku domains:add www.#{domain}"
run 'heroku addons:add zerigo_dns:basic'
run 'git push heroku master'
end
######################################## STATIC ######
if yes? 'Using semi-static pages? (yes/no)'
gem 'friendly_id'
static = 'rails g nifty:scaffold Page title:string content:text cached_slug:string --haml --skip'
remove_file 'app/models/page.rb'
remove_file 'app/controllers/pages_controller.rb'
get shoehorn + 'app/models/page.rb', 'app/models/page.rb'
get shoehorn + 'app/controllers/pages_controller.rb', 'app/controllers/pages_controller.rb'
get shoehorn + 'app/views/pages/static.html.haml', 'app/views/pages/static.html.haml'
route "match '/home' => 'pages#home'"
route "match ':page' => 'pages#static'"
route 'root :to => "pages#index"'
end
################################# CONFIGURATION ######
run 'bundle install'
run compass if defined? compass
if defined? static
run static
run 'rails g friendly_id'
end
rake 'db:migrate'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment