Skip to content

Instantly share code, notes, and snippets.

@andrzejsliwa
Forked from nimms/templator.rb
Created December 28, 2010 21:21
Show Gist options
  • Save andrzejsliwa/757734 to your computer and use it in GitHub Desktop.
Save andrzejsliwa/757734 to your computer and use it in GitHub Desktop.
# Cleaning up and extending the Gemfile
remove_file 'Gemfile'
create_file 'Gemfile', <<-GEMFILE
source 'http://rubygems.org'
gem 'rails', '3.0.1'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'haml', '~> 3.0.12'
gem 'compass', '~> 0.10.4'
gem 'compass-susy-plugin'
gem 'jsmin'
# Pick and choose here ->
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'devise', :branch => 'omniauth'
# gem 'omnisocial'
group :production, :test, :cucumber, :development do
gem 'aws-s3'
gem 'paperclip'
gem 'cancan'
end
group :test, :cucumber, :development do
gem 'factory_girl_rails', '~> 1.0.0'
gem 'factory_girl_generator'
gem 'haml-rails'
gem 'connie'
end
group :test, :cucumber do
gem 'capybara', '>= 0.3.8'
gem 'capybara-envjs'
gem 'cucumber-rails', '>= 0.3.2'
gem 'pickle', '>= 0.3.4'
gem 'database_cleaner', '>= 0.5.2'
gem 'launchy', '~> 0.3.5'
gem 'rspec-rails', '~> 2.0.0.beta.12'
gem 'fredo'
gem 'ruby-debug'
# gem 'spork', '>= 0.8.4'
end
group :development do
gem 'wirble'
gem 'awesome_print'
# gem 'slowgrowl'
end
GEMFILE
#plugin "asset_manager", :git => "git://github.com/evs/asset_manager.git"
# Initializers and loading
application 'config.autoload_paths += %W(#{config.root}/lib)'
create_file 'config/secrets.yml', <<-SECRETS
# Environment secrets
S3_KEY: somekey
S3_SECRET: somesecret
S3_BUCKET: my-own-bucket
SECRETS
File.open('config/environment.rb', 'r+') do |env|
environment = env.read
env.pos = 0
secrets = <<-ENVIRONMENT
# Load the environment variables
unless ENV['RACK_ENV'] == 'production'
begin
YAML.load_file(File.expand_path('secrets.yml', File.dirname(__FILE__))).each do |key, value|
ENV[key] = value
end
rescue
raise "Error loading secrets configuration, please edit config/secrets.yml"
end
end
ENVIRONMENT
env << secrets
env << environment
end
# Generators
application <<-GENERATORS
config.generators do |g|
g.template_engine :haml
g.test_framework :rspec, :fixture => true, :views => false
g.integration_tool :cucumber
g.fixture_replacement :factory_girl, :dir => "spec/factories"
end
GENERATORS
# A good way to reach your own generators
# empty_directory 'lib/generators'
# git :clone => "--depth 0 http://github.com/leshill/rails3-app.git lib/generators"
# remove_dir 'lib/generators/.git'
# remove_file 'lib/generators/app.rb'
# Javascript
get "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "public/javascripts/jquery.js"
get "http://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js", "public/javascripts/raphael.js"
get "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js", "public/javascripts/jquery-ui.js"
get "http://github.com/rails/jquery-ujs/raw/master/src/rails.js", "public/javascripts/rails.js"
get "http://github.com/ilpoldo/goverlay/raw/master/goverlay.js", "public/javascripts/goverlay.js"
get "http://github.com/Modernizr/Modernizr/raw/master/modernizr.js", "public/javascripts/modernizr.js"
remove_file 'public/javascripts/application.js'
create_file "public/javascripts/application.js", <<-APPLICATIONJS
var app = {
setupAjaxCallbacks: function () {
$('body').ajaxStart(function () {
});
$('body').ajaxStop(function () {
});
$('body').ajaxError(function (event, xhr, ajaxOptions, thrownError) {
console.log({event:event,response:xhr});
});
}
};
$(document).ready(function(){
jQuery.goverlay(30,10,18);
// Just to warm up my js:
(function(test_paragraph){
test_paragraph.append(test_paragraph.attr("data-message"));
})($('p[data-function=jstest]'));
});
APPLICATIONJS
# Haml
remove_file 'app/views/layouts/application.html.erb'
create_file 'app/views/layouts/application.html.haml', <<-LAYOUT
!!! html
%html{:lang=>"en",:class=>"no-js"}
%head
%meta{:charset=>"utf-8"}
%meta{:name=>"description", :content=>"Here is the description of your project."}
%meta{:name=>"author", :content=>"#{app_name.humanize}"}
%meta{:name=>"Copyright", :content=>"Copyright #{app_name.humanize} 2010. All Rights Reserved."}
%meta{:name=>"DC.title", :content=>"#{app_name.humanize} - The Anything Manager"}
%meta{:name=>"DC.subject", :content=>"Manage anything."}
%meta{:name=>"DC.creator", :content=>"Rangbeard Pty Ltd."}
%meta{:name=>"google-site-verification", :content=>""}
/ %link{:rel=>"shortcut icon", :href=>"/images/favicon.png"}
/ %link{:rel=>"apple-touch-icon", :href=>"/images/custom_icon.png"}
/ - size: 57x57 for older iPhones, 72x72 for iPads, 114x114 for iPhone4's retina display
/ - To prevent iOS from applying its styles to the icon name it thusly: apple-touch-icon-precomposed.png
/ - Transparency is not recommended (iOS will put a black BG behind the icon)
/[if lt IE 9]
= javascript_include_tag "http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"
= javascript_include_tag "application.js", "jquery.js", "raphael.js", "rails.js", "jquery-ui.js", "goverlay.js", "modernizr.js"
%title= @page_title
= yield :head
= stylesheet_link_tag 'screen.css', :media => 'screen, projection'
= stylesheet_link_tag 'print.css', :media => 'print'
/[if lt IE 8]
= stylesheet_link_tag 'ie.css', :media => 'screen, projection'
= csrf_meta_tag
%body
%header
%h1{ :role => "banner" }
%nav
%ul
%li= link_to "Home", root_path
%article
%section
= yield
%aside#aside
= yield(:sidebar)
%footer
LAYOUT
# Assets cleanup
remove_file "README"
remove_file "LICENSE"
remove_file "public/index.html"
# remove_file "public/favicon.ico"
remove_file "public/robots.txt"
remove_file "public/images/rails.png"
readme = <<-README
=#{app_name.humanize}
=== A Rails 3 application
== Copyright
Copyright (c) #{Time.now.year} Leandro Pedroni. See LICENSE for details.
README
create_file "README.md", readme
# how do I output errors from the bundle install??
run 'bundle install --without production'
# After the app responds
rake "db:migrate"
rake "secret"
generate "rspec:install"
generate "cucumber:install --rspec --capybara"
# generate "pickle --paths --email"
# Git
gitignore = <<-GITIGNORE
.bundle
db/*.sqlite3
log/*.log
tmp/**/*
.DS_Store
**/.DS_Store
db/schema.rb
config/secrets.yml
vendor/cache/*
GITIGNORE
remove_file '.gitignore'
create_file '.gitignore', gitignore
git :init
git :add => "."
git :commit => "-a -m 'Initial Commit'"
# Print documentation
docs = <<-DOCS
Good luck developing #{app_name.humanize}!
Don't forget to run: compass init rails . -r susy --using susy/project --syntax sass
DOCS
log docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment