-
-
Save notch8-old/839534 to your computer and use it in GitHub Desktop.
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
# An application template for Rails 3 | |
gem "factory_girl_rails", :group => [:development, :test] | |
gem "factory_girl_generator", :group => [:development, :test] | |
gem "rspec", :group => [:development, :test] | |
gem "rspec-rails", :group => [:development, :test] | |
gem "haml" | |
gem "haml-rails" | |
gem "compass" | |
gem "taps" | |
gem "heroku", :group => :development | |
begin | |
require 'bundler' | |
rescue Bundler::GemNotFound => e | |
STDERR.puts e.message | |
exit! | |
end | |
run 'bundle install' | |
run 'rails g rspec:install' | |
generators = <<-GENERATORS | |
config.generators do |g| | |
g.test_framework :rspec, :fixture => true, :views => false | |
g.integration_tool :rspec, :fixture => true, :views => true | |
g.template_engine :haml | |
g.fixture_replacement :factory_girl | |
end | |
GENERATORS | |
application generators | |
if !options["skip_prototype"] | |
# removing prototype files | |
remove_file "public/javascripts/controls.js" | |
remove_file "public/javascripts/dragdrop.js" | |
remove_file "public/javascripts/effects.js" | |
remove_file "public/javascripts/prototype.js" | |
remove_file "public/javascripts/jrails.js" | |
end | |
# getting jquery and rails.js for jquery | |
get "http://code.jquery.com/jquery-1.4.4.min.js", "public/javascripts/jquery.js" | |
get "https://github.com/rails/jquery-ujs/raw/master/src/rails.js", "public/javascripts/rails.js" | |
# ... and use it! | |
gsub_file 'config/application.rb', 'config.action_view.javascript_expansions[:defaults] = %w()', 'config.action_view.javascript_expansions[:defaults] = %w(jquery rails application)' | |
# describing of layout application | |
layout = <<-LAYOUT | |
!!! | |
%html | |
%head | |
%title= h(yield(:title) || "Untitled") | |
= stylesheet_link_tag :all | |
= javascript_include_tag :defaults | |
= csrf_meta_tag | |
= yield(:head) | |
%body | |
#container | |
- flash.each do |name, msg| | |
= content_tag :div, msg, :id => "flash_\#\{name\}", :class => 'flash' | |
%nav | |
= link_to "Home", root_url | |
%header | |
- if show_title? | |
%h1=h yield(:title) | |
%article | |
= yield | |
%footer | |
LAYOUT | |
# ... and a layout helper | |
layout_helper = <<-LAYOUTHELPER | |
# These helper methods can be called in your template to set variables to be used in the layout | |
# This module should be included in all views globally, | |
# to do so you may need to add this line to your ApplicationController | |
# helper :layout | |
module LayoutHelper | |
def title(page_title, show_title = true) | |
content_for(:title) { page_title.to_s } | |
@show_title = show_title | |
end | |
def show_title? | |
@show_title | |
end | |
def stylesheet(*args) | |
content_for(:head) { stylesheet_link_tag(*args) } | |
end | |
def javascript(*args) | |
content_for(:head) { javascript_include_tag(*args) } | |
end | |
end | |
LAYOUTHELPER | |
# adding correct routes | |
new_routes = <<-ROUTES | |
#root :to => 'pages#index' | |
ROUTES | |
# ... inject there | |
inject_into_file "config/routes.rb", "\n#{new_routes}", :after => "#{app_name.classify}::Application.routes.draw do" | |
# removing unused files | |
remove_file "README" | |
remove_file "public/index.html" | |
remove_file "public/images/rails.png" | |
remove_file "app/views/layouts/application.html.erb" | |
# creating the new ones | |
create_file 'README' | |
create_file "app/views/layouts/application.html.haml", layout | |
create_file "app/helpers/layout_helper.rb", layout_helper | |
run "compass init rails . -x sass --using blueprint/semantic --sass-dir public/stylesheets/sass --css-dir public/stylesheets" | |
puts "go to directory and let rails go ;)" | |
puts "$ cd #{app_name}" | |
puts "$ rake db:create" | |
puts "$ ./script/rails g scaffold Pages title:string body:text" | |
puts "edit config/routes.rb and uncomment root :to => 'pages#index'" | |
puts "$ ./script/rails s" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment