-
-
Save dallas/143208 to your computer and use it in GitHub Desktop.
Rails template for v2.3 by henrik
This file contains hidden or 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
# Rails template for Rails 2.3. Work in progress. | |
# By Henrik Nyh (http://henrik.nyh.se) 2009-03-29. Public domain. | |
# Usage: rails myapp -m http://gist.github.com/87341.txt | |
META_AUTHOR = "Henrik Nyh (http://henrik.nyh.se)" | |
JQUERY_VERSION = "1.3.2" | |
APP_NAME = File.basename(Dir.pwd) | |
git :init | |
file ".gitignore", <<-END | |
.DS_Store | |
log/* | |
tmp/**/* | |
config/*.yml | |
db/*.sqlite3 | |
END | |
run "touch tmp/.gitignore log/.gitignore" | |
run "cp config/database.yml config/database.yml.sample" | |
# Delete unnecessary files | |
run "rm README" | |
run "rm doc/README_FOR_APP" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm -f public/images/* public/javascripts/*" | |
git :add => ".", :commit => "-m 'Initial commit.'" | |
gem 'settingslogic' | |
gem 'mocha' | |
gem 'thoughtbot-shoulda', :source => 'http://gems.github.com', :lib => 'shoulda' | |
gem 'thoughtbot-factory_girl', :source => 'http://gems.github.com', :lib => 'factory_girl' | |
gem 'mislav-will_paginate', :source => 'http://gems.github.com', | |
:version => '~> 2.2.3', :lib => 'will_paginate' | |
gem 'haml' | |
rake 'gems:install' | |
run 'haml --rails .' | |
plugin 'augmentations', :git => 'git://github.com/henrik/augmentations.git' | |
plugin 'nested_layouts', :git => 'git://github.com/amatsuda/nested_layouts.git' | |
plugin 'title_helpers', :git => 'git://github.com/henrik/title_helpers.git' | |
git :add => ".", :commit => "-m 'Plugins.'" | |
run "touch public/javascripts/application.js" | |
run "curl -L http://jqueryjs.googlecode.com/files/jquery-#{JQUERY_VERSION}.min.js > public/javascripts/jquery-#{JQUERY_VERSION}.min.js" | |
# Uncomment "filter_parameter_logging :password" | |
gsub_file 'app/controllers/application_controller.rb', | |
/#\s*(filter_parameter_logging :password)/, '\1' | |
# Remove config.gem examples | |
gsub_file 'config/environment.rb', | |
/\s*# Specify gems.*# config\.gem.*?\n/m, '' | |
file 'config/initializers/core_ext.rb', <<-END | |
class String | |
# Like String#capitalize, but only touches the first char, so "foo BAR" | |
# becomes "Foo BAR", not "Foo bar". | |
def capitalize_gently | |
return '' if empty? | |
(self.mb_chars.first.upcase + self.mb_chars.from(1)).to_s | |
end | |
end | |
class Object | |
# (foo.nonblank? || bar) is equivalent to (foo.blank? ? bar : foo) | |
def nonblank? | |
!blank? && self | |
end | |
end | |
END | |
file 'config/initializers/plugins.rb', <<-END | |
Haml::Template.options[:attr_wrapper] = %{"} | |
END | |
file 'app/helpers/application_layout_helper.rb', <<-END | |
module ApplicationLayoutHelper | |
def body_classes | |
classes = controller.controller_path.split('/') << controller.action_name | |
{ :class => classes.join(' ') } | |
end | |
def stylesheet_links | |
stylesheet_link_tag(%W[ | |
application | |
], :cache => true) | |
end | |
def javascript_includes | |
javascript_include_tag %W[ | |
jquery-#{JQUERY_VERSION}.min | |
application | |
], :cache => true | |
end | |
end | |
END | |
file 'public/stylesheets/sass/constants.sass', <<-END | |
!font = "'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif" | |
END | |
file 'public/stylesheets/sass/application.sass', <<-END | |
@import constants | |
body | |
background: #FFF | |
margin: 0 | |
padding: 25px 15px | |
:font-family = !font | |
font-size: 15px | |
END | |
file 'config/application.yml.template', <<-END | |
defaults: &defaults | |
title: #{APP_NAME} | |
development: | |
<<: *defaults | |
title: DEV #{APP_NAME} | |
test: | |
<<: *defaults | |
production: | |
<<: *defaults | |
END | |
run "cp config/application.yml.template config/application.yml" | |
file 'app/views/layouts/application.html.haml', <<-END | |
!!! Strict | |
%html{ html_attrs } | |
%head | |
%meta{ :"http-equiv" => 'Content-Type', :content => 'text/html; charset=utf-8' } | |
%title= title(#{Settings.title}) | |
%link{ :rel => 'shortcut icon', :href => '/images/favicon.png', :type => 'image/png' } | |
= stylesheet_links | |
= yield :stylesheets | |
= javascript_includes | |
= yield :javascripts | |
%meta{ :name => 'author', :content => #{META_AUTHOR.inspect} } | |
%body{ body_classes } | |
#container | |
#content | |
= yield | |
#footer | |
%p== Copyright© \#{Date.today.year}. | |
END | |
git :add => ".", :commit => "-m 'Customize.'" | |
# TODO | |
# more custom initializers and helpers? See http://github.com/jeremymcanally/rails-templates/blob/68bada09dbd577b277a49ee4f3fea30fb0bc618c/suspenders.rb | |
# MySQL | |
# config object | |
# Exception logging? | |
# Capify | |
# Open app in TextMate | |
run "mate ." if yes?('Open app in TextMate (y/n)?') | |
# TODO: matewait, open /etc/hosts and Apache configs for Passenger? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment