Created
March 25, 2013 18:05
-
-
Save mikegee/5239242 to your computer and use it in GitHub Desktop.
script to generate a rails app with some stuff I always use
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
#!/bin/zsh | |
source "$HOME/.rvm/scripts/rvm" | |
rvm use 1.9.3@global | |
rails new $1 --skip-bundle --skip-test-unit | |
cd $1 | |
rm public/index.html | |
git init . | |
git add . | |
git commit -m'generated Rails app' | |
echo rvm use 1.9.3@$1 --create > .rvmrc | |
`cat .rvmrc` | |
git add . | |
git commit -m'rvmrc' | |
cat > config/routes.rb <<EOF | |
Rails.application.routes.draw do | |
end | |
EOF | |
git commit -am'empty routes' | |
cat > Gemfile <<EOF | |
source 'https://rubygems.org' | |
gem 'rails' | |
gem 'sqlite3', group: [:test, :development] | |
gem 'pg', group: [:production, :staging] | |
gem 'bootstrap-sass' | |
gem 'haml' | |
gem 'jquery-rails' | |
gem 'jquery-turbolinks' | |
gem 'sass-rails' | |
gem 'simple_form' | |
gem 'thin' | |
gem 'turbolinks' | |
group :development do | |
gem 'guard-rspec' | |
gem 'rb-fsevent', require: false | |
end | |
group :test do | |
gem 'capybara' | |
gem 'launchy' | |
gem 'shoulda-matchers' | |
end | |
group :test, :development do | |
gem 'factory_girl_rails' | |
gem 'haml-rails' | |
gem 'rspec-rails' | |
end | |
group :assets do | |
gem 'sass-rails' | |
gem 'coffee-rails' | |
gem 'uglifier' | |
end | |
EOF | |
bundle install --without production staging | |
git add . | |
git commit -am'bunch of gems' | |
rails generate rspec:install | |
bundle exec guard init | |
git add . | |
git commit -m'setup rspec and guard' | |
cat > app/assets/stylesheets/bootstrap_and_overrides.css.scss <<EOF | |
@import "bootstrap"; | |
body { padding-top: 60px; } | |
@import "bootstrap-responsive"; | |
EOF | |
git rm app/views/layouts/application.html.erb | |
cat > app/views/layouts/application.html.haml <<EOF | |
!!! | |
%html | |
%head | |
%meta{content: "width=device-width, initial-scale=1.0", name: "viewport"} | |
%title= content_for?(:title) ? yield(:title) : "$1" | |
%meta{content: content_for?(:description) ? yield(:description) : "$1", name: "description"} | |
= stylesheet_link_tag "application", media: "all" | |
= javascript_include_tag "application" | |
= csrf_meta_tags | |
= yield(:head) | |
%body{class: "#{controller_name} #{action_name}"} | |
%header.navbar.navbar-fixed-top.navbar-inverse | |
%nav.navbar-inner | |
.container | |
= render 'layouts/navigation' | |
.container | |
.content | |
.row | |
.span12 | |
= render 'layouts/messages' | |
= yield | |
%footer | |
EOF | |
cat > app/views/layouts/_navigation.html.haml <<EOF | |
= link_to '$1', root_path, class: 'brand' | |
- if current_user | |
%ul.nav | |
= nav_link 'Link 1', root_path | |
%ul.nav.pull-right | |
%li.dropdown | |
%a.dropdown-toggle{'data-toggle' => 'dropdown', 'href' => '#'} | |
= current_user.name | |
%b.caret | |
%ul.dropdown-menu | |
%li= link_to 'Logout', logout_path, method: 'delete' | |
- else | |
%ul.nav.pull-right | |
%li | |
= link_to 'Login', login_path | |
EOF | |
cat > app/views/layouts/_messages.html.haml <<EOF | |
- flash.each do |name, msg| | |
- if msg.is_a?(String) | |
%div{class: "alert alert-#{name == :notice ? "success" : "error"}"} | |
%a.close{"data-dismiss" => "alert"} × | |
= content_tag :div, msg, id: "flash_#{name}" | |
EOF | |
cat > app/helpers/layout_helper.rb <<EOF | |
module LayoutHelper | |
def nav_link(name, path) | |
content_tag :li, class: current_page?(path) ? 'active' : nil do | |
link_to name, path | |
end | |
end | |
end | |
EOF | |
git add . | |
git commit -m'bootstrap layout' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment