├── .gitignore ├── README ├── README.textile ├── files-v2 ├── .rvmrc ├── README ├── README.textile ├── app │ ├── assets │ │ └── stylesheets │ │ │ ├── application-bootstrap.css.scss │ │ │ └── application.css.scss │ └── views │ │ ├── devise │ │ ├── registrations │ │ │ ├── edit.html.erb │ │ │ ├── edit.html.haml │ │ │ ├── new.html.erb │ │ │ └── new.html.haml │ │ └── shared │ │ │ ├── _links.html.erb │ │ │ └── _links.html.haml │ │ ├── home │ │ ├── index-subdomains_app.html.erb │ │ ├── index-subdomains_app.html.haml │ │ ├── index.html.erb │ │ └── index.html.haml │ │ ├── layouts │ │ ├── _messages-bootstrap.html.erb │ │ ├── _messages-bootstrap.html.haml │ │ ├── _messages.html.erb │ │ ├── _messages.html.haml │ │ ├── _navigation-cancan.html.erb │ │ ├── _navigation-cancan.html.haml │ │ ├── _navigation-devise.html.erb │ │ ├── _navigation-devise.html.haml │ │ ├── _navigation-omniauth.html.erb │ │ ├── _navigation-omniauth.html.haml │ │ ├── _navigation-subdomains_app.html.erb │ │ ├── _navigation-subdomains_app.html.haml │ │ ├── _navigation.html.erb │ │ ├── _navigation.html.haml │ │ ├── application-bootstrap.html.erb │ │ ├── application-bootstrap.html.haml │ │ ├── application.html.erb │ │ └── application.html.haml │ │ ├── profiles │ │ ├── show-subdomains_app.html.erb │ │ └── show-subdomains_app.html.haml │ │ └── users │ │ ├── edit-omniauth.html.erb │ │ ├── edit-omniauth.html.haml │ │ ├── index.html.erb │ │ ├── index.html.haml │ │ ├── show-subdomains_app.html.erb │ │ ├── show-subdomains_app.html.haml │ │ ├── show.html.erb │ │ └── show.html.haml ├── config │ ├── database-mysql.yml │ └── database-postgresql.yml └── public │ └── humans.txt ├── files ├── devise-views-haml │ └── app │ │ └── views │ │ └── devise │ │ ├── _links.erb │ │ ├── registrations │ │ ├── edit.html.haml │ │ └── new.html.haml │ │ └── shared │ │ └── _links.html.haml ├── gitignore.txt ├── humans.txt ├── navigation │ ├── devise │ │ ├── _navigation.html.erb │ │ ├── _navigation.html.haml │ │ └── authorization │ │ │ ├── _navigation.html.erb │ │ │ └── _navigation.html.haml │ ├── none │ │ ├── _navigation.html.erb │ │ └── _navigation.html.haml │ ├── omniauth │ │ ├── _navigation.html.erb │ │ └── _navigation.html.haml │ └── subdomains │ │ ├── _navigation.html.erb │ │ └── _navigation.html.haml ├── sample_readme.textile ├── sample_readme.txt ├── simple │ ├── assets │ │ └── stylesheets │ │ │ └── application.css.scss │ └── views │ │ └── layouts │ │ ├── _messages.html.erb │ │ ├── _messages.html.haml │ │ ├── application.html.erb │ │ └── application.html.haml ├── twitter-bootstrap │ ├── assets │ │ └── stylesheets │ │ │ └── application.css.scss │ └── views │ │ └── layouts │ │ ├── _messages.html.erb │ │ ├── _messages.html.haml │ │ ├── application.html.erb │ │ └── application.html.haml └── views │ └── layouts │ ├── application.html.erb │ └── application.html.haml ├── rails-prelaunch-signup-template.rb ├── rails3-bootstrap-devise-cancan-template.rb ├── rails3-devise-rspec-cucumber-template.rb ├── rails3-haml-html5-template.rb ├── rails3-mongoid-devise-template.rb ├── rails3-mongoid-omniauth-template.rb └── rails3-subdomains-template.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | db/*.sqlite3 3 | log/*.log 4 | tmp/**/* 5 | .DS_Store -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Rails3-Application-Templates 2 | ======================== 3 | 4 | You can use these templates to generate a Rails web application. 5 | ________________________ 6 | 7 | See the README file on GitHub 8 | 9 | For more information, please see the updated README file on GitHub: 10 | 11 | http://github.com/RailsApps/rails3-application-templates 12 | 13 | ________________________ 14 | 15 | MIT License 16 | 17 | 18 | -------------------------------------------------------------------------------- /README.textile: -------------------------------------------------------------------------------- 1 | h1. !http://railsapps.github.com/images/rails-36x36.jpg(Rails 3.2 Application Templates)! Rails 3.2 Application Templates 2 | 3 | h3. These application templates are deprecated (no longer maintained). 4 | 5 | h3. Use the "Rails Composer":http://railsapps.github.com/rails-composer/ tool instead. The Rails Composer tool creates the example applications for the RailsApps project. The tool gives you a Rails 3.2 starter app you can deploy in minutes. 6 | 7 | h2. Dependencies 8 | 9 | Before generating your application, you will need: 10 | 11 | * The Ruby language (version 1.9.3) 12 | * Rails 3.2 13 | 14 | See "Installing Rails":http://railsapps.github.com/installing-rails.html for detailed instructions and advice. 15 | 16 | h2. Creating a Starter App 17 | 18 | To build a Rails application, run the command (where @myapp@ is the name of your application): 19 | 20 |
 21 | $ rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
 22 | 
23 | 24 | You can use the @-T@ flag to skip Test::Unit files or the @-O@ flag to skip Active Record files: 25 | 26 |
 27 | $ rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb -T -O
 28 | 
29 | 30 | h2. Application Template Default 31 | 32 | The @rails new@ command creates a new Rails application. If you want to use a template for every Rails application you build, you can set options for the @rails new@ command in a *.railsrc* file in your home directory. Here's how to set up a *.railsrc* file to use a template when you create a new Rails application: 33 | 34 |
 35 | # ~/.railsrc
 36 | -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
 37 | 
38 | 39 | h2. Troubleshooting 40 | 41 | Problems? Check the "issues for the rails_apps_composer gem":https://github.com/RailsApps/rails_apps_composer/issues. 42 | 43 | You should review the article "Installing Rails":http://railsapps.github.com/installing-rails.html to make sure you've updated all the components that are required to run Rails successfully. 44 | 45 | h4. Problems with "Certificate Verify Failed" 46 | 47 | Are you getting an error "OpenSSL certificate verify failed" when you try to generate a new Rails app from an application template? See suggestions to resolve the error "Certificate Verify Failed":http://railsapps.github.com/openssl-certificate-verify-failed.html. 48 | 49 | h4. Problems with "Segmentation Fault" 50 | 51 | If you get a "segfault" when you try @rails new@, try removing and reinstalling rvm. 52 | 53 | h2. Documentation and Support 54 | 55 | The application templates are assembled from recipes supplied by the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem. See the rails_apps_composer project to understand how the application templates work. 56 | 57 | h4. Customizing the Template 58 | 59 | If you wish to change a template to generate an app with your own customized options, you can copy and edit the template file. However, it is better to use the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem to create a new application template. You'll find newer versions of the recipes that make up the application template. You may find issues have been identified and (perhaps) fixed. And it will be easier to maintain your application template if you work from the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem. 60 | 61 | h4. Writing Recipes 62 | 63 | To understand the code in these templates, take a look at "Thor::Actions":http://rdoc.info/github/wycats/thor/master/Thor/Actions. Your recipes can use any methods provided by "Thor::Actions":http://rdoc.info/github/wycats/thor/master/Thor/Actions or "Rails::Generators::Actions":http://railsapi.com/doc/rails-v3.0.3/classes/Rails/Generators/Actions.html. 64 | 65 | h4. About Rails Application Templates 66 | 67 | "Cooking Up A Custom Rails 3 Template (11 Oct 2010) by Andrea Singh":http://blog.madebydna.com/all/code/2010/10/11/cooking-up-a-custom-rails3-template.html 68 | "Rails Application Templates (16 Sept 2010) by Collin Schaafsma":http://quickleft.com/blog/rails-application-templates 69 | "Application templates in Rails 3 (18 Sept 2009) by Ben Scofield":http://benscofield.com/2009/09/application-templates-in-rails-3/ 70 | "Railscasts: App Templates in Rails 2.3 (9 Feb 2009) by Ryan Bates":http://railscasts.com/episodes/148-app-templates-in-rails-2-3 71 | "Rails templates (4 Dec 2008) by Pratik Naik":http://m.onkey.org/rails-templates 72 | 73 | h4. Similar Projects 74 | 75 | There are many similar projects: 76 | 77 | * "Rails application template projects":http://railsapps.github.com/rails-application-templates.html 78 | * "Rails examples, tutorials, and starter apps":http://railsapps.github.com/rails-examples-tutorials.html. 79 | 80 | h4. Issues 81 | 82 | Please review "issues for the rails_apps_composer gem":https://github.com/RailsApps/rails_apps_composer/issues and submit any issues there. 83 | 84 | h4. Where to Get Help 85 | 86 | Your best source for help with problems is "Stack Overflow":http://stackoverflow.com/questions/tagged/ruby-on-rails-3. Your issue may have been encountered and addressed by others. 87 | 88 | You can also try "Rails Hotline":http://www.railshotline.com/, a free telephone hotline for Rails help staffed by volunteers. 89 | 90 | h2. Contributing 91 | 92 | Please make changes to the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem rather than changing the application templates. 93 | 94 | h2. Credits 95 | 96 | Daniel Kehoe initiated the "RailsApps project":https://github.com/RailsApps and created the Rails Composer application template. 97 | 98 | Is it useful to you? Follow the project on Twitter: 99 | "@rails_apps":http://twitter.com/rails_apps 100 | and tweet some praise. I'd love to know you were helped out by what I've put together. 101 | 102 | h2. License 103 | 104 | "MIT License":http://www.opensource.org/licenses/mit-license 105 | 106 | Copyright 2012 Daniel Kehoe 107 | 108 | h2. Useful Links 109 | 110 | |_. Getting Started |_. Articles |_. Tutorials | 111 | | "Rails Tutorial":https://tutorials.railsapps.org/rails-tutorial (recommendations) | "Heroku and Rails":http://railsapps.github.com/rails-heroku-tutorial.html | "Devise with CanCan and Twitter Bootstrap":https://tutorials.railsapps.org/rails3-bootstrap-devise-cancan | 112 | | "Rails":http://railsapps.github.com/rails.html (resources)| "Twitter Bootstrap and Rails":http://railsapps.github.com/twitter-bootstrap-rails.html | "Rails Membership Site with Stripe":https://tutorials.railsapps.org/rails-stripe-membership-saas | 113 | | "Installing Rails":http://railsapps.github.com/installing-rails.html | "JavaScript and Rails":http://railsapps.github.com/rails-javascript-include-external.html | "Rails Subscription Site with Recurly":https://tutorials.railsapps.org/rails-recurly-subscription-saas | 114 | | "Updating Rails":http://railsapps.github.com/updating-rails.html | "Rails Environment Variables":http://railsapps.github.com/rails-environment-variables.html | "Startup Prelaunch Signup Application":http://railsapps.github.com/tutorial-rails-prelaunch-signup.html | 115 | | "Rails Composer":http://railsapps.github.com/rails-composer/ | "Git and GitHub with Rails":http://railsapps.github.com/rails-git.html | "Devise with RSpec and Cucumber":http://railsapps.github.com/tutorial-rails-devise-rspec-cucumber.html | 116 | | "Rails Examples":http://railsapps.github.com/ | "Send Email with Rails":http://railsapps.github.com/rails-send-email.html | "Devise with Mongoid":http://railsapps.github.com/tutorial-rails-mongoid-devise.html | 117 | | "Rails Starter Apps":http://railsapps.github.com/rails-examples-tutorials.html | "Haml and Rails":http://railsapps.github.com/rails-haml.html | "OmniAuth with Mongoid":http://railsapps.github.com/tutorial-rails-mongoid-omniauth.html | 118 | | | "Rails Application Layout":http://railsapps.github.com/rails-default-application-layout.html | "Subdomains with Devise":http://railsapps.github.com/tutorial-rails-subdomains.html | 119 | | | "HTML5 Boilerplate for Rails":http://railsapps.github.com/rails-html5-boilerplate.html | | 120 | | | "Example Gemfiles for Rails":http://railsapps.github.com/rails-3-2-example-gemfile.html | | 121 | | | "Rails Application Templates":http://railsapps.github.com/rails-application-templates.html | | 122 | 123 | !https://cruel-carlota.pagodabox.com/face2018e437828af58da43b847d6178(githalytics.com alpha)! 124 | -------------------------------------------------------------------------------- /files-v2/.rvmrc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This is an RVM Project .rvmrc file, used to automatically load the ruby 4 | # development environment upon cd'ing into the directory 5 | 6 | # First we specify our desired [@], the @gemset name is optional, 7 | # Only full ruby name is supported here, for short names use: 8 | # echo "rvm use 1.9.3" > .rvmrc 9 | environment_id="ruby-1.9.3@App_Name" 10 | 11 | # Uncomment the following lines if you want to verify rvm version per project 12 | # rvmrc_rvm_version="1.14.2 (latest)" # 1.10.1 seams as a safe start 13 | # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || { 14 | # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading." 15 | # return 1 16 | # } 17 | 18 | # First we attempt to load the desired environment directly from the environment 19 | # file. This is very fast and efficient compared to running through the entire 20 | # CLI and selector. If you want feedback on which environment was used then 21 | # insert the word 'use' after --create as this triggers verbose mode. 22 | if [[ -d "${rvm_path:-$HOME/.rvm}/environments" 23 | && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] 24 | then 25 | \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id" 26 | [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] && 27 | \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true 28 | else 29 | # If the environment file has not yet been created, use the RVM CLI to select. 30 | rvm --create "$environment_id" || { 31 | echo "Failed to create RVM environment '${environment_id}'." 32 | return 1 33 | } 34 | fi 35 | 36 | # If you use bundler, this might be useful to you: 37 | # if [[ -s Gemfile ]] && { 38 | # ! builtin command -v bundle >/dev/null || 39 | # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null 40 | # } 41 | # then 42 | # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n" 43 | # gem install bundler 44 | # fi 45 | # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null 46 | # then 47 | # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete' 48 | # fi 49 | -------------------------------------------------------------------------------- /files-v2/README: -------------------------------------------------------------------------------- 1 | App_Name 2 | ======================== 3 | 4 | This application was generated with the rails_apps_composer gem: 5 | https://github.com/RailsApps/rails_apps_composer 6 | provided by the RailsApps Project: 7 | http://railsapps.github.com/ 8 | 9 | ________________________ 10 | 11 | Recipes: 12 | RECIPES 13 | 14 | Preferences: 15 | PREFERENCES 16 | 17 | ________________________ 18 | 19 | License -------------------------------------------------------------------------------- /files-v2/README.textile: -------------------------------------------------------------------------------- 1 | h1. App_Name 2 | 3 | This application was generated with the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem provided by the "RailsApps Project":http://railsapps.github.com/. 4 | 5 | h2. Diagnostics 6 | 7 | This application was built with recipes that are known to work together. 8 | 9 | This application was built with preferences that are known to work together. 10 | 11 | If the application doesn't work as expected, please "report an issue":https://github.com/RailsApps/rails_apps_composer/issues and include these diagnostics: 12 | 13 | We'd also like to know if you've found combinations of recipes or preferences that do work together. 14 | 15 | Recipes: 16 | RECIPES 17 | 18 | Preferences: 19 | PREFERENCES 20 | 21 | h2. Ruby on Rails 22 | 23 | This application requires: 24 | 25 | * Ruby 26 | * Rails 27 | 28 | Learn more about "Installing Rails":http://railsapps.github.com/installing-rails.html. 29 | 30 | h2. Database 31 | 32 | This application uses SQLite with ActiveRecord. 33 | 34 | h2. Development 35 | 36 | * Template Engine: ERB 37 | * Testing Framework: Test::Unit 38 | * Front-end Framework: None 39 | * Form Builder: None 40 | * Authentication: None 41 | * Authorization: None 42 | 43 | h2. Email 44 | 45 | The application is configured to send email using a Gmail account. 46 | 47 | h2. Getting Started 48 | 49 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 50 | 51 | h2. Documentation and Support 52 | 53 | This is the only documentation. 54 | 55 | h4. Issues 56 | 57 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 58 | 59 | h2. Similar Projects 60 | 61 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 62 | 63 | h2. Contributing 64 | 65 | If you make improvements to this application, please share with others. 66 | 67 | * Fork the project on GitHub. 68 | * Make your feature addition or bug fix. 69 | * Commit with Git. 70 | * Send the author a pull request. 71 | 72 | If you add functionality to this application, create an alternative implementation, or build an application that is similar, please contact me and I'll add a note to the README so that others can find your work. 73 | 74 | h2. Credits 75 | 76 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 77 | 78 | h2. License 79 | 80 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. -------------------------------------------------------------------------------- /files-v2/app/assets/stylesheets/application-bootstrap.css.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the top of the 9 | * compiled file, but it's generally better to create a new file per style scope. 10 | * 11 | *= require_self 12 | *= require_tree . 13 | */ 14 | 15 | .content { 16 | background-color: #eee; 17 | padding: 20px; 18 | margin: 0 -20px; /* negative indent the amount of the padding to maintain the grid system */ 19 | -webkit-border-radius: 0 0 6px 6px; 20 | -moz-border-radius: 0 0 6px 6px; 21 | border-radius: 0 0 6px 6px; 22 | -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15); 23 | -moz-box-shadow: 0 1px 2px rgba(0,0,0,.15); 24 | box-shadow: 0 1px 2px rgba(0,0,0,.15); 25 | } 26 | -------------------------------------------------------------------------------- /files-v2/app/assets/stylesheets/application.css.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the top of the 9 | * compiled file, but it's generally better to create a new file per style scope. 10 | * 11 | *= require_self 12 | *= require_tree . 13 | */ 14 | .brand { 15 | float: left; 16 | padding-right: 8px; 17 | } 18 | ul.nav { 19 | list-style: none; 20 | margin: 0 0 2em; 21 | padding: 0; 22 | } 23 | ul.nav li { 24 | display: inline; 25 | } 26 | #flash_notice, #flash_alert { 27 | padding: 5px 8px; 28 | margin: 10px 0; 29 | } 30 | #flash_notice { 31 | background-color: #CFC; 32 | border: solid 1px #6C6; 33 | } 34 | #flash_alert { 35 | background-color: #FCC; 36 | border: solid 1px #C66; 37 | } 38 | -------------------------------------------------------------------------------- /files-v2/app/views/devise/registrations/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Edit <%= resource_name.to_s.humanize %>

2 | 3 | <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> 4 | <%= devise_error_messages! %> 5 |

<%= f.label :name %>
6 | <%= f.text_field :name %>

7 | 8 |
<%= f.label :email %>
9 | <%= f.email_field :email %>
10 | 11 |
<%= f.label :password %> (leave blank if you don't want to change it)
12 | <%= f.password_field :password, :autocomplete => "off" %>
13 | 14 |
<%= f.label :password_confirmation %>
15 | <%= f.password_field :password_confirmation %>
16 | 17 |
<%= f.label :current_password %> (we need your current password to confirm your changes)
18 | <%= f.password_field :current_password %>
19 | 20 |
<%= f.submit "Update" %>
21 | <% end %> 22 | 23 |

Cancel my account

24 | 25 |

Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.

26 | 27 | <%= link_to "Back", :back %> 28 | -------------------------------------------------------------------------------- /files-v2/app/views/devise/registrations/edit.html.haml: -------------------------------------------------------------------------------- 1 | %h2 2 | Edit #{resource_name.to_s.humanize} 3 | = form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| 4 | = devise_error_messages! 5 | %p 6 | = f.label :name 7 | %br/ 8 | = f.text_field :name 9 | %div 10 | = f.label :email 11 | %br/ 12 | = f.email_field :email 13 | %div 14 | = f.label :password 15 | %i (leave blank if you don't want to change it) 16 | %br/ 17 | = f.password_field :password, :autocomplete => "off" 18 | %div 19 | = f.label :password_confirmation 20 | %br/ 21 | = f.password_field :password_confirmation 22 | %div 23 | = f.label :current_password 24 | %i (we need your current password to confirm your changes) 25 | %br/ 26 | = f.password_field :current_password 27 | %div= f.submit "Update" 28 | %h3 Cancel my account 29 | %p 30 | Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete}. 31 | = link_to "Back", :back -------------------------------------------------------------------------------- /files-v2/app/views/devise/registrations/new.html.erb: -------------------------------------------------------------------------------- 1 |

Sign up

2 | 3 | <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> 4 | <%= devise_error_messages! %> 5 |

<%= f.label :name %>
6 | <%= f.text_field :name %>

7 | 8 |
<%= f.label :email %>
9 | <%= f.email_field :email %>
10 | 11 |
<%= f.label :password %>
12 | <%= f.password_field :password %>
13 | 14 |
<%= f.label :password_confirmation %>
15 | <%= f.password_field :password_confirmation %>
16 | 17 |
<%= f.submit "Sign up" %>
18 | <% end %> 19 | 20 | <%= render "devise/shared/links" %> 21 | -------------------------------------------------------------------------------- /files-v2/app/views/devise/registrations/new.html.haml: -------------------------------------------------------------------------------- 1 | %h2 Sign up 2 | = form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| 3 | = devise_error_messages! 4 | %p 5 | = f.label :name 6 | %br/ 7 | = f.text_field :name 8 | %div 9 | = f.label :email 10 | %br/ 11 | = f.email_field :email 12 | %div 13 | = f.label :password 14 | %br/ 15 | = f.password_field :password 16 | %div 17 | = f.label :password_confirmation 18 | %br/ 19 | = f.password_field :password_confirmation 20 | %div= f.submit "Sign up" 21 | = render :partial => "devise/shared/links" -------------------------------------------------------------------------------- /files-v2/app/views/devise/shared/_links.html.erb: -------------------------------------------------------------------------------- 1 | <%- if controller_name != 'sessions' %> 2 | <%= link_to "Sign in", new_session_path(resource_name) %>
3 | <% end -%> 4 | 5 | <%- if devise_mapping.registerable? && controller_name != 'registrations' %> 6 | <%= link_to "Sign up", new_registration_path(resource_name) %>
7 | <% end -%> 8 | 9 | <%- if devise_mapping.recoverable? && controller_name != 'passwords' %> 10 | <%= link_to "Forgot your password?", new_password_path(resource_name) %>
11 | <% end -%> 12 | 13 | <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> 14 | <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
15 | <% end -%> 16 | 17 | <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> 18 | <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
19 | <% end -%> 20 | 21 | <%- if devise_mapping.omniauthable? %> 22 | <%- resource_class.omniauth_providers.each do |provider| %> 23 | <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
24 | <% end -%> 25 | <% end -%> -------------------------------------------------------------------------------- /files-v2/app/views/devise/shared/_links.html.haml: -------------------------------------------------------------------------------- 1 | - if controller_name != 'sessions' 2 | = link_to "Sign in", new_session_path(resource_name) 3 | %br/ 4 | - if devise_mapping.registerable? && controller_name != 'registrations' 5 | = link_to "Sign up", new_registration_path(resource_name) 6 | %br/ 7 | - if devise_mapping.recoverable? && controller_name != 'passwords' 8 | = link_to "Forgot your password?", new_password_path(resource_name) 9 | %br/ 10 | - if devise_mapping.confirmable? && controller_name != 'confirmations' 11 | = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) 12 | %br/ 13 | - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' 14 | = link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) 15 | %br/ 16 | - if devise_mapping.omniauthable? 17 | - resource_class.omniauth_providers.each do |provider| 18 | = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) 19 | %br/ -------------------------------------------------------------------------------- /files-v2/app/views/home/index-subdomains_app.html.erb: -------------------------------------------------------------------------------- 1 |

Home

2 | <% @users.each do |user| %> 3 |

<%= #{user.name} profile: #{link_to root_url(:subdomain => user.name), root_url(:subdomain => user.name)} %>

4 | <% end %> -------------------------------------------------------------------------------- /files-v2/app/views/home/index-subdomains_app.html.haml: -------------------------------------------------------------------------------- 1 | %h3 Home 2 | - @users.each do |user| 3 | %br/ 4 | #{user.name} profile: #{link_to root_url(:subdomain => user.name), root_url(:subdomain => user.name)} 5 | -------------------------------------------------------------------------------- /files-v2/app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 |

Home

2 | <% @users.each do |user| %> 3 |

User: <%=link_to user.name, user %>

4 | <% end %> -------------------------------------------------------------------------------- /files-v2/app/views/home/index.html.haml: -------------------------------------------------------------------------------- 1 | %h3 Home 2 | - @users.each do |user| 3 | %p 4 | User: #{link_to user.name, user} -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_messages-bootstrap.html.erb: -------------------------------------------------------------------------------- 1 | <% flash.each do |name, msg| %> 2 |
"> 3 | × 4 | <%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %> 5 |
6 | <% end %> -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_messages-bootstrap.html.haml: -------------------------------------------------------------------------------- 1 | - flash.each do |name, msg| 2 | %div{:class => "alert alert-#{name == :notice ? "success" : "error"}"} 3 | %a.close{"data-dismiss" => "alert"} × 4 | = content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_messages.html.erb: -------------------------------------------------------------------------------- 1 | <% flash.each do |name, msg| %> 2 | <%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %> 3 | <% end %> -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_messages.html.haml: -------------------------------------------------------------------------------- 1 | - flash.each do |name, msg| 2 | = content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_navigation-cancan.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "App_Name", root_path, :class => 'brand' %> 2 | -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_navigation-cancan.html.haml: -------------------------------------------------------------------------------- 1 | = link_to "App_Name", root_path, :class => 'brand' 2 | %ul.nav 3 | - if user_signed_in? 4 | %li 5 | = link_to('Logout', destroy_user_session_path, :method=>'delete') 6 | - else 7 | %li 8 | = link_to('Login', new_user_session_path) 9 | - if user_signed_in? 10 | %li 11 | = link_to('Edit account', edit_user_registration_path) 12 | - if current_user.has_role? :admin 13 | %li 14 | = link_to('Admin', users_path) 15 | - else 16 | %li 17 | = link_to('Sign up', new_user_registration_path) -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_navigation-devise.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "App_Name", root_path, :class => 'brand' %> 2 | -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_navigation-devise.html.haml: -------------------------------------------------------------------------------- 1 | = link_to "App_Name", root_path, :class => 'brand' 2 | %ul.nav 3 | - if user_signed_in? 4 | %li 5 | = link_to('Logout', destroy_user_session_path, :method=>'delete') 6 | - else 7 | %li 8 | = link_to('Login', new_user_session_path) 9 | - if user_signed_in? 10 | %li 11 | = link_to('Edit account', edit_user_registration_path) 12 | - else 13 | %li 14 | = link_to('Sign up', new_user_registration_path) -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_navigation-omniauth.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "App_Name", root_path, :class => 'brand' %> 2 | -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_navigation-omniauth.html.haml: -------------------------------------------------------------------------------- 1 | = link_to "App_Name", root_path, :class => 'brand' 2 | %ul.nav 3 | - if user_signed_in? 4 | %li 5 | Logged in as #{current_user.name} 6 | %li 7 | = link_to('Logout', signout_path) 8 | - else 9 | %li 10 | = link_to('Login', signin_path) -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_navigation-subdomains_app.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "App_Name", root_path, :class => 'brand' %> 2 | -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_navigation-subdomains_app.html.haml: -------------------------------------------------------------------------------- 1 | = link_to "App_Name", root_path, :class => 'brand' 2 | %ul.nav 3 | %li 4 | = link_to 'Main', root_url(:host => request.domain) 5 | - if request.subdomain.present? && request.subdomain != "www" 6 | - if user_signed_in? 7 | %li 8 | = link_to('Edit account', edit_user_registration_url) 9 | %li 10 | = link_to('Logout', destroy_user_session_url, :method=>'delete') 11 | - else 12 | %li 13 | = link_to('Login', new_user_session_url) 14 | - else 15 | %li 16 | = link_to('Sign up', new_user_registration_url(:host => request.domain)) 17 | - if user_signed_in? 18 | %li 19 | = link_to('Logout', destroy_user_session_url, :method=>'delete') -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_navigation.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "App_Name", root_path, :class => 'brand' %> -------------------------------------------------------------------------------- /files-v2/app/views/layouts/_navigation.html.haml: -------------------------------------------------------------------------------- 1 | = link_to "App_Name", root_path, :class => 'brand' -------------------------------------------------------------------------------- /files-v2/app/views/layouts/application-bootstrap.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | <%= content_for?(:title) ? yield(:title) : "App_Name" %> 8 | 9 | 10 | <%= stylesheet_link_tag "application", :media => "all" %> 11 | <%= javascript_include_tag "application" %> 12 | <%= csrf_meta_tags %> 13 | <%= yield(:head) %> 14 | 15 | 16 | 23 |
24 |
25 |
26 |
27 |
28 | <%= render 'layouts/messages' %> 29 | <%= yield %> 30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | 38 | -------------------------------------------------------------------------------- /files-v2/app/views/layouts/application-bootstrap.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html 3 | %head 4 | %meta{:charset => "utf-8"} 5 | %meta{"http-equiv" => "X-UA-Compatible", :content => "IE=edge,chrome=1"} 6 | %meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"} 7 | %title= content_for?(:title) ? yield(:title) : "App_Name" 8 | %meta{:content => "", :name => "description"} 9 | %meta{:content => "", :name => "author"} 10 | = stylesheet_link_tag "application", :media => "all" 11 | = javascript_include_tag "application" 12 | = csrf_meta_tags 13 | = yield(:head) 14 | %body 15 | %header.navbar.navbar-fixed-top 16 | %nav.navbar-inner 17 | .container 18 | = render 'layouts/navigation' 19 | #main{:role => "main"} 20 | .container 21 | .content 22 | .row 23 | .span12 24 | = render 'layouts/messages' 25 | = yield 26 | %footer 27 | -------------------------------------------------------------------------------- /files-v2/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | App_Name 8 | 9 | 10 | <%= stylesheet_link_tag "application", :media => "all" %> 11 | <%= javascript_include_tag "application" %> 12 | <%= csrf_meta_tags %> 13 | 14 | 15 |
16 |
17 | <%= render 'layouts/navigation' %> 18 | <%= render 'layouts/messages' %> 19 |
20 |
21 | <%= yield %> 22 |
23 |
24 |
25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /files-v2/app/views/layouts/application.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html 3 | %head 4 | %title App_Name 5 | %meta{:charset => "utf-8"} 6 | %meta{"http-equiv" => "X-UA-Compatible", :content => "IE=edge,chrome=1"} 7 | %meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"} 8 | = stylesheet_link_tag :application, :media => "all" 9 | = javascript_include_tag :application 10 | = csrf_meta_tags 11 | %body 12 | #container.container 13 | %header 14 | = render 'layouts/navigation' 15 | = render 'layouts/messages' 16 | #main{:role => "main"} 17 | = yield 18 | %footer 19 | -------------------------------------------------------------------------------- /files-v2/app/views/profiles/show-subdomains_app.html.erb: -------------------------------------------------------------------------------- 1 |

Profile

2 |

<%= @user.name %>

3 |

<%= @user.email %>

-------------------------------------------------------------------------------- /files-v2/app/views/profiles/show-subdomains_app.html.haml: -------------------------------------------------------------------------------- 1 | %h1 Profile 2 | %h3= @user.name 3 | %h3= @user.email 4 | -------------------------------------------------------------------------------- /files-v2/app/views/users/edit-omniauth.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_for(@user) do |f| %> 2 | <%= f.label :email %> 3 | <%= f.text_field :email %> 4 |
5 | <%= f.submit "Sign in" %> 6 | <% end %> 7 | -------------------------------------------------------------------------------- /files-v2/app/views/users/edit-omniauth.html.haml: -------------------------------------------------------------------------------- 1 | = form_for(@user) do |f| 2 | = f.label :email 3 | = f.text_field :email 4 | %br/ 5 | = f.submit "Sign in" -------------------------------------------------------------------------------- /files-v2/app/views/users/index.html.erb: -------------------------------------------------------------------------------- 1 |

Users

2 | -------------------------------------------------------------------------------- /files-v2/app/views/users/index.html.haml: -------------------------------------------------------------------------------- 1 | %h3 Users 2 | %ul.users 3 | - @users.each do |user| 4 | %li 5 | = link_to user.name, user 6 | signed up #{user.created_at.to_date} -------------------------------------------------------------------------------- /files-v2/app/views/users/show-subdomains_app.html.erb: -------------------------------------------------------------------------------- 1 |

User: <%= @user.name %>

2 |

Email: <%= @user.email if @user.email %>

3 |

Profile: <%= #{link_to root_url(:subdomain => @user.name), root_url(:subdomain => @user.name)} %>

4 | -------------------------------------------------------------------------------- /files-v2/app/views/users/show-subdomains_app.html.haml: -------------------------------------------------------------------------------- 1 | %p 2 | User: #{@user.name} 3 | %p 4 | Email: #{@user.email if @user.email} 5 | %p 6 | Profile: #{link_to root_url(:subdomain => @user.name), root_url(:subdomain => @user.name)} 7 | -------------------------------------------------------------------------------- /files-v2/app/views/users/show.html.erb: -------------------------------------------------------------------------------- 1 |

User

2 |

User: <%= @user.name %>

3 |

Email: <%= @user.email if @user.email %>

-------------------------------------------------------------------------------- /files-v2/app/views/users/show.html.haml: -------------------------------------------------------------------------------- 1 | %h3 User 2 | %p 3 | User: #{@user.name} 4 | %p 5 | Email: #{@user.email if @user.email} -------------------------------------------------------------------------------- /files-v2/config/database-mysql.yml: -------------------------------------------------------------------------------- 1 | # MySQL. Versions 4.1 and 5.0 are recommended. 2 | # 3 | # Install the MYSQL driver 4 | # gem install mysql2 5 | # 6 | # Ensure the MySQL gem is defined in your Gemfile 7 | # gem 'mysql2' 8 | # 9 | # And be sure to use new-style password hashing: 10 | # http://dev.mysql.com/doc/refman/5.0/en/old-client.html 11 | development: 12 | adapter: mysql2 13 | encoding: utf8 14 | reconnect: false 15 | database: myapp_development 16 | pool: 5 17 | username: root 18 | password: 19 | host: localhost 20 | 21 | # Warning: The database defined as "test" will be erased and 22 | # re-generated from your development database when you run "rake". 23 | # Do not set this db to the same as development or production. 24 | test: 25 | adapter: mysql2 26 | encoding: utf8 27 | reconnect: false 28 | database: myapp_test 29 | pool: 5 30 | username: root 31 | password: 32 | host: localhost 33 | 34 | production: 35 | adapter: mysql2 36 | encoding: utf8 37 | reconnect: false 38 | database: myapp_production 39 | pool: 5 40 | username: root 41 | password: 42 | host: localhost 43 | -------------------------------------------------------------------------------- /files-v2/config/database-postgresql.yml: -------------------------------------------------------------------------------- 1 | # PostgreSQL. Versions 8.2 and up are supported. 2 | # 3 | # Install the pg driver: 4 | # gem install pg 5 | # On Mac OS X with macports: 6 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 7 | # On Windows: 8 | # gem install pg 9 | # Choose the win32 build. 10 | # Install PostgreSQL and put its /bin directory on your path. 11 | # 12 | # Configure Using Gemfile 13 | # gem 'pg' 14 | # 15 | development: 16 | adapter: postgresql 17 | encoding: unicode 18 | database: myapp_development 19 | pool: 5 20 | username: myapp 21 | password: 22 | 23 | # Connect on a TCP socket. Omitted by default since the client uses a 24 | # domain socket that doesn't need configuration. Windows does not have 25 | # domain sockets, so uncomment these lines. 26 | #host: localhost 27 | #port: 5432 28 | 29 | # Schema search path. The server defaults to $user,public 30 | #schema_search_path: myapp,sharedapp,public 31 | 32 | # Minimum log levels, in increasing order: 33 | # debug5, debug4, debug3, debug2, debug1, 34 | # log, notice, warning, error, fatal, and panic 35 | # The server defaults to notice. 36 | #min_messages: warning 37 | 38 | # Warning: The database defined as "test" will be erased and 39 | # re-generated from your development database when you run "rake". 40 | # Do not set this db to the same as development or production. 41 | test: 42 | adapter: postgresql 43 | encoding: unicode 44 | database: myapp_test 45 | pool: 5 46 | username: myapp 47 | password: 48 | 49 | production: 50 | adapter: postgresql 51 | encoding: unicode 52 | database: myapp_production 53 | pool: 5 54 | username: myapp 55 | password: 56 | -------------------------------------------------------------------------------- /files-v2/public/humans.txt: -------------------------------------------------------------------------------- 1 | /* the humans responsible & colophon */ 2 | /* humanstxt.org */ 3 | 4 | 5 | /* TEAM */ 6 | : 7 | Site: 8 | Twitter: 9 | Location: 10 | 11 | /* THANKS */ 12 | Daniel Kehoe (@rails_apps) for the RailsApps project 13 | 14 | /* SITE */ 15 | Standards: HTML5, CSS3 16 | Components: jQuery 17 | Software: Ruby on Rails 18 | 19 | /* GENERATED BY */ 20 | RailsApps application template: http://railsapps.github.com/ -------------------------------------------------------------------------------- /files/devise-views-haml/app/views/devise/_links.erb: -------------------------------------------------------------------------------- 1 | <%- if controller_name != 'sessions' %> 2 | <%= link_to "Sign in", new_session_path(resource_name) %>
3 | <% end -%> 4 | 5 | <%- if devise_mapping.registerable? && controller_name != 'registrations' %> 6 | <%= link_to "Sign up", new_registration_path(resource_name) %>
7 | <% end -%> 8 | 9 | <%- if devise_mapping.recoverable? && controller_name != 'passwords' %> 10 | <%= link_to "Forgot your password?", new_password_path(resource_name) %>
11 | <% end -%> 12 | 13 | <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> 14 | <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
15 | <% end -%> 16 | 17 | <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> 18 | <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
19 | <% end -%> 20 | 21 | <%- if devise_mapping.omniauthable? %> 22 | <%- resource_class.omniauth_providers.each do |provider| %> 23 | <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
24 | <% end -%> 25 | <% end -%> 26 | -------------------------------------------------------------------------------- /files/devise-views-haml/app/views/devise/registrations/edit.html.haml: -------------------------------------------------------------------------------- 1 | %h2 2 | Edit #{resource_name.to_s.humanize} 3 | = form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| 4 | = devise_error_messages! 5 | %p 6 | = f.label :name 7 | %br/ 8 | = f.text_field :name 9 | %div 10 | = f.label :email 11 | %br/ 12 | = f.email_field :email 13 | %div 14 | = f.label :password 15 | %i (leave blank if you don't want to change it) 16 | %br/ 17 | = f.password_field :password, :autocomplete => "off" 18 | %div 19 | = f.label :password_confirmation 20 | %br/ 21 | = f.password_field :password_confirmation 22 | %div 23 | = f.label :current_password 24 | %i (we need your current password to confirm your changes) 25 | %br/ 26 | = f.password_field :current_password 27 | %div= f.submit "Update" 28 | %h3 Cancel my account 29 | %p 30 | Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete}. 31 | = link_to "Back", :back -------------------------------------------------------------------------------- /files/devise-views-haml/app/views/devise/registrations/new.html.haml: -------------------------------------------------------------------------------- 1 | %h2 Sign up 2 | = form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| 3 | = devise_error_messages! 4 | %p 5 | = f.label :name 6 | %br/ 7 | = f.text_field :name 8 | %div 9 | = f.label :email 10 | %br/ 11 | = f.email_field :email 12 | %div 13 | = f.label :password 14 | %br/ 15 | = f.password_field :password 16 | %div 17 | = f.label :password_confirmation 18 | %br/ 19 | = f.password_field :password_confirmation 20 | %div= f.submit "Sign up" 21 | = render :partial => "devise/shared/links" -------------------------------------------------------------------------------- /files/devise-views-haml/app/views/devise/shared/_links.html.haml: -------------------------------------------------------------------------------- 1 | - if controller_name != 'sessions' 2 | = link_to "Sign in", new_session_path(resource_name) 3 | %br/ 4 | - if devise_mapping.registerable? && controller_name != 'registrations' 5 | = link_to "Sign up", new_registration_path(resource_name) 6 | %br/ 7 | - if devise_mapping.recoverable? && controller_name != 'passwords' 8 | = link_to "Forgot your password?", new_password_path(resource_name) 9 | %br/ 10 | - if devise_mapping.confirmable? && controller_name != 'confirmations' 11 | = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) 12 | %br/ 13 | - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' 14 | = link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) 15 | %br/ 16 | - if devise_mapping.omniauthable? 17 | - resource_class.omniauth_providers.each do |provider| 18 | = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) 19 | %br/ -------------------------------------------------------------------------------- /files/gitignore.txt: -------------------------------------------------------------------------------- 1 | #---------------------------------------------------------------------------- 2 | # Ignore these files when commiting to a git repository. 3 | # 4 | # See http://help.github.com/ignore-files/ for more about ignoring files. 5 | # 6 | # The original version of this file is found here: 7 | # https://github.com/RailsApps/rails3-application-templates/raw/master/files/gitignore.txt 8 | # 9 | # Corrections? Improvements? Create a GitHub issue: 10 | # http://github.com/RailsApps/rails3-application-templates/issues 11 | #---------------------------------------------------------------------------- 12 | 13 | # bundler state 14 | /.bundle 15 | /vendor/bundle/ 16 | 17 | # minimal Rails specific artifacts 18 | db/*.sqlite3 19 | /log/* 20 | /tmp/* 21 | 22 | # various artifacts 23 | **.war 24 | *.rbc 25 | *.sassc 26 | .rspec 27 | .redcar/ 28 | .sass-cache 29 | /config/config.yml 30 | /config/database.yml 31 | /coverage.data 32 | /coverage/ 33 | /db/*.javadb/ 34 | /db/*.sqlite3 35 | /doc/api/ 36 | /doc/app/ 37 | /doc/features.html 38 | /doc/specs.html 39 | /public/cache 40 | /public/stylesheets/compiled 41 | /public/system/* 42 | /spec/tmp/* 43 | /cache 44 | /capybara* 45 | /capybara-*.html 46 | /gems 47 | /spec/requests 48 | /spec/routing 49 | /spec/views 50 | /specifications 51 | rerun.txt 52 | pickle-email-*.html 53 | 54 | # If you find yourself ignoring temporary files generated by your text editor 55 | # or operating system, you probably want to add a global ignore instead: 56 | # git config --global core.excludesfile ~/.gitignore_global 57 | # 58 | # Here are some files you may want to ignore globally: 59 | 60 | # scm revert files 61 | **.orig 62 | 63 | # Mac finder artifacts 64 | .DS_Store 65 | 66 | # Netbeans project directory 67 | /nbproject/ 68 | 69 | # RubyMine project files 70 | .idea 71 | 72 | # Textmate project files 73 | /*.tmproj 74 | 75 | # vim artifacts 76 | **.swp 77 | -------------------------------------------------------------------------------- /files/humans.txt: -------------------------------------------------------------------------------- 1 | /* the humans responsible & colophon */ 2 | /* humanstxt.org */ 3 | 4 | 5 | /* TEAM */ 6 | : 7 | Site: 8 | Twitter: 9 | Location: 10 | 11 | /* THANKS */ 12 | Daniel Kehoe (@rails_apps) for the RailsApps project 13 | 14 | /* SITE */ 15 | Standards: HTML5, CSS3 16 | Components: jQuery 17 | Software: Ruby on Rails 18 | 19 | /* GENERATED BY */ 20 | RailsApps application template: http://railsapps.github.com/ -------------------------------------------------------------------------------- /files/navigation/devise/_navigation.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "App_Name", root_path, :class => 'brand' %> 2 | -------------------------------------------------------------------------------- /files/navigation/devise/_navigation.html.haml: -------------------------------------------------------------------------------- 1 | = link_to "App_Name", root_path, :class => 'brand' 2 | %ul.nav 3 | - if user_signed_in? 4 | %li 5 | = link_to('Logout', destroy_user_session_path, :method=>'delete') 6 | - else 7 | %li 8 | = link_to('Login', new_user_session_path) 9 | - if user_signed_in? 10 | %li 11 | = link_to('Edit account', edit_user_registration_path) 12 | - else 13 | %li 14 | = link_to('Sign up', new_user_registration_path) -------------------------------------------------------------------------------- /files/navigation/devise/authorization/_navigation.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "App_Name", root_path, :class => 'brand' %> 2 | -------------------------------------------------------------------------------- /files/navigation/devise/authorization/_navigation.html.haml: -------------------------------------------------------------------------------- 1 | = link_to "App_Name", root_path, :class => 'brand' 2 | %ul.nav 3 | - if user_signed_in? 4 | %li 5 | = link_to('Logout', destroy_user_session_path, :method=>'delete') 6 | - else 7 | %li 8 | = link_to('Login', new_user_session_path) 9 | - if user_signed_in? 10 | %li 11 | = link_to('Edit account', edit_user_registration_path) 12 | - if current_user.has_role? :admin 13 | %li 14 | = link_to('Admin', users_path) 15 | - else 16 | %li 17 | = link_to('Sign up', new_user_registration_path) -------------------------------------------------------------------------------- /files/navigation/none/_navigation.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "App_Name", root_path, :class => 'brand' %> -------------------------------------------------------------------------------- /files/navigation/none/_navigation.html.haml: -------------------------------------------------------------------------------- 1 | = link_to "App_Name", root_path, :class => 'brand' -------------------------------------------------------------------------------- /files/navigation/omniauth/_navigation.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "App_Name", root_path, :class => 'brand' %> 2 | -------------------------------------------------------------------------------- /files/navigation/omniauth/_navigation.html.haml: -------------------------------------------------------------------------------- 1 | = link_to "App_Name", root_path, :class => 'brand' 2 | %ul.nav 3 | - if user_signed_in? 4 | %li 5 | Logged in as #{current_user.name} 6 | %li 7 | = link_to('Logout', signout_path) 8 | - else 9 | %li 10 | = link_to('Login', signin_path) -------------------------------------------------------------------------------- /files/navigation/subdomains/_navigation.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "App_Name", root_path, :class => 'brand' %> 2 | -------------------------------------------------------------------------------- /files/navigation/subdomains/_navigation.html.haml: -------------------------------------------------------------------------------- 1 | = link_to "App_Name", root_path, :class => 'brand' 2 | %ul.nav 3 | %li 4 | = link_to 'Main', root_url(:host => request.domain) 5 | - if request.subdomain.present? && request.subdomain != "www" 6 | - if user_signed_in? 7 | %li 8 | = link_to('Edit account', edit_user_registration_url) 9 | %li 10 | = link_to('Logout', destroy_user_session_url, :method=>'delete') 11 | - else 12 | %li 13 | = link_to('Login', new_user_session_url) 14 | - else 15 | %li 16 | = link_to('Sign up', new_user_registration_url(:host => request.domain)) 17 | - if user_signed_in? 18 | %li 19 | = link_to('Logout', destroy_user_session_url, :method=>'delete') -------------------------------------------------------------------------------- /files/sample_readme.textile: -------------------------------------------------------------------------------- 1 | h1. App_Name 2 | 3 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 4 | 5 | h2. More Information 6 | 7 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 8 | 9 | h2. Required Gems 10 | 11 | This application requires this gem: 12 | 13 | * "rails":http://rubygems.org/gems/rails 14 | 15 | h2. Dependencies 16 | 17 | To use this application, you will need: 18 | 19 | * The Ruby language (version 1.8.7 or 1.9.2) 20 | * Rails (version 3.0.4 or newer) 21 | 22 | h2. Installing the Application 23 | 24 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 25 | 26 | h2. Getting Started 27 | 28 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 29 | 30 | h2. Documentation and Support 31 | 32 | This is the only documentation. 33 | 34 | h4. Issues 35 | 36 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 37 | 38 | h2. Similar Projects 39 | 40 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 41 | 42 | h2. Contributing 43 | 44 | If you make improvements to this application, please share with others. 45 | 46 | * Fork the project on GitHub. 47 | * Make your feature addition or bug fix. 48 | * Commit with Git. 49 | * Send the author a pull request. 50 | 51 | If you add functionality to this application, create an alternative implementation, or build an application that is similar, please contact me and I'll add a note to the README so that others can find your work. 52 | 53 | h2. Credits 54 | 55 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 56 | 57 | h2. License 58 | 59 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. -------------------------------------------------------------------------------- /files/sample_readme.txt: -------------------------------------------------------------------------------- 1 | App_Name 2 | ======================== 3 | 4 | 5 | ________________________ 6 | 7 | License 8 | -------------------------------------------------------------------------------- /files/simple/assets/stylesheets/application.css.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the top of the 9 | * compiled file, but it's generally better to create a new file per style scope. 10 | * 11 | *= require_self 12 | *= require_tree . 13 | */ 14 | .brand { 15 | float: left; 16 | padding-right: 8px; 17 | } 18 | ul.nav { 19 | list-style: none; 20 | margin: 0 0 2em; 21 | padding: 0; 22 | } 23 | ul.nav li { 24 | display: inline; 25 | } 26 | #flash_notice, #flash_alert { 27 | padding: 5px 8px; 28 | margin: 10px 0; 29 | } 30 | #flash_notice { 31 | background-color: #CFC; 32 | border: solid 1px #6C6; 33 | } 34 | #flash_alert { 35 | background-color: #FCC; 36 | border: solid 1px #C66; 37 | } 38 | -------------------------------------------------------------------------------- /files/simple/views/layouts/_messages.html.erb: -------------------------------------------------------------------------------- 1 | <% flash.each do |name, msg| %> 2 | <%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %> 3 | <% end %> -------------------------------------------------------------------------------- /files/simple/views/layouts/_messages.html.haml: -------------------------------------------------------------------------------- 1 | - flash.each do |name, msg| 2 | = content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) -------------------------------------------------------------------------------- /files/simple/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | App_Name 8 | 9 | 10 | <%= stylesheet_link_tag "application", :media => "all" %> 11 | <%= javascript_include_tag "application" %> 12 | <%= csrf_meta_tags %> 13 | 14 | 15 |
16 |
17 | <%= render 'layouts/navigation' %> 18 | <%= render 'layouts/messages' %> 19 |
20 |
21 | <%= yield %> 22 |
23 |
24 |
25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /files/simple/views/layouts/application.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html 3 | %head 4 | %title App_Name 5 | %meta{:charset => "utf-8"} 6 | %meta{"http-equiv" => "X-UA-Compatible", :content => "IE=edge,chrome=1"} 7 | %meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"} 8 | = stylesheet_link_tag :application, :media => "all" 9 | = javascript_include_tag :application 10 | = csrf_meta_tags 11 | %body 12 | #container.container 13 | %header 14 | = render 'layouts/navigation' 15 | = render 'layouts/messages' 16 | #main{:role => "main"} 17 | = yield 18 | %footer 19 | -------------------------------------------------------------------------------- /files/twitter-bootstrap/assets/stylesheets/application.css.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the top of the 9 | * compiled file, but it's generally better to create a new file per style scope. 10 | * 11 | *= require_self 12 | *= require_tree . 13 | */ 14 | 15 | .content { 16 | background-color: #eee; 17 | padding: 20px; 18 | margin: 0 -20px; /* negative indent the amount of the padding to maintain the grid system */ 19 | -webkit-border-radius: 0 0 6px 6px; 20 | -moz-border-radius: 0 0 6px 6px; 21 | border-radius: 0 0 6px 6px; 22 | -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15); 23 | -moz-box-shadow: 0 1px 2px rgba(0,0,0,.15); 24 | box-shadow: 0 1px 2px rgba(0,0,0,.15); 25 | } 26 | -------------------------------------------------------------------------------- /files/twitter-bootstrap/views/layouts/_messages.html.erb: -------------------------------------------------------------------------------- 1 | <% flash.each do |name, msg| %> 2 |
"> 3 | × 4 | <%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %> 5 |
6 | <% end %> -------------------------------------------------------------------------------- /files/twitter-bootstrap/views/layouts/_messages.html.haml: -------------------------------------------------------------------------------- 1 | - flash.each do |name, msg| 2 | %div{:class => "alert alert-#{name == :notice ? "success" : "error"}"} 3 | %a.close{"data-dismiss" => "alert"} × 4 | = content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) -------------------------------------------------------------------------------- /files/twitter-bootstrap/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | <%= content_for?(:title) ? yield(:title) : "App_Name" %> 8 | 9 | 10 | <%= stylesheet_link_tag "application", :media => "all" %> 11 | <%= javascript_include_tag "application" %> 12 | <%= csrf_meta_tags %> 13 | <%= yield(:head) %> 14 | 15 | 16 | 23 |
24 |
25 |
26 |
27 |
28 | <%= render 'layouts/messages' %> 29 | <%= yield %> 30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | 38 | -------------------------------------------------------------------------------- /files/twitter-bootstrap/views/layouts/application.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html 3 | %head 4 | %meta{:charset => "utf-8"} 5 | %meta{"http-equiv" => "X-UA-Compatible", :content => "IE=edge,chrome=1"} 6 | %meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"} 7 | %title= content_for?(:title) ? yield(:title) : "App_Name" 8 | %meta{:content => "", :name => "description"} 9 | %meta{:content => "", :name => "author"} 10 | = stylesheet_link_tag "application", :media => "all" 11 | = javascript_include_tag "application" 12 | = csrf_meta_tags 13 | = yield(:head) 14 | %body 15 | %header.navbar.navbar-fixed-top 16 | %nav.navbar-inner 17 | .container 18 | = render 'layouts/navigation' 19 | #main{:role => "main"} 20 | .container 21 | .content 22 | .row 23 | .span12 24 | = render 'layouts/messages' 25 | = yield 26 | %footer 27 | -------------------------------------------------------------------------------- /files/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | App_Name 8 | 9 | 10 | <%= stylesheet_link_tag "application", :media => "all" %> 11 | <%= javascript_include_tag "application" %> 12 | <%= csrf_meta_tags %> 13 | 14 | 15 |
16 |
17 | <%- flash.each do |name, msg| -%> 18 | <%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %> 19 | <%- end -%> 20 |
21 |
22 | <%= yield %> 23 |
24 |
25 |
26 |
27 | 28 | -------------------------------------------------------------------------------- /files/views/layouts/application.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html 3 | %head 4 | %title App_Name 5 | %meta{:charset => "utf-8"} 6 | %meta{"http-equiv" => "X-UA-Compatible", :content => "IE=edge,chrome=1"} 7 | %meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"} 8 | = stylesheet_link_tag :application, :media => "all" 9 | = javascript_include_tag :application 10 | = csrf_meta_tags 11 | %body 12 | #container.container 13 | %header 14 | - flash.each do |name, msg| 15 | = content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) 16 | #main{:role => "main"} 17 | = yield 18 | %footer -------------------------------------------------------------------------------- /rails3-haml-html5-template.rb: -------------------------------------------------------------------------------- 1 | # Application Generator Template 2 | # Modifies a Rails app to set up Haml with an HTML5 application layout and options for CSS with Twitter Bootstrap 3 | # Usage: rails new APP_NAME -m https://github.com/RailsApps/rails3-application-templates/raw/master/rails3-haml-html5-template.rb 4 | 5 | # Generated using the rails_apps_composer gem: 6 | # https://github.com/RailsApps/rails_apps_composer/ 7 | 8 | # Based on application template recipes by: 9 | # Michael Bleigh https://github.com/mbleigh 10 | # Daniel Kehoe https://github.com/DanielKehoe 11 | 12 | # If you are customizing this template, you can use any methods provided by Thor::Actions 13 | # http://rdoc.info/rdoc/wycats/thor/blob/f939a3e8a854616784cac1dcff04ef4f3ee5f7ff/Thor/Actions.html 14 | # and Rails::Generators::Actions 15 | # http://github.com/rails/rails/blob/master/railties/lib/rails/generators/actions.rb 16 | 17 | # >---------------------------------------------------------------------------< 18 | # 19 | # _____ _ _ __ ___ _ 20 | # | __ \ (_) | \ \ / (_) | | 21 | # | |__) |__ _ _| |___\ \ /\ / / _ ______ _ _ __ __| | 22 | # | _ // _` | | / __|\ \/ \/ / | |_ / _` | '__/ _` | 23 | # | | \ \ (_| | | \__ \ \ /\ / | |/ / (_| | | | (_| | 24 | # |_| \_\__,_|_|_|___/ \/ \/ |_/___\__,_|_| \__,_| 25 | # 26 | # This template was generated by rails_apps_composer, a custom version of 27 | # RailsWizard, the application template builder. For more information, see: 28 | # https://github.com/RailsApps/rails_apps_composer/ 29 | # 30 | # >---------------------------------------------------------------------------< 31 | 32 | # >----------------------------[ Initial Setup ]------------------------------< 33 | 34 | initializer 'generators.rb', <<-RUBY 35 | Rails.application.config.generators do |g| 36 | end 37 | RUBY 38 | 39 | @recipes = ["haml", "home_page", "html5", "cleanup", "extras", "git"] 40 | 41 | def recipes; @recipes end 42 | def recipe?(name); @recipes.include?(name) end 43 | 44 | def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m" + " #{text}" end 45 | def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end 46 | def say_wizard(text); say_custom(@current_recipe || 'wizard', text) end 47 | 48 | def ask_wizard(question) 49 | ask "\033[1m\033[30m\033[46m" + (@current_recipe || "prompt").rjust(10) + "\033[0m\033[36m" + " #{question}\033[0m" 50 | end 51 | 52 | def yes_wizard?(question) 53 | answer = ask_wizard(question + " \033[33m(y/n)\033[0m") 54 | case answer.downcase 55 | when "yes", "y" 56 | true 57 | when "no", "n" 58 | false 59 | else 60 | yes_wizard?(question) 61 | end 62 | end 63 | 64 | def no_wizard?(question); !yes_wizard?(question) end 65 | 66 | def multiple_choice(question, choices) 67 | say_custom('question', question) 68 | values = {} 69 | choices.each_with_index do |choice,i| 70 | values[(i + 1).to_s] = choice[1] 71 | say_custom (i + 1).to_s + ')', choice[0] 72 | end 73 | answer = ask_wizard("Enter your selection:") while !values.keys.include?(answer) 74 | values[answer] 75 | end 76 | 77 | @current_recipe = nil 78 | @configs = {} 79 | 80 | @after_blocks = [] 81 | def after_bundler(&block); @after_blocks << [@current_recipe, block]; end 82 | @after_everything_blocks = [] 83 | def after_everything(&block); @after_everything_blocks << [@current_recipe, block]; end 84 | @before_configs = {} 85 | def before_config(&block); @before_configs[@current_recipe] = block; end 86 | 87 | 88 | # this application template only supports Rails version 3.1 and newer 89 | case Rails::VERSION::MAJOR.to_s 90 | when "3" 91 | case Rails::VERSION::MINOR.to_s 92 | when "2" 93 | say_wizard "You are using Rails version #{Rails::VERSION::STRING}." 94 | when "1" 95 | say_wizard "You are using Rails version #{Rails::VERSION::STRING}." 96 | when "0" 97 | say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer." 98 | raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer." 99 | else 100 | say_wizard "You are using Rails version #{Rails::VERSION::STRING}." 101 | end 102 | else 103 | say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer." 104 | raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer." 105 | end 106 | 107 | say_wizard "Checking configuration. Please confirm your preferences." 108 | 109 | # >---------------------------[ Autoload Modules/Classes ]-----------------------------< 110 | 111 | inject_into_file 'config/application.rb', :after => 'config.autoload_paths += %W(#{config.root}/extras)' do <<-'RUBY' 112 | 113 | config.autoload_paths += %W(#{config.root}/lib) 114 | RUBY 115 | end 116 | 117 | # >---------------------------------[ Recipes ]----------------------------------< 118 | 119 | 120 | # >---------------------------------[ HAML ]----------------------------------< 121 | 122 | @current_recipe = "haml" 123 | @before_configs["haml"].call if @before_configs["haml"] 124 | say_recipe 'HAML' 125 | 126 | config = {} 127 | config['haml'] = yes_wizard?("Would you like to use Haml instead of ERB?") if true && true unless config.key?('haml') 128 | @configs[@current_recipe] = config 129 | 130 | # Application template recipe for the rails_apps_composer. Check for a newer version here: 131 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/haml.rb 132 | 133 | if config['haml'] 134 | gem 'haml', '>= 3.1.6' 135 | gem 'haml-rails', '>= 0.3.4', :group => :development 136 | else 137 | recipes.delete('haml') 138 | end 139 | 140 | 141 | # >-------------------------------[ HomePage ]--------------------------------< 142 | 143 | @current_recipe = "home_page" 144 | @before_configs["home_page"].call if @before_configs["home_page"] 145 | say_recipe 'HomePage' 146 | 147 | 148 | @configs[@current_recipe] = config 149 | 150 | # Application template recipe for the rails_apps_composer. Check for a newer version here: 151 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/home_page.rb 152 | 153 | after_bundler do 154 | 155 | say_wizard "HomePage recipe running 'after bundler'" 156 | 157 | # remove the default home page 158 | remove_file 'public/index.html' 159 | 160 | # create a home controller and view 161 | generate(:controller, "home index") 162 | 163 | # set up a simple home page (with placeholder content) 164 | if recipes.include? 'haml' 165 | remove_file 'app/views/home/index.html.haml' 166 | # There is Haml code in this script. Changing the indentation is perilous between HAMLs. 167 | # We have to use single-quote-style-heredoc to avoid interpolation. 168 | create_file 'app/views/home/index.html.haml' do 169 | <<-'HAML' 170 | %h3 Home 171 | HAML 172 | end 173 | elsif recipes.include? 'slim' 174 | # skip 175 | else 176 | remove_file 'app/views/home/index.html.erb' 177 | create_file 'app/views/home/index.html.erb' do 178 | <<-ERB 179 |

Home

180 | ERB 181 | end 182 | end 183 | 184 | # set routes 185 | gsub_file 'config/routes.rb', /get \"home\/index\"/, 'root :to => "home#index"' 186 | 187 | if recipes.include? 'devise' 188 | inject_into_file 'config/routes.rb', :before => " root :to" do 189 | <<-RUBY 190 | authenticated :user do 191 | root :to => 'home#index' 192 | end 193 | \n 194 | RUBY 195 | end 196 | end 197 | 198 | end 199 | 200 | 201 | # >---------------------------------[ html5 ]---------------------------------< 202 | 203 | @current_recipe = "html5" 204 | @before_configs["html5"].call if @before_configs["html5"] 205 | say_recipe 'html5' 206 | 207 | config = {} 208 | config['css_option'] = multiple_choice("Which front-end framework would you like for HTML5 and CSS?", [["None", "nothing"], ["Zurb Foundation", "foundation"], ["Twitter Bootstrap (less)", "bootstrap_less"], ["Twitter Bootstrap (sass)", "bootstrap_sass"], ["Skeleton", "skeleton"], ["Just normalize CSS for consistent styling", "normalize"]]) if true && true unless config.key?('css_option') 209 | @configs[@current_recipe] = config 210 | 211 | # Application template recipe for the rails_apps_composer. Check for a newer version here: 212 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/html5.rb 213 | 214 | case config['css_option'] 215 | 216 | when 'foundation' 217 | # https://github.com/zurb/foundation-rails 218 | gem 'zurb-foundation', '>= 3.0.5' 219 | 220 | when 'bootstrap_less' 221 | # https://github.com/seyhunak/twitter-bootstrap-rails 222 | # http://railscasts.com/episodes/328-twitter-bootstrap-basics 223 | gem 'twitter-bootstrap-rails', '>= 2.0.3', :group => :assets 224 | # please install gem 'therubyracer' to use Less 225 | gem 'therubyracer', :group => :assets, :platform => :ruby 226 | recipes << 'bootstrap' 227 | recipes << 'jsruntime' 228 | 229 | when 'bootstrap_sass' 230 | # https://github.com/thomas-mcdonald/bootstrap-sass 231 | # http://rubysource.com/twitter-bootstrap-less-and-sass-understanding-your-options-for-rails-3-1/ 232 | gem 'bootstrap-sass', '>= 2.0.4.0' 233 | recipes << 'bootstrap' 234 | 235 | end 236 | after_bundler do 237 | say_wizard "HTML5 recipe running 'after bundler'" 238 | # add a humans.txt file 239 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/humans.txt', 'public/humans.txt' 240 | # install a front-end framework for HTML5 and CSS3 241 | remove_file 'app/assets/stylesheets/application.css' 242 | remove_file 'app/views/layouts/application.html.erb' 243 | remove_file 'app/views/layouts/application.html.haml' 244 | unless recipes.include? 'bootstrap' 245 | if recipes.include? 'haml' 246 | # Haml version of a simple application layout 247 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/views/layouts/application.html.haml', 'app/views/layouts/application.html.haml' 248 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/views/layouts/_messages.html.haml', 'app/views/layouts/_messages.html.haml' 249 | else 250 | # ERB version of a simple application layout 251 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/views/layouts/application.html.erb', 'app/views/layouts/application.html.erb' 252 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/views/layouts/_messages.html.erb', 'app/views/layouts/_messages.html.erb' 253 | end 254 | # simple css styles 255 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/assets/stylesheets/application.css.scss', 'app/assets/stylesheets/application.css.scss' 256 | else # for Twitter Bootstrap 257 | if recipes.include? 'haml' 258 | # Haml version of a complex application layout using Twitter Bootstrap 259 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/application.html.haml', 'app/views/layouts/application.html.haml' 260 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/_messages.html.haml', 'app/views/layouts/_messages.html.haml' 261 | else 262 | # ERB version of a complex application layout using Twitter Bootstrap 263 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/application.html.erb', 'app/views/layouts/application.html.erb' 264 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/_messages.html.erb', 'app/views/layouts/_messages.html.erb' 265 | end 266 | # complex css styles using Twitter Bootstrap 267 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/assets/stylesheets/application.css.scss', 'app/assets/stylesheets/application.css.scss' 268 | end 269 | # get an appropriate navigation partial 270 | if recipes.include? 'haml' 271 | if recipes.include? 'devise' 272 | if recipes.include? 'authorization' 273 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/authorization/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml' 274 | else 275 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml' 276 | end 277 | elsif recipes.include? 'omniauth' 278 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/omniauth/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml' 279 | elsif recipes.include? 'subdomains' 280 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/subdomains/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml' 281 | else 282 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/none/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml' 283 | end 284 | else 285 | if recipes.include? 'devise' 286 | if recipes.include? 'authorization' 287 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/authorization/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb' 288 | else 289 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb' 290 | end 291 | elsif recipes.include? 'omniauth' 292 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/omniauth/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb' 293 | elsif recipes.include? 'subdomains' 294 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/subdomains/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb' 295 | else 296 | get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/none/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb' 297 | end 298 | end 299 | if recipes.include? 'haml' 300 | gsub_file 'app/views/layouts/application.html.haml', /App_Name/, "#{app_name.humanize.titleize}" 301 | gsub_file 'app/views/layouts/_navigation.html.haml', /App_Name/, "#{app_name.humanize.titleize}" 302 | else 303 | gsub_file 'app/views/layouts/application.html.erb', /App_Name/, "#{app_name.humanize.titleize}" 304 | gsub_file 'app/views/layouts/_navigation.html.erb', /App_Name/, "#{app_name.humanize.titleize}" 305 | end 306 | case config['css_option'] 307 | 308 | when 'bootstrap_less' 309 | say_wizard 'installing Twitter Bootstrap HTML5 framework (less)' 310 | generate 'bootstrap:install' 311 | remove_file 'app/assets/stylesheets/application.css' # already created application.css.scss above 312 | insert_into_file 'app/assets/stylesheets/bootstrap_and_overrides.css.less', "body { padding-top: 60px; }\n", :after => "@import \"twitter/bootstrap/bootstrap\";\n" 313 | 314 | when 'bootstrap_sass' 315 | say_wizard 'installing Twitter Bootstrap HTML5 framework (sass)' 316 | insert_into_file 'app/assets/javascripts/application.js', "//= require bootstrap\n", :after => "jquery_ujs\n" 317 | create_file 'app/assets/stylesheets/bootstrap_and_overrides.css.scss', <<-RUBY 318 | // Set the correct sprite paths 319 | $iconSpritePath: asset-url('glyphicons-halflings.png', image); 320 | $iconWhiteSpritePath: asset-url('glyphicons-halflings-white.png', image); 321 | @import "bootstrap"; 322 | body { padding-top: 60px; } 323 | @import "bootstrap-responsive"; 324 | RUBY 325 | 326 | when 'foundation' 327 | say_wizard 'installing Zurb Foundation HTML5 framework' 328 | insert_into_file 'app/assets/javascripts/application.js', "//= require foundation\n", :after => "jquery_ujs\n" 329 | insert_into_file 'app/assets/stylesheets/application.css.scss', " *= require foundation\n", :after => "require_self\n" 330 | 331 | when 'skeleton' 332 | say_wizard 'installing Skeleton HTML5 framework' 333 | get 'https://raw.github.com/necolas/normalize.css/master/normalize.css', 'app/assets/stylesheets/normalize.css.scss' 334 | get 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/base.css', 'app/assets/stylesheets/base.css.scss' 335 | get 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/layout.css', 'app/assets/stylesheets/layout.css.scss' 336 | get 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/skeleton.css', 'app/assets/stylesheets/skeleton.css.scss' 337 | 338 | when 'normalize' 339 | say_wizard 'normalizing CSS for consistent styling' 340 | get 'https://raw.github.com/necolas/normalize.css/master/normalize.css', 'app/assets/stylesheets/normalize.css.scss' 341 | 342 | when 'nothing' 343 | say_wizard 'no HTML5 front-end framework selected' 344 | 345 | end 346 | 347 | end 348 | 349 | 350 | # >--------------------------------[ Cleanup ]--------------------------------< 351 | 352 | @current_recipe = "cleanup" 353 | @before_configs["cleanup"].call if @before_configs["cleanup"] 354 | say_recipe 'Cleanup' 355 | 356 | 357 | @configs[@current_recipe] = config 358 | 359 | # Application template recipe for the rails_apps_composer. Check for a newer version here: 360 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/cleanup.rb 361 | 362 | after_bundler do 363 | 364 | say_wizard "Cleanup recipe running 'after bundler'" 365 | 366 | # remove unnecessary files 367 | %w{ 368 | README 369 | doc/README_FOR_APP 370 | public/index.html 371 | app/assets/images/rails.png 372 | }.each { |file| remove_file file } 373 | 374 | # add placeholder READMEs 375 | get "https://raw.github.com/RailsApps/rails3-application-templates/master/files/sample_readme.txt", "README" 376 | get "https://raw.github.com/RailsApps/rails3-application-templates/master/files/sample_readme.textile", "README.textile" 377 | gsub_file "README", /App_Name/, "#{app_name.humanize.titleize}" 378 | gsub_file "README.textile", /App_Name/, "#{app_name.humanize.titleize}" 379 | 380 | # remove commented lines and multiple blank lines from Gemfile 381 | # thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb 382 | gsub_file 'Gemfile', /#.*\n/, "\n" 383 | gsub_file 'Gemfile', /\n^\s*\n/, "\n" 384 | 385 | # remove commented lines and multiple blank lines from config/routes.rb 386 | gsub_file 'config/routes.rb', / #.*\n/, "\n" 387 | gsub_file 'config/routes.rb', /\n^\s*\n/, "\n" 388 | 389 | end 390 | 391 | 392 | # >--------------------------------[ Extras ]---------------------------------< 393 | 394 | @current_recipe = "extras" 395 | @before_configs["extras"].call if @before_configs["extras"] 396 | say_recipe 'Extras' 397 | 398 | config = {} 399 | config['footnotes'] = yes_wizard?("Would you like to use 'rails-footnotes' (it's SLOW!)?") if true && true unless config.key?('footnotes') 400 | config['ban_spiders'] = yes_wizard?("Would you like to set a robots.txt file to ban spiders?") if true && true unless config.key?('ban_spiders') 401 | config['paginate'] = yes_wizard?("Would you like to add 'will_paginate' for pagination?") if true && true unless config.key?('paginate') 402 | config['jsruntime'] = yes_wizard?("Add 'therubyracer' JavaScript runtime (for Linux users without node.js)?") if true && true unless config.key?('jsruntime') 403 | @configs[@current_recipe] = config 404 | 405 | # Application template recipe for the rails_apps_composer. Check for a newer version here: 406 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/extras.rb 407 | 408 | if config['footnotes'] 409 | say_wizard "Adding 'rails-footnotes'" 410 | gem 'rails-footnotes', '>= 3.7', :group => :development 411 | after_bundler do 412 | generate 'rails_footnotes:install' 413 | end 414 | end 415 | 416 | if config['ban_spiders'] 417 | say_wizard "Banning spiders by modifying 'public/robots.txt'" 418 | after_bundler do 419 | # ban spiders from your site by changing robots.txt 420 | gsub_file 'public/robots.txt', /# User-Agent/, 'User-Agent' 421 | gsub_file 'public/robots.txt', /# Disallow/, 'Disallow' 422 | end 423 | end 424 | 425 | if config['paginate'] 426 | say_wizard "Adding 'will_paginate'" 427 | if recipes.include? 'mongoid' 428 | gem 'will_paginate_mongoid' 429 | else 430 | gem 'will_paginate', '>= 3.0.3' 431 | end 432 | recipes << 'paginate' 433 | end 434 | 435 | if config['jsruntime'] 436 | say_wizard "Adding 'therubyracer' JavaScript runtime gem" 437 | # maybe it was already added by the html5 recipe for bootstrap_less? 438 | unless recipes.include? 'jsruntime' 439 | gem 'therubyracer', :group => :assets, :platform => :ruby 440 | end 441 | end 442 | 443 | 444 | # >----------------------------------[ Git ]----------------------------------< 445 | 446 | @current_recipe = "git" 447 | @before_configs["git"].call if @before_configs["git"] 448 | say_recipe 'Git' 449 | 450 | 451 | @configs[@current_recipe] = config 452 | 453 | # Application template recipe for the rails_apps_composer. Check for a newer version here: 454 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/git.rb 455 | 456 | after_everything do 457 | 458 | say_wizard "Git recipe running 'after everything'" 459 | 460 | # Git should ignore some files 461 | remove_file '.gitignore' 462 | get "https://raw.github.com/RailsApps/rails3-application-templates/master/files/gitignore.txt", ".gitignore" 463 | 464 | if recipes.include? 'omniauth' 465 | append_file '.gitignore' do <<-TXT 466 | 467 | # keep OmniAuth service provider secrets out of the Git repo 468 | config/initializers/omniauth.rb 469 | TXT 470 | end 471 | end 472 | 473 | # Initialize new Git repo 474 | git :init 475 | git :add => '.' 476 | git :commit => "-aqm 'new Rails app generated by Rails Apps Composer gem'" 477 | # Create a git branch 478 | git :checkout => ' -b working_branch' 479 | git :add => '.' 480 | git :commit => "-m 'Initial commit of working_branch'" 481 | git :checkout => 'master' 482 | end 483 | 484 | 485 | 486 | 487 | 488 | @current_recipe = nil 489 | 490 | # >-----------------------------[ Run Bundler ]-------------------------------< 491 | 492 | say_wizard "Running 'bundle install'. This will take a while." 493 | run 'bundle install' 494 | run 'bundle update' 495 | say_wizard "Running 'after bundler' callbacks." 496 | require 'bundler/setup' 497 | @after_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call} 498 | 499 | @current_recipe = nil 500 | say_wizard "Running 'after everything' callbacks." 501 | @after_everything_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call} 502 | 503 | @current_recipe = nil 504 | say_wizard "Finished running the rails_apps_composer app template." 505 | say_wizard "Your new Rails app is ready." 506 | -------------------------------------------------------------------------------- /rails3-subdomains-template.rb: -------------------------------------------------------------------------------- 1 | # >---------------------------------------------------------------------------< 2 | # 3 | # _____ _ _ 4 | # | __ \ (_) | /\ 5 | # | |__) |__ _ _| |___ / \ _ __ _ __ ___ 6 | # | _ // _` | | / __| / /\ \ | '_ \| '_ \/ __| 7 | # | | \ \ (_| | | \__ \/ ____ \| |_) | |_) \__ \ 8 | # |_| \_\__,_|_|_|___/_/ \_\ .__/| .__/|___/ 9 | # | | | | 10 | # |_| |_| 11 | # 12 | # Template generated by rails_apps_composer. For more information, see: 13 | # https://github.com/RailsApps/rails_apps_composer/ 14 | # Thank you to Michael Bleigh for leading the way with the RailsWizard gem. 15 | # 16 | # >---------------------------------------------------------------------------< 17 | 18 | # >----------------------------[ Initial Setup ]------------------------------< 19 | 20 | run 'bundle update' 21 | 22 | initializer 'generators.rb', <<-RUBY 23 | Rails.application.config.generators do |g| 24 | end 25 | RUBY 26 | 27 | @recipes = ["core", "git", "railsapps", "setup", "readme", "gems", "testing", "email", "models", "controllers", "views", "routes", "frontend", "init", "prelaunch", "extras"] 28 | @prefs = {:railsapps=>"rails3-subdomains", :dev_webserver=>"webrick", :prod_webserver=>"same", :ban_spiders=>true, :jsruntime=>false, :rvmrc=>true} 29 | @gems = [] 30 | @diagnostics_recipes = [["example"], ["setup"], ["railsapps"], ["gems", "setup"], ["gems", "readme", "setup"], ["extras", "gems", "readme", "setup"], ["example", "git"], ["git", "setup"], ["git", "railsapps"], ["gems", "git", "setup"], ["gems", "git", "readme", "setup"], ["extras", "gems", "git", "readme", "setup"], ["controllers", "email", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["controllers", "core", "email", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["controllers", "core", "email", "extras", "frontend", "gems", "git", "init", "models", "prelaunch", "railsapps", "readme", "routes", "setup", "testing", "views"], ["controllers", "email", "example", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["controllers", "email", "example", "extras", "frontend", "gems", "git", "init", "models", "prelaunch", "railsapps", "readme", "routes", "setup", "testing", "views"]] 31 | @diagnostics_prefs = [{:railsapps=>"rails-prelaunch-signup", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"mandrill", :authentication=>"devise", :devise_modules=>"confirmable", :authorization=>"cancan", :starter_app=>"admin_app", :form_builder=>"simple_form"}, {:railsapps=>"rails3-bootstrap-devise-cancan", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"cancan", :starter_app=>"admin_app", :form_builder=>"none"}, {:railsapps=>"rails3-devise-rspec-cucumber", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none", :starter_app=>"users_app", :form_builder=>"none"}, {:railsapps=>"rails3-mongoid-devise", :database=>"mongodb", :orm=>"mongoid", :templates=>"erb", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none", :starter_app=>"users_app", :form_builder=>"none"}, {:railsapps=>"rails3-mongoid-omniauth", :database=>"mongodb", :orm=>"mongoid", :templates=>"erb", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"none", :authentication=>"omniauth", :omniauth_provider=>"twitter", :authorization=>"none", :starter_app=>"users_app", :form_builder=>"none"}, {:railsapps=>"rails3-subdomains", :database=>"mongodb", :orm=>"mongoid", :templates=>"haml", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none", :starter_app=>"subdomains_app", :form_builder=>"none"}, {:railsapps=>"none", :database=>"sqlite", :unit_test=>"rspec", :integration=>"capybara", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"none", :authentication=>"omniauth", :omniauth_provider=>"twitter", :authorization=>"cancan", :form_builder=>"none", :starter_app=>"admin_app"}, {:railsapps=>"none", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"none", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"gmail", :authentication=>"devise", :devise_modules=>"invitable", :authorization=>"cancan", :form_builder=>"simple_form", :starter_app=>"admin_app"}, {:railsapps=>"none", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"cancan", :form_builder=>"none", :starter_app=>"admin_app"}, {:railsapps=>"none", :database=>"sqlite", :unit_test=>"test_unit", :integration=>"none", :fixtures=>"none", :frontend=>"bootstrap", :bootstrap=>"less", :email=>"sendgrid", :authentication=>"devise", :devise_modules=>"confirmable", :authorization=>"cancan", :form_builder=>"none", :starter_app=>"admin_app"}] 32 | diagnostics = {} 33 | 34 | def recipes; @recipes end 35 | def recipe?(name); @recipes.include?(name) end 36 | def prefs; @prefs end 37 | def prefer(key, value); @prefs[key].eql? value end 38 | def gems; @gems end 39 | def diagnostics_recipes; @diagnostics_recipes end 40 | def diagnostics_prefs; @diagnostics_prefs end 41 | 42 | def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m" + " #{text}" end 43 | def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end 44 | def say_wizard(text); say_custom(@current_recipe || 'composer', text) end 45 | 46 | def ask_wizard(question) 47 | ask "\033[1m\033[30m\033[46m" + (@current_recipe || "prompt").rjust(10) + "\033[1m\033[36m" + " #{question}\033[0m" 48 | end 49 | 50 | def yes_wizard?(question) 51 | answer = ask_wizard(question + " \033[33m(y/n)\033[0m") 52 | case answer.downcase 53 | when "yes", "y" 54 | true 55 | when "no", "n" 56 | false 57 | else 58 | yes_wizard?(question) 59 | end 60 | end 61 | 62 | def no_wizard?(question); !yes_wizard?(question) end 63 | 64 | def multiple_choice(question, choices) 65 | say_custom('question', question) 66 | values = {} 67 | choices.each_with_index do |choice,i| 68 | values[(i + 1).to_s] = choice[1] 69 | say_custom (i + 1).to_s + ')', choice[0] 70 | end 71 | answer = ask_wizard("Enter your selection:") while !values.keys.include?(answer) 72 | values[answer] 73 | end 74 | 75 | @current_recipe = nil 76 | @configs = {} 77 | 78 | @after_blocks = [] 79 | def after_bundler(&block); @after_blocks << [@current_recipe, block]; end 80 | @after_everything_blocks = [] 81 | def after_everything(&block); @after_everything_blocks << [@current_recipe, block]; end 82 | @before_configs = {} 83 | def before_config(&block); @before_configs[@current_recipe] = block; end 84 | 85 | def copy_from(source, destination) 86 | begin 87 | remove_file destination 88 | get source, destination 89 | rescue OpenURI::HTTPError 90 | say_wizard "Unable to obtain #{source}" 91 | end 92 | end 93 | 94 | def copy_from_repo(filename, opts = {}) 95 | repo = 'https://raw.github.com/RailsApps/rails-composer/master/files/' 96 | repo = opts[:repo] unless opts[:repo].nil? 97 | if (!opts[:prefs].nil?) && (!prefs.has_value? opts[:prefs]) 98 | return 99 | end 100 | source_filename = filename 101 | destination_filename = filename 102 | unless opts[:prefs].nil? 103 | if filename.include? opts[:prefs] 104 | destination_filename = filename.gsub(/\-#{opts[:prefs]}/, '') 105 | end 106 | end 107 | if (prefer :templates, 'haml') && (filename.include? 'views') 108 | remove_file destination_filename 109 | destination_filename = destination_filename.gsub(/.erb/, '.haml') 110 | end 111 | if (prefer :templates, 'slim') && (filename.include? 'views') 112 | remove_file destination_filename 113 | destination_filename = destination_filename.gsub(/.erb/, '.slim') 114 | end 115 | begin 116 | remove_file destination_filename 117 | if (prefer :templates, 'haml') && (filename.include? 'views') 118 | create_file destination_filename, html_to_haml(repo + source_filename) 119 | elsif (prefer :templates, 'slim') && (filename.include? 'views') 120 | create_file destination_filename, html_to_slim(repo + source_filename) 121 | else 122 | get repo + source_filename, destination_filename 123 | end 124 | rescue OpenURI::HTTPError 125 | say_wizard "Unable to obtain #{source_filename} from the repo #{repo}" 126 | end 127 | end 128 | 129 | def html_to_haml(source) 130 | html = open(source) {|input| input.binmode.read } 131 | Haml::HTML.new(html, :erb => true, :xhtml => true).render 132 | end 133 | 134 | def html_to_slim(source) 135 | html = open(source) {|input| input.binmode.read } 136 | haml = Haml::HTML.new(html, :erb => true, :xhtml => true).render 137 | Haml2Slim.convert!(haml) 138 | end 139 | 140 | 141 | if diagnostics_recipes.sort.include? recipes.sort 142 | diagnostics[:recipes] = 'success' 143 | say_wizard("WOOT! The recipes you've selected are known to work together.") 144 | else 145 | diagnostics[:recipes] = 'fail' 146 | say_wizard("\033[1m\033[36m" + "WARNING! The recipes you've selected might not work together." + "\033[0m") 147 | say_wizard("Help us out by reporting whether this combination works or fails.") 148 | say_wizard("Please open an issue for rails_apps_composer on GitHub.") 149 | say_wizard("Your new application will contain diagnostics in its README file.") 150 | say_wizard("Continuing...") 151 | end 152 | 153 | # this application template only supports Rails version 3.1 and newer 154 | case Rails::VERSION::MAJOR.to_s 155 | when "3" 156 | case Rails::VERSION::MINOR.to_s 157 | when "0" 158 | say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer." 159 | raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer." 160 | end 161 | else 162 | say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer." 163 | raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer." 164 | end 165 | 166 | say_wizard "Using rails_apps_composer recipes to generate an application." 167 | 168 | # >---------------------------[ Autoload Modules/Classes ]-----------------------------< 169 | 170 | inject_into_file 'config/application.rb', :after => 'config.autoload_paths += %W(#{config.root}/extras)' do <<-'RUBY' 171 | 172 | config.autoload_paths += %W(#{config.root}/lib) 173 | RUBY 174 | end 175 | 176 | # >---------------------------------[ Recipes ]----------------------------------< 177 | 178 | 179 | # >---------------------------------[ core ]----------------------------------< 180 | 181 | @current_recipe = "core" 182 | @before_configs["core"].call if @before_configs["core"] 183 | say_recipe 'core' 184 | 185 | 186 | @configs[@current_recipe] = config 187 | 188 | # Application template recipe for the rails_apps_composer. Change the recipe here: 189 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/core.rb 190 | 191 | ## Git 192 | say_wizard "selected all core recipes" 193 | 194 | 195 | # >----------------------------------[ git ]----------------------------------< 196 | 197 | @current_recipe = "git" 198 | @before_configs["git"].call if @before_configs["git"] 199 | say_recipe 'git' 200 | 201 | 202 | @configs[@current_recipe] = config 203 | 204 | # Application template recipe for the rails_apps_composer. Change the recipe here: 205 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/git.rb 206 | 207 | ## Git 208 | say_wizard "initialize git" 209 | prefs[:git] = true unless prefs.has_key? :git 210 | if prefer :git, true 211 | copy_from 'https://raw.github.com/RailsApps/rails-composer/master/files/gitignore.txt', '.gitignore' 212 | git :init 213 | git :add => '.' 214 | git :commit => "-aqm 'rails_apps_composer: initial commit'" 215 | end 216 | 217 | 218 | # >-------------------------------[ railsapps ]-------------------------------< 219 | 220 | @current_recipe = "railsapps" 221 | @before_configs["railsapps"].call if @before_configs["railsapps"] 222 | say_recipe 'railsapps' 223 | 224 | 225 | @configs[@current_recipe] = config 226 | 227 | # Application template recipe for the rails_apps_composer. Change the recipe here: 228 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/railsapps.rb 229 | 230 | prefs[:railsapps] = multiple_choice "Install an example application?", 231 | [["I want to build my own application", "none"], 232 | ["rails3-bootstrap-devise-cancan", "rails3-bootstrap-devise-cancan"], 233 | ["rails3-devise-rspec-cucumber", "rails3-devise-rspec-cucumber"], 234 | ["rails3-mongoid-devise", "rails3-mongoid-devise"], 235 | ["rails3-mongoid-omniauth", "rails3-mongoid-omniauth"], 236 | ["rails3-subdomains", "rails3-subdomains"]] unless prefs.has_key? :railsapps 237 | 238 | case prefs[:railsapps] 239 | when 'rails-prelaunch-signup' 240 | prefs[:git] = true 241 | prefs[:database] = 'sqlite' 242 | prefs[:unit_test] = 'rspec' 243 | prefs[:integration] = 'cucumber' 244 | prefs[:fixtures] = 'factory_girl' 245 | prefs[:frontend] = 'bootstrap' 246 | prefs[:bootstrap] = 'sass' 247 | prefs[:email] = 'mandrill' 248 | prefs[:authentication] = 'devise' 249 | prefs[:devise_modules] = 'confirmable' 250 | prefs[:authorization] = 'cancan' 251 | prefs[:starter_app] = 'admin_app' 252 | prefs[:form_builder] = 'simple_form' 253 | if prefer :git, true 254 | prefs[:prelaunch_branch] = multiple_choice "Git branch for the prelaunch app?", [["wip (work-in-progress)", "wip"], ["master", "master"], ["prelaunch", "prelaunch"], ["staging", "staging"]] 255 | if prefs[:prelaunch_branch] == 'master' 256 | prefs[:main_branch] = multiple_choice "Git branch for the main app?", [["None", "none"], ["wip (work-in-progress)", "wip"], ["edge", "edge"]] 257 | else 258 | prefs[:main_branch] = 'master' 259 | end 260 | end 261 | when 'rails3-bootstrap-devise-cancan' 262 | prefs[:git] = true 263 | prefs[:database] = 'sqlite' 264 | prefs[:unit_test] = 'rspec' 265 | prefs[:integration] = 'cucumber' 266 | prefs[:fixtures] = 'factory_girl' 267 | prefs[:frontend] = 'bootstrap' 268 | prefs[:bootstrap] = 'sass' 269 | prefs[:email] = 'gmail' 270 | prefs[:authentication] = 'devise' 271 | prefs[:devise_modules] = 'default' 272 | prefs[:authorization] = 'cancan' 273 | prefs[:starter_app] = 'admin_app' 274 | prefs[:form_builder] = 'none' 275 | when 'rails3-devise-rspec-cucumber' 276 | prefs[:git] = true 277 | prefs[:database] = 'sqlite' 278 | prefs[:unit_test] = 'rspec' 279 | prefs[:integration] = 'cucumber' 280 | prefs[:fixtures] = 'factory_girl' 281 | prefs[:frontend] = 'none' 282 | prefs[:email] = 'gmail' 283 | prefs[:authentication] = 'devise' 284 | prefs[:devise_modules] = 'default' 285 | prefs[:authorization] = 'none' 286 | prefs[:starter_app] = 'users_app' 287 | prefs[:form_builder] = 'none' 288 | when 'rails3-mongoid-devise' 289 | prefs[:git] = true 290 | prefs[:database] = 'mongodb' 291 | prefs[:orm] = 'mongoid' 292 | prefs[:unit_test] = 'rspec' 293 | prefs[:integration] = 'cucumber' 294 | prefs[:fixtures] = 'factory_girl' 295 | prefs[:frontend] = 'none' 296 | prefs[:email] = 'gmail' 297 | prefs[:authentication] = 'devise' 298 | prefs[:devise_modules] = 'default' 299 | prefs[:authorization] = 'none' 300 | prefs[:starter_app] = 'users_app' 301 | prefs[:form_builder] = 'none' 302 | when 'rails3-mongoid-omniauth' 303 | prefs[:git] = true 304 | prefs[:database] = 'mongodb' 305 | prefs[:orm] = 'mongoid' 306 | prefs[:unit_test] = 'rspec' 307 | prefs[:integration] = 'cucumber' 308 | prefs[:fixtures] = 'factory_girl' 309 | prefs[:frontend] = 'none' 310 | prefs[:email] = 'none' 311 | prefs[:authentication] = 'omniauth' 312 | prefs[:omniauth_provider] = 'twitter' 313 | prefs[:authorization] = 'none' 314 | prefs[:starter_app] = 'users_app' 315 | prefs[:form_builder] = 'none' 316 | when 'rails3-subdomains' 317 | prefs[:git] = true 318 | prefs[:database] = 'mongodb' 319 | prefs[:orm] = 'mongoid' 320 | prefs[:unit_test] = 'rspec' 321 | prefs[:integration] = 'cucumber' 322 | prefs[:fixtures] = 'factory_girl' 323 | prefs[:frontend] = 'none' 324 | prefs[:email] = 'gmail' 325 | prefs[:authentication] = 'devise' 326 | prefs[:devise_modules] = 'default' 327 | prefs[:authorization] = 'none' 328 | prefs[:starter_app] = 'subdomains_app' 329 | prefs[:form_builder] = 'none' 330 | end 331 | 332 | 333 | # >---------------------------------[ setup ]---------------------------------< 334 | 335 | @current_recipe = "setup" 336 | @before_configs["setup"].call if @before_configs["setup"] 337 | say_recipe 'setup' 338 | 339 | 340 | @configs[@current_recipe] = config 341 | 342 | # Application template recipe for the rails_apps_composer. Change the recipe here: 343 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/setup.rb 344 | 345 | ## Ruby on Rails 346 | HOST_OS = RbConfig::CONFIG['host_os'] 347 | say_wizard "Your operating system is #{HOST_OS}." 348 | say_wizard "You are using Ruby version #{RUBY_VERSION}." 349 | say_wizard "You are using Rails version #{Rails::VERSION::STRING}." 350 | 351 | ## Is sqlite3 in the Gemfile? 352 | gemfile = File.read(destination_root() + '/Gemfile') 353 | sqlite_detected = gemfile.include? 'sqlite3' 354 | 355 | ## Web Server 356 | prefs[:dev_webserver] = multiple_choice "Web server for development?", [["WEBrick (default)", "webrick"], 357 | ["Thin", "thin"], ["Unicorn", "unicorn"], ["Puma", "puma"]] unless prefs.has_key? :dev_webserver 358 | webserver = multiple_choice "Web server for production?", [["Same as development", "same"], 359 | ["Thin", "thin"], ["Unicorn", "unicorn"], ["Puma", "puma"]] unless prefs.has_key? :prod_webserver 360 | if webserver == 'same' 361 | case prefs[:dev_webserver] 362 | when 'thin' 363 | prefs[:prod_webserver] = 'thin' 364 | when 'unicorn' 365 | prefs[:prod_webserver] = 'unicorn' 366 | when 'puma' 367 | prefs[:prod_webserver] = 'puma' 368 | end 369 | else 370 | prefs[:prod_webserver] = webserver 371 | end 372 | 373 | ## Database Adapter 374 | prefs[:database] = multiple_choice "Database used in development?", [["SQLite", "sqlite"], ["PostgreSQL", "postgresql"], 375 | ["MySQL", "mysql"], ["MongoDB", "mongodb"]] unless prefs.has_key? :database 376 | case prefs[:database] 377 | when 'mongodb' 378 | unless sqlite_detected 379 | prefs[:orm] = multiple_choice "How will you connect to MongoDB?", [["Mongoid","mongoid"]] unless prefs.has_key? :orm 380 | else 381 | say_wizard "WARNING! SQLite gem detected in the Gemfile" 382 | say_wizard "If you wish to use MongoDB you must skip Active Record." 383 | say_wizard "If using rails_apps_composer, choose 'skip Active Record'." 384 | say_wizard "If using Rails Composer or an application template, use the '-O' flag as in 'rails new foo -O'." 385 | prefs[:fail] = multiple_choice "Abort or continue?", [["abort", "abort"], ["continue", "continue"]] 386 | if prefer :fail, 'abort' 387 | raise StandardError.new "SQLite detected in the Gemfile. Use '-O' or '--skip-activerecord' as in 'rails new foo -O' if you don't want ActiveRecord and SQLite" 388 | end 389 | end 390 | end 391 | 392 | ## Template Engine 393 | prefs[:templates] = multiple_choice "Template engine?", [["ERB", "erb"], ["Haml", "haml"], ["Slim", "slim"]] unless prefs.has_key? :templates 394 | 395 | ## Testing Framework 396 | if recipes.include? 'testing' 397 | prefs[:unit_test] = multiple_choice "Unit testing?", [["Test::Unit", "test_unit"], ["RSpec", "rspec"]] unless prefs.has_key? :unit_test 398 | prefs[:integration] = multiple_choice "Integration testing?", [["None", "none"], ["RSpec with Capybara", "capybara"], 399 | ["Cucumber with Capybara", "cucumber"], ["Turnip with Capybara", "turnip"]] unless prefs.has_key? :integration 400 | prefs[:fixtures] = multiple_choice "Fixture replacement?", [["None","none"], ["Factory Girl","factory_girl"], ["Machinist","machinist"]] unless prefs.has_key? :fixtures 401 | end 402 | 403 | ## Front-end Framework 404 | if recipes.include? 'frontend' 405 | prefs[:frontend] = multiple_choice "Front-end framework?", [["None", "none"], ["Twitter Bootstrap", "bootstrap"], 406 | ["Zurb Foundation", "foundation"], ["Skeleton", "skeleton"], ["Just normalize CSS for consistent styling", "normalize"]] unless prefs.has_key? :frontend 407 | if prefer :frontend, 'bootstrap' 408 | case HOST_OS 409 | when /mswin|windows/i 410 | prefs[:bootstrap] = multiple_choice "Twitter Bootstrap version?", [["Twitter Bootstrap (Sass)", "sass"]] unless prefs.has_key? :bootstrap 411 | else 412 | prefs[:bootstrap] = multiple_choice "Twitter Bootstrap version?", [["Twitter Bootstrap (Less)", "less"], 413 | ["Twitter Bootstrap (Sass)", "sass"]] unless prefs.has_key? :bootstrap 414 | end 415 | end 416 | end 417 | 418 | ## Email 419 | if recipes.include? 'email' 420 | prefs[:email] = multiple_choice "Add support for sending email?", [["None", "none"], ["Gmail","gmail"], ["SMTP","smtp"], 421 | ["SendGrid","sendgrid"], ["Mandrill","mandrill"]] unless prefs.has_key? :email 422 | else 423 | prefs[:email] = 'none' 424 | end 425 | 426 | ## Authentication and Authorization 427 | if recipes.include? 'models' 428 | prefs[:authentication] = multiple_choice "Authentication?", [["None", "none"], ["Devise", "devise"], ["OmniAuth", "omniauth"]] unless prefs.has_key? :authentication 429 | case prefs[:authentication] 430 | when 'devise' 431 | if prefer :orm, 'mongoid' 432 | prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"]] unless prefs.has_key? :devise_modules 433 | else 434 | prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"], ["Devise with Confirmable module","confirmable"], 435 | ["Devise with Confirmable and Invitable modules","invitable"]] unless prefs.has_key? :devise_modules 436 | end 437 | when 'omniauth' 438 | prefs[:omniauth_provider] = multiple_choice "OmniAuth provider?", [["Facebook", "facebook"], ["Twitter", "twitter"], ["GitHub", "github"], 439 | ["LinkedIn", "linkedin"], ["Google-Oauth-2", "google-oauth2"], ["Tumblr", "tumblr"]] unless prefs.has_key? :omniauth_provider 440 | end 441 | prefs[:authorization] = multiple_choice "Authorization?", [["None", "none"], ["CanCan with Rolify", "cancan"]] unless prefs.has_key? :authorization 442 | end 443 | 444 | ## Form Builder 445 | prefs[:form_builder] = multiple_choice "Use a form builder gem?", [["None", "none"], ["SimpleForm", "simple_form"]] unless prefs.has_key? :form_builder 446 | 447 | ## MVC 448 | if (recipes.include? 'models') && (recipes.include? 'controllers') && (recipes.include? 'views') && (recipes.include? 'routes') 449 | if prefer :authorization, 'cancan' 450 | prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"], 451 | ["Home Page, User Accounts", "users_app"], ["Home Page, User Accounts, Admin Dashboard", "admin_app"]] unless prefs.has_key? :starter_app 452 | elsif prefer :authentication, 'devise' 453 | if prefer :orm, 'mongoid' 454 | prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"], 455 | ["Home Page, User Accounts", "users_app"], ["Home Page, User Accounts, Subdomains", "subdomains_app"]] unless prefs.has_key? :starter_app 456 | else 457 | prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"], 458 | ["Home Page, User Accounts", "users_app"]] unless prefs.has_key? :starter_app 459 | end 460 | elsif prefer :authentication, 'omniauth' 461 | prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"], 462 | ["Home Page, User Accounts", "users_app"]] unless prefs.has_key? :starter_app 463 | else 464 | prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"]] unless prefs.has_key? :starter_app 465 | end 466 | end 467 | 468 | # save diagnostics before anything can fail 469 | create_file "README", "RECIPES\n#{recipes.sort.inspect}\n" 470 | append_file "README", "PREFERENCES\n#{prefs.inspect}" 471 | 472 | 473 | # >--------------------------------[ readme ]---------------------------------< 474 | 475 | @current_recipe = "readme" 476 | @before_configs["readme"].call if @before_configs["readme"] 477 | say_recipe 'readme' 478 | 479 | 480 | @configs[@current_recipe] = config 481 | 482 | # Application template recipe for the rails_apps_composer. Change the recipe here: 483 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/readme.rb 484 | 485 | after_everything do 486 | say_wizard "recipe running after everything" 487 | 488 | # remove default READMEs 489 | %w{ 490 | README 491 | README.rdoc 492 | doc/README_FOR_APP 493 | }.each { |file| remove_file file } 494 | 495 | # add placeholder READMEs and humans.txt file 496 | copy_from_repo 'public/humans.txt' 497 | copy_from_repo 'README' 498 | copy_from_repo 'README.textile' 499 | gsub_file "README", /App_Name/, "#{app_name.humanize.titleize}" 500 | gsub_file "README.textile", /App_Name/, "#{app_name.humanize.titleize}" 501 | 502 | # Diagnostics 503 | gsub_file "README.textile", /recipes that are known/, "recipes that are NOT known" if diagnostics[:recipes] == 'fail' 504 | gsub_file "README.textile", /preferences that are known/, "preferences that are NOT known" if diagnostics[:prefs] == 'fail' 505 | gsub_file "README.textile", /RECIPES/, recipes.sort.inspect 506 | gsub_file "README.textile", /PREFERENCES/, prefs.inspect 507 | gsub_file "README", /RECIPES/, recipes.sort.inspect 508 | gsub_file "README", /PREFERENCES/, prefs.inspect 509 | 510 | # Ruby on Rails 511 | gsub_file "README.textile", /\* Ruby/, "* Ruby version #{RUBY_VERSION}" 512 | gsub_file "README.textile", /\* Rails/, "* Rails version #{Rails::VERSION::STRING}" 513 | 514 | # Database 515 | gsub_file "README.textile", /SQLite/, "PostgreSQL" if prefer :database, 'postgresql' 516 | gsub_file "README.textile", /SQLite/, "MySQL" if prefer :database, 'mysql' 517 | gsub_file "README.textile", /SQLite/, "MongoDB" if prefer :database, 'mongodb' 518 | gsub_file "README.textile", /ActiveRecord/, "the Mongoid ORM" if prefer :orm, 'mongoid' 519 | 520 | # Template Engine 521 | gsub_file "README.textile", /ERB/, "Haml" if prefer :templates, 'haml' 522 | gsub_file "README.textile", /ERB/, "Slim" if prefer :templates, 'slim' 523 | 524 | # Testing Framework 525 | gsub_file "README.textile", /Test::Unit/, "RSpec" if prefer :unit_test, 'rspec' 526 | gsub_file "README.textile", /RSpec/, "RSpec and Cucumber" if prefer :integration, 'cucumber' 527 | gsub_file "README.textile", /RSpec/, "RSpec and Factory Girl" if prefer :fixtures, 'factory_girl' 528 | gsub_file "README.textile", /RSpec/, "RSpec and Machinist" if prefer :fixtures, 'machinist' 529 | 530 | # Front-end Framework 531 | gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Twitter Bootstrap (Sass)" if prefer :bootstrap, 'sass' 532 | gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Twitter Bootstrap (Less)" if prefer :bootstrap, 'less' 533 | gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Zurb Foundation" if prefer :frontend, 'foundation' 534 | gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Skeleton" if prefer :frontend, 'skeleton' 535 | gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Normalized CSS" if prefer :frontend, 'normalize' 536 | 537 | # Form Builder 538 | gsub_file "README.textile", /Form Builder: None/, "Form Builder: SimpleForm" if prefer :form_builder, 'simple_form' 539 | 540 | # Email 541 | unless prefer :email, 'none' 542 | gsub_file "README.textile", /Gmail/, "SMTP" if prefer :email, 'smtp' 543 | gsub_file "README.textile", /Gmail/, "SendGrid" if prefer :email, 'sendgrid' 544 | gsub_file "README.textile", /Gmail/, "Mandrill" if prefer :email, 'mandrill' 545 | else 546 | gsub_file "README.textile", /h2. Email/, "" 547 | gsub_file "README.textile", /The application is configured to send email using a Gmail account./, "" 548 | end 549 | 550 | # Authentication and Authorization 551 | gsub_file "README.textile", /Authentication: None/, "Authentication: Devise" if prefer :authentication, 'devise' 552 | gsub_file "README.textile", /Authentication: None/, "Authentication: OmniAuth" if prefer :authentication, 'omniauth' 553 | gsub_file "README.textile", /Authorization: None/, "Authorization: CanCan" if prefer :authorization, 'cancan' 554 | 555 | git :add => '.' if prefer :git, true 556 | git :commit => "-aqm 'rails_apps_composer: add README files'" if prefer :git, true 557 | 558 | end # after_everything 559 | 560 | 561 | # >---------------------------------[ gems ]----------------------------------< 562 | 563 | @current_recipe = "gems" 564 | @before_configs["gems"].call if @before_configs["gems"] 565 | say_recipe 'gems' 566 | 567 | 568 | @configs[@current_recipe] = config 569 | 570 | # Application template recipe for the rails_apps_composer. Change the recipe here: 571 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/gems.rb 572 | 573 | ### GEMFILE ### 574 | 575 | ## Ruby on Rails 576 | insert_into_file 'Gemfile', "ruby '1.9.3'\n", :before => "gem 'rails', '3.2.6'" if prefer :deploy, 'heroku' 577 | 578 | ## Web Server 579 | if (prefs[:dev_webserver] == prefs[:prod_webserver]) 580 | gem 'thin', '>= 1.4.1' if prefer :dev_webserver, 'thin' 581 | gem 'unicorn', '>= 4.3.1' if prefer :dev_webserver, 'unicorn' 582 | gem 'puma', '>= 1.6.3' if prefer :dev_webserver, 'puma' 583 | else 584 | gem 'thin', '>= 1.4.1', :group => [:development, :test] if prefer :dev_webserver, 'thin' 585 | gem 'unicorn', '>= 4.3.1', :group => [:development, :test] if prefer :dev_webserver, 'unicorn' 586 | gem 'puma', '>= 1.6.3', :group => [:development, :test] if prefer :dev_webserver, 'puma' 587 | gem 'thin', '>= 1.4.1', :group => :production if prefer :prod_webserver, 'thin' 588 | gem 'unicorn', '>= 4.3.1', :group => :production if prefer :prod_webserver, 'unicorn' 589 | gem 'puma', '>= 1.6.3', :group => :production if prefer :prod_webserver, 'puma' 590 | end 591 | 592 | ## Database Adapter 593 | gsub_file 'Gemfile', /gem 'sqlite3'\n/, '' unless prefer :database, 'sqlite' 594 | gem 'mongoid', '>= 3.0.5' if prefer :orm, 'mongoid' 595 | gem 'pg', '>= 0.14.1' if prefer :database, 'postgresql' 596 | gem 'mysql2', '>= 0.3.11' if prefer :database, 'mysql' 597 | 598 | ## Template Engine 599 | if prefer :templates, 'haml' 600 | gem 'haml', '>= 3.1.7' 601 | gem 'haml-rails', '>= 0.3.5', :group => :development 602 | # hpricot and ruby_parser are needed for conversion of HTML to Haml 603 | gem 'hpricot', '>= 0.8.6', :group => :development 604 | gem 'ruby_parser', '>= 2.3.1', :group => :development 605 | end 606 | if prefer :templates, 'slim' 607 | gem 'slim', '>= 1.3.0' 608 | gem 'haml2slim', '>= 0.4.6', :group => :development 609 | # Haml is needed for conversion of HTML to Slim 610 | gem 'haml', '>= 3.1.6', :group => :development 611 | gem 'haml-rails', '>= 0.3.5', :group => :development 612 | gem 'hpricot', '>= 0.8.6', :group => :development 613 | gem 'ruby_parser', '>= 2.3.1', :group => :development 614 | end 615 | 616 | ## Testing Framework 617 | if prefer :unit_test, 'rspec' 618 | gem 'rspec-rails', '>= 2.11.0', :group => [:development, :test] 619 | gem 'capybara', '>= 1.1.2', :group => :test 620 | if prefer :orm, 'mongoid' 621 | # use the database_cleaner gem to reset the test database 622 | gem 'database_cleaner', '>= 0.8.0', :group => :test 623 | # include RSpec matchers from the mongoid-rspec gem 624 | gem 'mongoid-rspec', '>= 1.4.6', :group => :test 625 | end 626 | gem 'email_spec', '>= 1.2.1', :group => :test unless prefer :email, 'none' 627 | end 628 | if prefer :integration, 'cucumber' 629 | gem 'cucumber-rails', '>= 1.3.0', :group => :test, :require => false 630 | gem 'database_cleaner', '>= 0.8.0', :group => :test unless prefer :orm, 'mongoid' 631 | gem 'launchy', '>= 2.1.2', :group => :test 632 | end 633 | gem 'turnip', '>= 1.0.0', :group => :test if prefer :integration, 'turnip' 634 | gem 'factory_girl_rails', '>= 4.0.0', :group => [:development, :test] if prefer :fixtures, 'factory_girl' 635 | gem 'machinist', '>= 2.0', :group => :test if prefer :fixtures, 'machinist' 636 | 637 | ## Front-end Framework 638 | gem 'bootstrap-sass', '>= 2.1.0.0' if prefer :bootstrap, 'sass' 639 | gem 'compass-rails', '>= 1.0.3', :group => :assets if prefer :frontend, 'foundation' 640 | gem 'zurb-foundation', '>= 3.0.9', :group => :assets if prefer :frontend, 'foundation' 641 | if prefer :bootstrap, 'less' 642 | gem 'twitter-bootstrap-rails', '>= 2.1.3', :group => :assets 643 | # install gem 'therubyracer' to use Less 644 | gem 'therubyracer', '>= 0.10.2', :group => :assets, :platform => :ruby 645 | end 646 | 647 | ## Email 648 | gem 'sendgrid', '>= 1.0.1' if prefer :email, 'sendgrid' 649 | gem 'hominid', '>= 3.0.5' if prefer :email, 'mandrill' 650 | 651 | ## Authentication (Devise) 652 | gem 'devise', '>= 2.1.2' if prefer :authentication, 'devise' 653 | gem 'devise_invitable', '>= 1.0.3' if prefer :devise_modules, 'invitable' 654 | 655 | ## Authentication (OmniAuth) 656 | gem 'omniauth', '>= 1.1.1' if prefer :authentication, 'omniauth' 657 | gem 'omniauth-twitter' if prefer :omniauth_provider, 'twitter' 658 | gem 'omniauth-facebook' if prefer :omniauth_provider, 'facebook' 659 | gem 'omniauth-github' if prefer :omniauth_provider, 'github' 660 | gem 'omniauth-linkedin' if prefer :omniauth_provider, 'linkedin' 661 | gem 'omniauth-google-oauth2' if prefer :omniauth_provider, 'google-oauth2' 662 | gem 'omniauth-tumblr' if prefer :omniauth_provider, 'tumblr' 663 | 664 | ## Authorization 665 | if prefer :authorization, 'cancan' 666 | gem 'cancan', '>= 1.6.8' 667 | gem 'rolify', '>= 3.2.0' 668 | end 669 | 670 | ## Form Builder 671 | gem 'simple_form', '>= 2.0.2' if prefer :form_builder, 'simple_form' 672 | 673 | ## Signup App 674 | if prefer :railsapps, 'rails-prelaunch-signup' 675 | gem 'google_visualr', '>= 2.1.2' 676 | gem 'jquery-datatables-rails', '>= 1.11.0' 677 | end 678 | 679 | ## Gems from a defaults file or added interactively 680 | gems.each do |g| 681 | gem g 682 | end 683 | 684 | ## Git 685 | git :add => '.' if prefer :git, true 686 | git :commit => "-aqm 'rails_apps_composer: Gemfile'" if prefer :git, true 687 | 688 | ### CREATE DATABASE ### 689 | after_bundler do 690 | copy_from_repo 'config/database-postgresql.yml', :prefs => 'postgresql' 691 | copy_from_repo 'config/database-mysql.yml', :prefs => 'mysql' 692 | generate 'mongoid:config' if prefer :orm, 'mongoid' 693 | remove_file 'config/database.yml' if prefer :orm, 'mongoid' 694 | if prefer :database, 'postgresql' 695 | begin 696 | say_wizard "Creating a user named '#{app_name}' for PostgreSQL" 697 | run "createuser #{app_name}" if prefer :database, 'postgresql' 698 | gsub_file "config/database.yml", /username: .*/, "username: #{app_name}" 699 | gsub_file "config/database.yml", /database: myapp_development/, "database: #{app_name}_development" 700 | gsub_file "config/database.yml", /database: myapp_test/, "database: #{app_name}_test" 701 | gsub_file "config/database.yml", /database: myapp_production/, "database: #{app_name}_production" 702 | rescue StandardError 703 | raise "unable to create a user for PostgreSQL" 704 | end 705 | end 706 | if prefer :database, 'mysql' 707 | gsub_file "config/database.yml", /database: myapp_development/, "database: #{app_name}_development" 708 | gsub_file "config/database.yml", /database: myapp_test/, "database: #{app_name}_test" 709 | gsub_file "config/database.yml", /database: myapp_production/, "database: #{app_name}_production" 710 | end 711 | unless prefer :database, 'sqlite' 712 | affirm = multiple_choice "Drop any existing databases named #{app_name}?", 713 | [["Yes (continue)",true], ["No (abort)",false]] 714 | if affirm 715 | run 'bundle exec rake db:drop' 716 | else 717 | raise "aborted at user's request" 718 | end 719 | end 720 | run 'bundle exec rake db:create:all' unless prefer :orm, 'mongoid' 721 | run 'bundle exec rake db:create' if prefer :orm, 'mongoid' 722 | ## Git 723 | git :add => '.' if prefer :git, true 724 | git :commit => "-aqm 'rails_apps_composer: create database'" if prefer :git, true 725 | end # after_bundler 726 | 727 | ### GENERATORS ### 728 | after_bundler do 729 | ## Front-end Framework 730 | generate 'foundation:install' if prefer :frontend, 'foundation' 731 | ## Form Builder 732 | if prefer :form_builder, 'simple_form' 733 | if prefer :frontend, 'bootstrap' 734 | say_wizard "recipe installing simple_form for use with Twitter Bootstrap" 735 | generate 'simple_form:install --bootstrap' 736 | else 737 | say_wizard "recipe installing simple_form" 738 | generate 'simple_form:install' 739 | end 740 | end 741 | ## Git 742 | git :add => '.' if prefer :git, true 743 | git :commit => "-aqm 'rails_apps_composer: generators'" if prefer :git, true 744 | end # after_bundler 745 | 746 | 747 | # >--------------------------------[ testing ]--------------------------------< 748 | 749 | @current_recipe = "testing" 750 | @before_configs["testing"].call if @before_configs["testing"] 751 | say_recipe 'testing' 752 | 753 | 754 | @configs[@current_recipe] = config 755 | 756 | # Application template recipe for the rails_apps_composer. Change the recipe here: 757 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/testing.rb 758 | 759 | after_bundler do 760 | say_wizard "recipe running after 'bundle install'" 761 | ### RSPEC ### 762 | if prefer :unit_test, 'rspec' 763 | say_wizard "recipe installing RSpec" 764 | generate 'rspec:install' 765 | copy_from_repo 'spec/spec_helper.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/' 766 | unless prefer :email, 'none' 767 | generate 'email_spec:steps' 768 | inject_into_file 'spec/spec_helper.rb', "require 'email_spec'\n", :after => "require 'rspec/rails'\n" 769 | inject_into_file 'spec/spec_helper.rb', :after => "RSpec.configure do |config|\n" do <<-RUBY 770 | config.include(EmailSpec::Helpers) 771 | config.include(EmailSpec::Matchers) 772 | RUBY 773 | end 774 | end 775 | run 'rm -rf test/' # Removing test folder (not needed for RSpec) 776 | inject_into_file 'config/application.rb', :after => "Rails::Application\n" do <<-RUBY 777 | 778 | # don't generate RSpec tests for views and helpers 779 | config.generators do |g| 780 | g.view_specs false 781 | g.helper_specs false 782 | #{"g.fixture_replacement :machinist" if prefer :fixtures, 'machinist'} 783 | end 784 | 785 | RUBY 786 | end 787 | ## RSPEC AND MONGOID 788 | if prefer :orm, 'mongoid' 789 | # remove ActiveRecord artifacts 790 | gsub_file 'spec/spec_helper.rb', /config.fixture_path/, '# config.fixture_path' 791 | gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures/, '# config.use_transactional_fixtures' 792 | # remove either possible occurrence of "require rails/test_unit/railtie" 793 | gsub_file 'config/application.rb', /require 'rails\/test_unit\/railtie'/, '# require "rails/test_unit/railtie"' 794 | gsub_file 'config/application.rb', /require "rails\/test_unit\/railtie"/, '# require "rails/test_unit/railtie"' 795 | # configure RSpec to use matchers from the mongoid-rspec gem 796 | create_file 'spec/support/mongoid.rb' do 797 | <<-RUBY 798 | RSpec.configure do |config| 799 | config.include Mongoid::Matchers 800 | end 801 | RUBY 802 | end 803 | end 804 | ## RSPEC AND DEVISE 805 | if prefer :authentication, 'devise' 806 | # add Devise test helpers 807 | create_file 'spec/support/devise.rb' do 808 | <<-RUBY 809 | RSpec.configure do |config| 810 | config.include Devise::TestHelpers, :type => :controller 811 | end 812 | RUBY 813 | end 814 | end 815 | end 816 | ### CUCUMBER ### 817 | if prefer :integration, 'cucumber' 818 | say_wizard "recipe installing Cucumber" 819 | generate "cucumber:install --capybara#{' --rspec' if prefer :unit_test, 'rspec'}#{' -D' if prefer :orm, 'mongoid'}" 820 | # make it easy to run Cucumber for single features without adding "--require features" to the command line 821 | gsub_file 'config/cucumber.yml', /std_opts = "/, 'std_opts = "-r features/support/ -r features/step_definitions ' 822 | unless prefer :email, 'none' 823 | create_file 'features/support/email_spec.rb' do <<-RUBY 824 | require 'email_spec/cucumber' 825 | RUBY 826 | end 827 | end 828 | ## CUCUMBER AND MONGOID 829 | if prefer :orm, 'mongoid' 830 | gsub_file 'features/support/env.rb', /transaction/, "truncation" 831 | inject_into_file 'features/support/env.rb', :after => 'begin' do 832 | "\n DatabaseCleaner.orm = 'mongoid'" 833 | end 834 | end 835 | end 836 | ## TURNIP 837 | if prefer :integration, 'turnip' 838 | append_file '.rspec', '-r turnip/rspec' 839 | inject_into_file 'spec/spec_helper.rb', "require 'turnip/capybara'\n", :after => "require 'rspec/rails'\n" 840 | create_file 'spec/acceptance/steps/.gitkeep' 841 | end 842 | ## FIXTURE REPLACEMENTS 843 | if prefer :fixtures, 'machinist' 844 | say_wizard "generating blueprints file for 'machinist'" 845 | generate 'machinist:install' 846 | end 847 | ### GIT ### 848 | git :add => '.' if prefer :git, true 849 | git :commit => "-aqm 'rails_apps_composer: testing framework'" if prefer :git, true 850 | end # after_bundler 851 | 852 | after_everything do 853 | say_wizard "recipe running after everything" 854 | ### RSPEC ### 855 | if prefer :unit_test, 'rspec' 856 | if (prefer :authentication, 'devise') && (prefer :starter_app, 'users_app') 857 | say_wizard "copying RSpec files from the rails3-devise-rspec-cucumber examples" 858 | repo = 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/' 859 | copy_from_repo 'spec/factories/users.rb', :repo => repo 860 | gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at" if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable') 861 | copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo 862 | copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo 863 | copy_from_repo 'spec/models/user_spec.rb', :repo => repo 864 | remove_file 'spec/views/home/index.html.erb_spec.rb' 865 | remove_file 'spec/views/home/index.html.haml_spec.rb' 866 | remove_file 'spec/views/users/show.html.erb_spec.rb' 867 | remove_file 'spec/views/users/show.html.haml_spec.rb' 868 | remove_file 'spec/helpers/home_helper_spec.rb' 869 | remove_file 'spec/helpers/users_helper_spec.rb' 870 | end 871 | if (prefer :authentication, 'devise') && (prefer :starter_app, 'admin_app') 872 | say_wizard "copying RSpec files from the rails3-bootstrap-devise-cancan examples" 873 | repo = 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/' 874 | copy_from_repo 'spec/factories/users.rb', :repo => repo 875 | gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at" if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable') 876 | copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo 877 | copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo 878 | copy_from_repo 'spec/models/user_spec.rb', :repo => repo 879 | remove_file 'spec/views/home/index.html.erb_spec.rb' 880 | remove_file 'spec/views/home/index.html.haml_spec.rb' 881 | remove_file 'spec/views/users/show.html.erb_spec.rb' 882 | remove_file 'spec/views/users/show.html.haml_spec.rb' 883 | remove_file 'spec/helpers/home_helper_spec.rb' 884 | remove_file 'spec/helpers/users_helper_spec.rb' 885 | end 886 | ## RSPEC AND OMNIAUTH 887 | if (prefer :authentication, 'omniauth') && (prefer :starter_app, 'users_app') 888 | say_wizard "copying RSpec files from the rails3-mongoid-omniauth examples" 889 | repo = 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/' 890 | copy_from_repo 'spec/factories/users.rb', :repo => repo 891 | copy_from_repo 'spec/controllers/sessions_controller_spec.rb', :repo => repo 892 | copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo 893 | copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo 894 | copy_from_repo 'spec/models/user_spec.rb', :repo => repo 895 | end 896 | ## SUBDOMAINS 897 | if (prefer :authentication, 'devise') && (prefer :starter_app, 'subdomains_app') 898 | say_wizard "copying RSpec files from the rails3-subdomains examples" 899 | repo = 'https://raw.github.com/RailsApps/rails3-subdomains/master/' 900 | copy_from_repo 'spec/factories/users.rb', :repo => repo 901 | copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo 902 | copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo 903 | copy_from_repo 'spec/models/user_spec.rb', :repo => repo 904 | end 905 | ## GIT 906 | git :add => '.' if prefer :git, true 907 | git :commit => "-aqm 'rails_apps_composer: rspec files'" if prefer :git, true 908 | end 909 | ### CUCUMBER ### 910 | if prefer :integration, 'cucumber' 911 | ## CUCUMBER AND DEVISE (USERS APP) 912 | if (prefer :authentication, 'devise') && (prefer :starter_app, 'users_app') 913 | say_wizard "copying Cucumber scenarios from the rails3-devise-rspec-cucumber examples" 914 | repo = 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/' 915 | copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo 916 | copy_from_repo 'features/users/sign_in.feature', :repo => repo 917 | copy_from_repo 'features/users/sign_out.feature', :repo => repo 918 | copy_from_repo 'features/users/sign_up.feature', :repo => repo 919 | copy_from_repo 'features/users/user_edit.feature', :repo => repo 920 | copy_from_repo 'features/users/user_show.feature', :repo => repo 921 | copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo 922 | copy_from_repo 'features/support/paths.rb', :repo => repo 923 | if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable') 924 | gsub_file 'features/step_definitions/user_steps.rb', /Welcome! You have signed up successfully./, "A message with a confirmation link has been sent to your email address." 925 | inject_into_file 'features/users/sign_in.feature', :before => ' Scenario: User signs in successfully' do 926 | <<-RUBY 927 | Scenario: User has not confirmed account 928 | Given I exist as an unconfirmed user 929 | And I am not logged in 930 | When I sign in with valid credentials 931 | Then I see an unconfirmed account message 932 | And I should be signed out 933 | RUBY 934 | end 935 | end 936 | end 937 | ## CUCUMBER AND DEVISE (ADMIN APP) 938 | if (prefer :authentication, 'devise') && (prefer :starter_app, 'admin_app') 939 | say_wizard "copying Cucumber scenarios from the rails3-bootstrap-devise-cancan examples" 940 | repo = 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/' 941 | copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo 942 | copy_from_repo 'features/users/sign_in.feature', :repo => repo 943 | copy_from_repo 'features/users/sign_out.feature', :repo => repo 944 | copy_from_repo 'features/users/sign_up.feature', :repo => repo 945 | copy_from_repo 'features/users/user_edit.feature', :repo => repo 946 | copy_from_repo 'features/users/user_show.feature', :repo => repo 947 | copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo 948 | copy_from_repo 'features/support/paths.rb', :repo => repo 949 | if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable') 950 | gsub_file 'features/step_definitions/user_steps.rb', /Welcome! You have signed up successfully./, "A message with a confirmation link has been sent to your email address." 951 | inject_into_file 'features/users/sign_in.feature', :before => ' Scenario: User signs in successfully' do 952 | <<-RUBY 953 | Scenario: User has not confirmed account 954 | Given I exist as an unconfirmed user 955 | And I am not logged in 956 | When I sign in with valid credentials 957 | Then I see an unconfirmed account message 958 | And I should be signed out 959 | RUBY 960 | end 961 | end 962 | end 963 | ## CUCUMBER AND DEVISE (SUBDOMAINS APP) 964 | if (prefer :authentication, 'devise') && (prefer :starter_app, 'subdomains_app') 965 | say_wizard "copying RSpec files from the rails3-subdomains examples" 966 | repo = 'https://raw.github.com/RailsApps/rails3-subdomains/master/' 967 | copy_from_repo 'features/users/sign_in.feature', :repo => repo 968 | copy_from_repo 'features/users/sign_out.feature', :repo => repo 969 | copy_from_repo 'features/users/sign_up.feature', :repo => repo 970 | copy_from_repo 'features/users/user_edit.feature', :repo => repo 971 | copy_from_repo 'features/users/user_show.feature', :repo => repo 972 | copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo 973 | copy_from_repo 'features/support/paths.rb', :repo => repo 974 | end 975 | ## GIT 976 | git :add => '.' if prefer :git, true 977 | git :commit => "-aqm 'rails_apps_composer: cucumber files'" if prefer :git, true 978 | end 979 | end # after_everything 980 | 981 | 982 | # >---------------------------------[ email ]---------------------------------< 983 | 984 | @current_recipe = "email" 985 | @before_configs["email"].call if @before_configs["email"] 986 | say_recipe 'email' 987 | 988 | 989 | @configs[@current_recipe] = config 990 | 991 | # Application template recipe for the rails_apps_composer. Change the recipe here: 992 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/email.rb 993 | 994 | after_bundler do 995 | say_wizard "recipe running after 'bundle install'" 996 | unless prefer :email, 'none' 997 | ### DEVELOPMENT 998 | gsub_file 'config/environments/development.rb', /# Don't care if the mailer can't send/, '# ActionMailer Config' 999 | gsub_file 'config/environments/development.rb', /config.action_mailer.raise_delivery_errors = false/ do 1000 | <<-RUBY 1001 | config.action_mailer.default_url_options = { :host => 'localhost:3000' } 1002 | config.action_mailer.delivery_method = :smtp 1003 | # change to true to allow email to be sent during development 1004 | config.action_mailer.perform_deliveries = false 1005 | config.action_mailer.raise_delivery_errors = true 1006 | config.action_mailer.default :charset => "utf-8" 1007 | RUBY 1008 | end 1009 | ### TEST 1010 | inject_into_file 'config/environments/test.rb', :before => "\nend" do 1011 | <<-RUBY 1012 | \n 1013 | # ActionMailer Config 1014 | config.action_mailer.default_url_options = { :host => 'example.com' } 1015 | RUBY 1016 | end 1017 | ### PRODUCTION 1018 | gsub_file 'config/environments/production.rb', /config.active_support.deprecation = :notify/ do 1019 | <<-RUBY 1020 | config.active_support.deprecation = :notify 1021 | 1022 | config.action_mailer.default_url_options = { :host => 'example.com' } 1023 | # ActionMailer Config 1024 | # Setup for production - deliveries, no errors raised 1025 | config.action_mailer.delivery_method = :smtp 1026 | config.action_mailer.perform_deliveries = true 1027 | config.action_mailer.raise_delivery_errors = false 1028 | config.action_mailer.default :charset => "utf-8" 1029 | RUBY 1030 | end 1031 | end 1032 | ### GMAIL ACCOUNT 1033 | if prefer :email, 'gmail' 1034 | gmail_configuration_text = <<-TEXT 1035 | \n 1036 | config.action_mailer.smtp_settings = { 1037 | address: "smtp.gmail.com", 1038 | port: 587, 1039 | domain: "example.com", 1040 | authentication: "plain", 1041 | enable_starttls_auto: true, 1042 | user_name: ENV["GMAIL_USERNAME"], 1043 | password: ENV["GMAIL_PASSWORD"] 1044 | } 1045 | TEXT 1046 | inject_into_file 'config/environments/development.rb', gmail_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"' 1047 | inject_into_file 'config/environments/production.rb', gmail_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"' 1048 | end 1049 | ### SENDGRID ACCOUNT 1050 | if prefer :email, 'sendgrid' 1051 | sendgrid_configuration_text = <<-TEXT 1052 | \n 1053 | config.action_mailer.smtp_settings = { 1054 | address: "smtp.sendgrid.net", 1055 | port: 25, 1056 | domain: "example.com", 1057 | authentication: "plain", 1058 | user_name: ENV["SENDGRID_USERNAME"], 1059 | password: ENV["SENDGRID_PASSWORD"] 1060 | } 1061 | TEXT 1062 | inject_into_file 'config/environments/development.rb', sendgrid_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"' 1063 | inject_into_file 'config/environments/production.rb', sendgrid_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"' 1064 | end 1065 | ### MANDRILL ACCOUNT 1066 | if prefer :email, 'mandrill' 1067 | mandrill_configuration_text = <<-TEXT 1068 | \n 1069 | config.action_mailer.smtp_settings = { 1070 | :address => "smtp.mandrillapp.com", 1071 | :port => 25, 1072 | :user_name => ENV["MANDRILL_USERNAME"], 1073 | :password => ENV["MANDRILL_API_KEY"] 1074 | } 1075 | TEXT 1076 | inject_into_file 'config/environments/development.rb', mandrill_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"' 1077 | inject_into_file 'config/environments/production.rb', mandrill_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"' 1078 | end 1079 | ### GIT 1080 | git :add => '.' if prefer :git, true 1081 | git :commit => "-aqm 'rails_apps_composer: set email accounts'" if prefer :git, true 1082 | end # after_bundler 1083 | 1084 | 1085 | # >--------------------------------[ models ]---------------------------------< 1086 | 1087 | @current_recipe = "models" 1088 | @before_configs["models"].call if @before_configs["models"] 1089 | say_recipe 'models' 1090 | 1091 | 1092 | @configs[@current_recipe] = config 1093 | 1094 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1095 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/models.rb 1096 | 1097 | after_bundler do 1098 | say_wizard "recipe running after 'bundle install'" 1099 | ### DEVISE ### 1100 | if prefer :authentication, 'devise' 1101 | # prevent logging of password_confirmation 1102 | gsub_file 'config/application.rb', /:password/, ':password, :password_confirmation' 1103 | generate 'devise:install' 1104 | generate 'devise_invitable:install' if prefer :devise_modules, 'invitable' 1105 | generate 'devise user' # create the User model 1106 | if prefer :orm, 'mongoid' 1107 | ## DEVISE AND MONGOID 1108 | copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-devise/master/' 1109 | if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable') 1110 | gsub_file 'app/models/user.rb', /:registerable,/, ":registerable, :confirmable," 1111 | gsub_file 'app/models/user.rb', /# field :confirmation_token/, "field :confirmation_token" 1112 | gsub_file 'app/models/user.rb', /# field :confirmed_at/, "field :confirmed_at" 1113 | gsub_file 'app/models/user.rb', /# field :confirmation_sent_at/, "field :confirmation_sent_at" 1114 | gsub_file 'app/models/user.rb', /# field :unconfirmed_email/, "field :unconfirmed_email" 1115 | end 1116 | if (prefer :devise_modules, 'invitable') 1117 | gsub_file 'app/models/user.rb', /\bend\s*\Z/ do 1118 | <<-RUBY 1119 | #invitable 1120 | field :invitation_token, :type => String 1121 | field :invitation_sent_at, :type => Time 1122 | field :invitation_accepted_at, :type => Time 1123 | field :invitation_limit, :type => Integer 1124 | field :invited_by_id, :type => String 1125 | field :invited_by_type, :type => String 1126 | end 1127 | RUBY 1128 | end 1129 | end 1130 | else 1131 | ## DEVISE AND ACTIVE RECORD 1132 | generate 'migration AddNameToUsers name:string' 1133 | copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/' 1134 | if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable') 1135 | gsub_file 'app/models/user.rb', /:registerable,/, ":registerable, :confirmable," 1136 | generate 'migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string' 1137 | end 1138 | end 1139 | ## DEVISE AND CUCUMBER 1140 | if prefer :integration, 'cucumber' 1141 | # Cucumber wants to test GET requests not DELETE requests for destroy_user_session_path 1142 | # (see https://github.com/RailsApps/rails3-devise-rspec-cucumber/issues/3) 1143 | gsub_file 'config/initializers/devise.rb', 'config.sign_out_via = :delete', 'config.sign_out_via = Rails.env.test? ? :get : :delete' 1144 | end 1145 | end 1146 | ### OMNIAUTH ### 1147 | if prefer :authentication, 'omniauth' 1148 | repo = 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/' 1149 | copy_from_repo 'config/initializers/omniauth.rb', :repo => repo 1150 | generate 'model User name:string email:string provider:string uid:string' unless prefer :orm, 'mongoid' 1151 | run 'bundle exec rake db:migrate' unless prefer :orm, 'mongoid' 1152 | copy_from_repo 'app/models/user.rb', :repo => repo # copy the User model (Mongoid version) 1153 | unless prefer :orm, 'mongoid' 1154 | ## OMNIAUTH AND ACTIVE RECORD 1155 | gsub_file 'app/models/user.rb', /class User/, 'class User < ActiveRecord::Base' 1156 | gsub_file 'app/models/user.rb', /^\s*include Mongoid::Document\n/, '' 1157 | gsub_file 'app/models/user.rb', /^\s*field.*\n/, '' 1158 | gsub_file 'app/models/user.rb', /^\s*# run 'rake db:mongoid:create_indexes' to create indexes\n/, '' 1159 | gsub_file 'app/models/user.rb', /^\s*index\(\{ email: 1 \}, \{ unique: true, background: true \}\)\n/, '' 1160 | end 1161 | end 1162 | ### SUBDOMAINS ### 1163 | copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app' 1164 | ### AUTHORIZATION ### 1165 | if prefer :authorization, 'cancan' 1166 | generate 'cancan:ability' 1167 | if prefer :starter_app, 'admin_app' # Limit access to the users#index page 1168 | copy_from_repo 'app/models/ability.rb', :repo => 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/' 1169 | end 1170 | unless prefer :orm, 'mongoid' 1171 | generate 'rolify:role Role User' 1172 | else 1173 | generate 'rolify:role Role User mongoid' 1174 | # correct the generation of rolify 3.1 with mongoid 1175 | # the call to `rolify` should be *after* the inclusion of mongoid 1176 | # (see https://github.com/EppO/rolify/issues/61) 1177 | # This isn't needed for rolify>=3.2.0.beta4, but should cause no harm 1178 | gsub_file 'app/models/user.rb', 1179 | /^\s*(rolify.*?)$\s*(include Mongoid::Document.*?)$/, 1180 | " \\2\n extend Rolify\n \\1\n" 1181 | end 1182 | end 1183 | ### GIT ### 1184 | git :add => '.' if prefer :git, true 1185 | git :commit => "-aqm 'rails_apps_composer: models'" if prefer :git, true 1186 | end # after_bundler 1187 | 1188 | 1189 | # >------------------------------[ controllers ]------------------------------< 1190 | 1191 | @current_recipe = "controllers" 1192 | @before_configs["controllers"].call if @before_configs["controllers"] 1193 | say_recipe 'controllers' 1194 | 1195 | 1196 | @configs[@current_recipe] = config 1197 | 1198 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1199 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/controllers.rb 1200 | 1201 | after_bundler do 1202 | say_wizard "recipe running after 'bundle install'" 1203 | ### APPLICATION_CONTROLLER ### 1204 | if prefer :authentication, 'omniauth' 1205 | copy_from_repo 'app/controllers/application_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/' 1206 | end 1207 | if prefer :authorization, 'cancan' 1208 | inject_into_file 'app/controllers/application_controller.rb', :before => "\nend" do <<-RUBY 1209 | \n 1210 | rescue_from CanCan::AccessDenied do |exception| 1211 | redirect_to root_path, :alert => exception.message 1212 | end 1213 | RUBY 1214 | end 1215 | end 1216 | ### HOME_CONTROLLER ### 1217 | if ['home_app','users_app','admin_app','subdomains_app'].include? prefs[:starter_app] 1218 | generate(:controller, "home index") 1219 | end 1220 | if ['users_app','admin_app','subdomains_app'].include? prefs[:starter_app] 1221 | gsub_file 'app/controllers/home_controller.rb', /def index/, "def index\n @users = User.all" 1222 | end 1223 | ### USERS_CONTROLLER ### 1224 | if ['users_app','admin_app','subdomains_app'].include? prefs[:starter_app] 1225 | if prefer :authentication, 'devise' 1226 | copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/' 1227 | elsif prefer :authentication, 'omniauth' 1228 | copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/' 1229 | end 1230 | if prefer :authorization, 'cancan' 1231 | inject_into_file 'app/controllers/users_controller.rb', " authorize! :index, @user, :message => 'Not authorized as an administrator.'\n", :after => "def index\n" 1232 | end 1233 | end 1234 | gsub_file 'app/controllers/users_controller.rb', /before_filter :authenticate_user!/, '' if prefer :starter_app, 'subdomains_app' 1235 | ### SESSIONS_CONTROLLER ### 1236 | if prefer :authentication, 'omniauth' 1237 | filename = 'app/controllers/sessions_controller.rb' 1238 | copy_from_repo filename, :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/' 1239 | gsub_file filename, /twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter' 1240 | if prefer :authorization, 'cancan' 1241 | inject_into_file filename, " user.add_role :admin if User.count == 1 # make the first user an admin\n", :after => "session[:user_id] = user.id\n" 1242 | end 1243 | end 1244 | ### PROFILES_CONTROLLER ### 1245 | copy_from_repo 'app/controllers/profiles_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app' 1246 | ### GIT ### 1247 | git :add => '.' if prefer :git, true 1248 | git :commit => "-aqm 'rails_apps_composer: controllers'" if prefer :git, true 1249 | end # after_bundler 1250 | 1251 | 1252 | # >---------------------------------[ views ]---------------------------------< 1253 | 1254 | @current_recipe = "views" 1255 | @before_configs["views"].call if @before_configs["views"] 1256 | say_recipe 'views' 1257 | 1258 | 1259 | @configs[@current_recipe] = config 1260 | 1261 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1262 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/views.rb 1263 | 1264 | after_bundler do 1265 | say_wizard "recipe running after 'bundle install'" 1266 | ### DEVISE ### 1267 | copy_from_repo 'app/views/devise/shared/_links.html.erb' if prefer :authentication, 'devise' 1268 | copy_from_repo 'app/views/devise/registrations/edit.html.erb' if prefer :authentication, 'devise' 1269 | copy_from_repo 'app/views/devise/registrations/new.html.erb' if prefer :authentication, 'devise' 1270 | ### HOME ### 1271 | copy_from_repo 'app/views/home/index.html.erb' if prefer :starter_app, 'users_app' 1272 | copy_from_repo 'app/views/home/index.html.erb' if prefer :starter_app, 'admin_app' 1273 | copy_from_repo 'app/views/home/index-subdomains_app.html.erb', :prefs => 'subdomains_app' 1274 | ### USERS ### 1275 | if ['users_app','admin_app','subdomains_app'].include? prefs[:starter_app] 1276 | ## INDEX 1277 | copy_from_repo 'app/views/users/index.html.erb' 1278 | ## SHOW 1279 | copy_from_repo 'app/views/users/show.html.erb' 1280 | copy_from_repo 'app/views/users/show-subdomains_app.html.erb', :prefs => 'subdomains_app' 1281 | ## EDIT 1282 | copy_from_repo 'app/views/users/edit-omniauth.html.erb', :prefs => 'omniauth' 1283 | end 1284 | ### PROFILES ### 1285 | copy_from_repo 'app/views/profiles/show-subdomains_app.html.erb', :prefs => 'subdomains_app' 1286 | ### GIT ### 1287 | git :add => '.' if prefer :git, true 1288 | git :commit => "-aqm 'rails_apps_composer: views'" if prefer :git, true 1289 | end # after_bundler 1290 | 1291 | 1292 | # >--------------------------------[ routes ]---------------------------------< 1293 | 1294 | @current_recipe = "routes" 1295 | @before_configs["routes"].call if @before_configs["routes"] 1296 | say_recipe 'routes' 1297 | 1298 | 1299 | @configs[@current_recipe] = config 1300 | 1301 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1302 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/routes.rb 1303 | 1304 | after_bundler do 1305 | say_wizard "recipe running after 'bundle install'" 1306 | ### HOME ### 1307 | if prefer :starter_app, 'home_app' 1308 | remove_file 'public/index.html' 1309 | gsub_file 'config/routes.rb', /get \"home\/index\"/, 'root :to => "home#index"' 1310 | end 1311 | ### USER_ACCOUNTS ### 1312 | if ['users_app','admin_app'].include? prefs[:starter_app] 1313 | ## DEVISE 1314 | copy_from_repo 'config/routes.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/' if prefer :authentication, 'devise' 1315 | ## OMNIAUTH 1316 | copy_from_repo 'config/routes.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/' if prefer :authentication, 'omniauth' 1317 | end 1318 | ### SUBDOMAINS ### 1319 | copy_from_repo 'lib/subdomain.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app' 1320 | copy_from_repo 'config/routes.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app' 1321 | ### CORRECT APPLICATION NAME ### 1322 | gsub_file 'config/routes.rb', /^.*.routes.draw do/, "#{app_const}.routes.draw do" 1323 | ### GIT ### 1324 | git :add => '.' if prefer :git, true 1325 | git :commit => "-aqm 'rails_apps_composer: routes'" if prefer :git, true 1326 | end # after_bundler 1327 | 1328 | 1329 | # >-------------------------------[ frontend ]--------------------------------< 1330 | 1331 | @current_recipe = "frontend" 1332 | @before_configs["frontend"].call if @before_configs["frontend"] 1333 | say_recipe 'frontend' 1334 | 1335 | 1336 | @configs[@current_recipe] = config 1337 | 1338 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1339 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/frontend.rb 1340 | 1341 | after_bundler do 1342 | say_wizard "recipe running after 'bundle install'" 1343 | ### LAYOUTS ### 1344 | copy_from_repo 'app/views/layouts/application.html.erb' 1345 | copy_from_repo 'app/views/layouts/application-bootstrap.html.erb', :prefs => 'bootstrap' 1346 | copy_from_repo 'app/views/layouts/_messages.html.erb' 1347 | copy_from_repo 'app/views/layouts/_messages-bootstrap.html.erb', :prefs => 'bootstrap' 1348 | copy_from_repo 'app/views/layouts/_navigation.html.erb' 1349 | if prefer :authorization, 'cancan' 1350 | case prefs[:authentication] 1351 | when 'devise' 1352 | copy_from_repo 'app/views/layouts/_navigation-cancan.html.erb', :prefs => 'cancan' 1353 | when 'omniauth' 1354 | copy_from 'https://raw.github.com/RailsApps/rails-composer/master/files/app/views/layouts/_navigation-cancan-omniauth.html.erb', 'app/views/layouts/_navigation.html.erb' 1355 | end 1356 | else 1357 | copy_from_repo 'app/views/layouts/_navigation-devise.html.erb', :prefs => 'devise' 1358 | copy_from_repo 'app/views/layouts/_navigation-omniauth.html.erb', :prefs => 'omniauth' 1359 | end 1360 | copy_from_repo 'app/views/layouts/_navigation-subdomains_app.html.erb', :prefs => 'subdomains_app' 1361 | ## APPLICATION NAME 1362 | application_layout_file = Dir['app/views/layouts/application.html.*'].first 1363 | navigation_partial_file = Dir['app/views/layouts/_navigation.html.*'].first 1364 | gsub_file application_layout_file, /App_Name/, "#{app_name.humanize.titleize}" 1365 | gsub_file navigation_partial_file, /App_Name/, "#{app_name.humanize.titleize}" 1366 | ### CSS ### 1367 | copy_from_repo 'app/assets/stylesheets/application.css.scss' 1368 | copy_from_repo 'app/assets/stylesheets/application-bootstrap.css.scss', :prefs => 'bootstrap' 1369 | if prefer :bootstrap, 'less' 1370 | generate 'bootstrap:install' 1371 | insert_into_file 'app/assets/stylesheets/bootstrap_and_overrides.css.less', "body { padding-top: 60px; }\n", :after => "@import \"twitter/bootstrap/bootstrap\";\n" 1372 | elsif prefer :bootstrap, 'sass' 1373 | insert_into_file 'app/assets/javascripts/application.js', "//= require bootstrap\n", :after => "jquery_ujs\n" 1374 | create_file 'app/assets/stylesheets/bootstrap_and_overrides.css.scss', <<-RUBY 1375 | @import "bootstrap"; 1376 | body { padding-top: 60px; } 1377 | @import "bootstrap-responsive"; 1378 | RUBY 1379 | elsif prefer :frontend, 'foundation' 1380 | insert_into_file 'app/assets/stylesheets/application.css.scss', " *= require foundation_and_overrides\n", :after => "require_self\n" 1381 | elsif prefer :frontend, 'skeleton' 1382 | copy_from 'https://raw.github.com/necolas/normalize.css/master/normalize.css', 'app/assets/stylesheets/normalize.css' 1383 | copy_from 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/base.css', 'app/assets/stylesheets/base.css' 1384 | copy_from 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/layout.css', 'app/assets/stylesheets/layout.css' 1385 | copy_from 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/skeleton.css', 'app/assets/stylesheets/skeleton.css' 1386 | elsif prefer :frontend, 'normalize' 1387 | copy_from 'https://raw.github.com/necolas/normalize.css/master/normalize.css', 'app/assets/stylesheets/normalize.css' 1388 | end 1389 | remove_file 'app/assets/stylesheets/application.css' 1390 | ### GIT ### 1391 | git :add => '.' if prefer :git, true 1392 | git :commit => "-aqm 'rails_apps_composer: front-end framework'" if prefer :git, true 1393 | end # after_bundler 1394 | 1395 | 1396 | # >---------------------------------[ init ]----------------------------------< 1397 | 1398 | @current_recipe = "init" 1399 | @before_configs["init"].call if @before_configs["init"] 1400 | say_recipe 'init' 1401 | 1402 | 1403 | @configs[@current_recipe] = config 1404 | 1405 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1406 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/init.rb 1407 | 1408 | after_everything do 1409 | say_wizard "recipe running after everything" 1410 | ### PREPARE SEED ### 1411 | if prefer :authentication, 'devise' 1412 | if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable') 1413 | ## DEVISE-CONFIRMABLE 1414 | append_file 'db/seeds.rb' do <<-FILE 1415 | puts 'SETTING UP DEFAULT USER LOGIN' 1416 | user = User.create! :name => 'First User', :email => 'user@example.com', :password => 'please', :password_confirmation => 'please' 1417 | user.confirm! 1418 | puts 'New user created: ' << user.name 1419 | user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'please', :password_confirmation => 'please' 1420 | user2.confirm! 1421 | puts 'New user created: ' << user2.name 1422 | FILE 1423 | end 1424 | else 1425 | ## DEVISE-DEFAULT 1426 | append_file 'db/seeds.rb' do <<-FILE 1427 | puts 'SETTING UP DEFAULT USER LOGIN' 1428 | user = User.create! :name => 'First User', :email => 'user@example.com', :password => 'please', :password_confirmation => 'please' 1429 | puts 'New user created: ' << user.name 1430 | user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'please', :password_confirmation => 'please' 1431 | puts 'New user created: ' << user2.name 1432 | FILE 1433 | end 1434 | end 1435 | if prefer :starter_app, 'subdomains_app' 1436 | gsub_file 'db/seeds.rb', /First User/, 'user1' 1437 | gsub_file 'db/seeds.rb', /Second User/, 'user2' 1438 | end 1439 | if prefer :authorization, 'cancan' 1440 | append_file 'db/seeds.rb' do <<-FILE 1441 | user.add_role :admin 1442 | FILE 1443 | end 1444 | end 1445 | ## DEVISE-INVITABLE 1446 | if prefer :devise_modules, 'invitable' 1447 | run 'bundle exec rake db:migrate' 1448 | generate 'devise_invitable user' 1449 | end 1450 | end 1451 | ### APPLY SEED ### 1452 | unless prefer :orm, 'mongoid' 1453 | ## ACTIVE_RECORD 1454 | say_wizard "applying migrations and seeding the database" 1455 | run 'bundle exec rake db:migrate' 1456 | run 'bundle exec rake db:test:prepare' 1457 | else 1458 | ## MONGOID 1459 | say_wizard "dropping database, creating indexes and seeding the database" 1460 | run 'bundle exec rake db:drop' 1461 | run 'bundle exec rake db:mongoid:create_indexes' 1462 | end 1463 | run 'bundle exec rake db:seed' 1464 | ### GIT ### 1465 | git :add => '.' if prefer :git, true 1466 | git :commit => "-aqm 'rails_apps_composer: set up database'" if prefer :git, true 1467 | end # after_everything 1468 | 1469 | 1470 | # >-------------------------------[ prelaunch ]-------------------------------< 1471 | 1472 | @current_recipe = "prelaunch" 1473 | @before_configs["prelaunch"].call if @before_configs["prelaunch"] 1474 | say_recipe 'prelaunch' 1475 | 1476 | 1477 | @configs[@current_recipe] = config 1478 | 1479 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1480 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/prelaunch.rb 1481 | 1482 | if prefer :railsapps, 'rails-prelaunch-signup' 1483 | 1484 | after_everything do 1485 | say_wizard "recipe running after 'bundle install'" 1486 | repo = 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/' 1487 | 1488 | # >-------------------------------[ Clean up starter app ]--------------------------------< 1489 | 1490 | %w{ 1491 | public/index.html 1492 | app/assets/images/rails.png 1493 | }.each { |file| remove_file file } 1494 | # remove commented lines and multiple blank lines from Gemfile 1495 | # thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb 1496 | gsub_file 'Gemfile', /#.*\n/, "\n" 1497 | gsub_file 'Gemfile', /\n^\s*\n/, "\n" 1498 | # remove commented lines and multiple blank lines from config/routes.rb 1499 | gsub_file 'config/routes.rb', / #.*\n/, "\n" 1500 | gsub_file 'config/routes.rb', /\n^\s*\n/, "\n" 1501 | # GIT 1502 | git :add => '.' if prefer :git, true 1503 | git :commit => "-aqm 'rails_apps_composer: clean up starter app'" if prefer :git, true 1504 | 1505 | # >-------------------------------[ Create a git branch ]--------------------------------< 1506 | if prefer :git, true 1507 | if prefer :prelaunch_branch, 'master' 1508 | unless prefer :main_branch, 'none' 1509 | say_wizard "renaming git branch 'master' to '#{prefs[:main_branch]}' for starter app" 1510 | git :branch => "-m master #{prefs[:main_branch]}" 1511 | git :checkout => "-b master" 1512 | else 1513 | say_wizard "creating prelaunch app on git branch 'master'" 1514 | end 1515 | else 1516 | say_wizard "creating new git branch '#{prefs[:prelaunch_branch]}' for prelaunch app" 1517 | git :checkout => "-b #{prefs[:prelaunch_branch]}" 1518 | end 1519 | end 1520 | 1521 | # >-------------------------------[ Cucumber ]--------------------------------< 1522 | say_wizard "copying Cucumber scenarios from the rails-prelaunch-signup examples" 1523 | copy_from_repo 'features/admin/send_invitations.feature', :repo => repo 1524 | copy_from_repo 'features/admin/view_progress.feature', :repo => repo 1525 | copy_from_repo 'features/visitors/request_invitation.feature', :repo => repo 1526 | copy_from_repo 'features/users/sign_in.feature', :repo => repo 1527 | copy_from_repo 'features/users/sign_up.feature', :repo => repo 1528 | copy_from_repo 'features/users/user_show.feature', :repo => repo 1529 | copy_from_repo 'features/step_definitions/admin_steps.rb', :repo => repo 1530 | copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo 1531 | copy_from_repo 'features/step_definitions/visitor_steps.rb', :repo => repo 1532 | copy_from_repo 'config/locales/devise.en.yml', :repo => repo 1533 | 1534 | # >-------------------------------[ Migrations ]--------------------------------< 1535 | 1536 | generate 'migration AddOptinToUsers opt_in:boolean' 1537 | run 'bundle exec rake db:drop' 1538 | run 'bundle exec rake db:migrate' 1539 | run 'bundle exec rake db:test:prepare' 1540 | run 'bundle exec rake db:seed' 1541 | 1542 | # >-------------------------------[ Models ]--------------------------------< 1543 | 1544 | copy_from_repo 'app/models/user.rb', :repo => repo 1545 | 1546 | # >-------------------------------[ Controllers ]--------------------------------< 1547 | 1548 | copy_from_repo 'app/controllers/confirmations_controller.rb', :repo => repo 1549 | copy_from_repo 'app/controllers/home_controller.rb', :repo => repo 1550 | copy_from_repo 'app/controllers/registrations_controller.rb', :repo => repo 1551 | copy_from_repo 'app/controllers/users_controller.rb', :repo => repo 1552 | 1553 | # >-------------------------------[ Mailers ]--------------------------------< 1554 | 1555 | generate 'mailer UserMailer' 1556 | copy_from_repo 'spec/mailers/user_mailer_spec.rb', :repo => repo 1557 | copy_from_repo 'app/mailers/user_mailer.rb', :repo => repo 1558 | 1559 | # >-------------------------------[ Views ]--------------------------------< 1560 | 1561 | copy_from_repo 'app/views/devise/confirmations/show.html.erb', :repo => repo 1562 | copy_from_repo 'app/views/devise/mailer/confirmation_instructions.html.erb', :repo => repo 1563 | copy_from_repo 'app/views/devise/registrations/_thankyou.html.erb', :repo => repo 1564 | copy_from_repo 'app/views/devise/registrations/new.html.erb', :repo => repo 1565 | copy_from_repo 'app/views/devise/shared/_links.html.erb', :repo => repo 1566 | copy_from_repo 'app/views/home/index.html.erb', :repo => repo 1567 | copy_from_repo 'app/views/user_mailer/welcome_email.html.erb', :repo => repo 1568 | copy_from_repo 'app/views/user_mailer/welcome_email.text.erb', :repo => repo 1569 | copy_from_repo 'app/views/users/index.html.erb', :repo => repo 1570 | copy_from_repo 'public/thankyou.html', :repo => repo 1571 | 1572 | # >-------------------------------[ Routes ]--------------------------------< 1573 | 1574 | copy_from_repo 'config/routes.rb', :repo => repo 1575 | ### CORRECT APPLICATION NAME ### 1576 | gsub_file 'config/routes.rb', /^.*.routes.draw do/, "#{app_const}.routes.draw do" 1577 | 1578 | # >-------------------------------[ Assets ]--------------------------------< 1579 | 1580 | copy_from_repo 'app/assets/javascripts/application.js', :repo => repo 1581 | copy_from_repo 'app/assets/javascripts/users.js.coffee', :repo => repo 1582 | copy_from_repo 'app/assets/stylesheets/application.css.scss', :repo => repo 1583 | 1584 | ### GIT ### 1585 | git :add => '.' if prefer :git, true 1586 | git :commit => "-aqm 'rails_apps_composer: prelaunch app'" if prefer :git, true 1587 | end # after_bundler 1588 | end # rails-prelaunch-signup 1589 | 1590 | 1591 | # >--------------------------------[ extras ]---------------------------------< 1592 | 1593 | @current_recipe = "extras" 1594 | @before_configs["extras"].call if @before_configs["extras"] 1595 | say_recipe 'extras' 1596 | 1597 | config = {} 1598 | config['ban_spiders'] = yes_wizard?("Set a robots.txt file to ban spiders?") if true && true unless config.key?('ban_spiders') || prefs.has_key?(:ban_spiders) 1599 | config['rvmrc'] = yes_wizard?("Create a project-specific rvm gemset and .rvmrc?") if true && true unless config.key?('rvmrc') || prefs.has_key?(:rvmrc) 1600 | config['github'] = yes_wizard?("Create a GitHub repository?") if true && true unless config.key?('github') || prefs.has_key?(:github) 1601 | @configs[@current_recipe] = config 1602 | 1603 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1604 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/extras.rb 1605 | 1606 | ## BAN SPIDERS 1607 | if config['ban_spiders'] 1608 | prefs[:ban_spiders] = true 1609 | end 1610 | if prefs[:ban_spiders] 1611 | say_wizard "recipe banning spiders by modifying 'public/robots.txt'" 1612 | after_bundler do 1613 | gsub_file 'public/robots.txt', /# User-Agent/, 'User-Agent' 1614 | gsub_file 'public/robots.txt', /# Disallow/, 'Disallow' 1615 | end 1616 | end 1617 | 1618 | ## JSRUNTIME 1619 | case RbConfig::CONFIG['host_os'] 1620 | when /linux/i 1621 | prefs[:jsruntime] = yes_wizard? "Add 'therubyracer' JavaScript runtime (for Linux users without node.js)?" unless prefs.has_key? :jsruntime 1622 | if prefs[:jsruntime] 1623 | # was it already added for bootstrap-less? 1624 | unless prefer :bootstrap, 'less' 1625 | say_wizard "recipe adding 'therubyracer' JavaScript runtime gem" 1626 | gem 'therubyracer', '>= 0.10.2', :group => :assets, :platform => :ruby 1627 | end 1628 | end 1629 | end 1630 | 1631 | ## RVMRC 1632 | if config['rvmrc'] 1633 | prefs[:rvmrc] = true 1634 | end 1635 | if prefs[:rvmrc] 1636 | say_wizard "recipe creating project-specific rvm gemset and .rvmrc" 1637 | # using the rvm Ruby API, see: 1638 | # http://blog.thefrontiergroup.com.au/2010/12/a-brief-introduction-to-the-rvm-ruby-api/ 1639 | # https://rvm.io/integration/passenger 1640 | if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm') 1641 | begin 1642 | gems_path = ENV['MY_RUBY_HOME'].split(/@/)[0].sub(/rubies/,'gems') 1643 | ENV['GEM_PATH'] = "#{gems_path}:#{gems_path}@global" 1644 | require 'rvm' 1645 | RVM.use_from_path! File.dirname(File.dirname(__FILE__)) 1646 | rescue LoadError 1647 | raise "RVM gem is currently unavailable." 1648 | end 1649 | end 1650 | say_wizard "creating RVM gemset '#{app_name}'" 1651 | RVM.gemset_create app_name 1652 | run "rvm rvmrc trust" 1653 | say_wizard "switching to gemset '#{app_name}'" 1654 | begin 1655 | RVM.gemset_use! app_name 1656 | rescue StandardError 1657 | raise "rvm failure: unable to use gemset #{app_name}" 1658 | end 1659 | run "rvm gemset list" 1660 | copy_from_repo '.rvmrc' 1661 | gsub_file '.rvmrc', /App_Name/, "#{app_name}" 1662 | end 1663 | 1664 | ## AFTER_EVERYTHING 1665 | after_everything do 1666 | say_wizard "recipe removing unnecessary files and whitespace" 1667 | %w{ 1668 | public/index.html 1669 | app/assets/images/rails.png 1670 | }.each { |file| remove_file file } 1671 | # remove commented lines and multiple blank lines from Gemfile 1672 | # thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb 1673 | gsub_file 'Gemfile', /#.*\n/, "\n" 1674 | gsub_file 'Gemfile', /\n^\s*\n/, "\n" 1675 | # remove commented lines and multiple blank lines from config/routes.rb 1676 | gsub_file 'config/routes.rb', / #.*\n/, "\n" 1677 | gsub_file 'config/routes.rb', /\n^\s*\n/, "\n" 1678 | # GIT 1679 | git :add => '.' if prefer :git, true 1680 | git :commit => "-aqm 'rails_apps_composer: extras'" if prefer :git, true 1681 | end 1682 | 1683 | ## GITHUB 1684 | if config['github'] 1685 | gem 'hub', '>= 1.10.2', :require => nil, :group => [:development] 1686 | after_everything do 1687 | say_wizard "recipe creating GitHub repository" 1688 | git_uri = `git config remote.origin.url`.strip 1689 | unless git_uri.size == 0 1690 | say_wizard "Repository already exists:" 1691 | say_wizard "#{git_uri}" 1692 | else 1693 | run "hub create #{app_name}" 1694 | unless prefer :railsapps, 'rails-prelaunch-signup' 1695 | run "hub push -u origin master" 1696 | else 1697 | run "hub push -u origin #{prefs[:prelaunch_branch]}" 1698 | run "hub push -u origin #{prefs[:main_branch]}" unless prefer :main_branch, 'none' 1699 | end 1700 | end 1701 | end 1702 | end 1703 | 1704 | 1705 | 1706 | # >---------------------------------[ Diagnostics ]----------------------------------< 1707 | 1708 | # remove prefs which are diagnostically irrelevant 1709 | redacted_prefs = prefs.clone 1710 | redacted_prefs.delete(:git) 1711 | redacted_prefs.delete(:dev_webserver) 1712 | redacted_prefs.delete(:prod_webserver) 1713 | redacted_prefs.delete(:templates) 1714 | redacted_prefs.delete(:ban_spiders) 1715 | redacted_prefs.delete(:jsruntime) 1716 | redacted_prefs.delete(:rvmrc) 1717 | redacted_prefs.delete(:prelaunch_branch) 1718 | redacted_prefs.delete(:main_branch) 1719 | 1720 | if diagnostics_prefs.include? redacted_prefs 1721 | diagnostics[:prefs] = 'success' 1722 | else 1723 | diagnostics[:prefs] = 'fail' 1724 | end 1725 | 1726 | 1727 | 1728 | @current_recipe = nil 1729 | 1730 | # >-----------------------------[ Run 'Bundle Install' ]-------------------------------< 1731 | 1732 | say_wizard "Installing gems. This will take a while." 1733 | if prefs.has_key? :bundle_path 1734 | run "bundle install --without production --path #{prefs[:bundle_path]}" 1735 | else 1736 | run 'bundle install --without production' 1737 | end 1738 | 1739 | # >-----------------------------[ Run 'After Bundler' Callbacks ]-------------------------------< 1740 | 1741 | say_wizard "Running 'after bundler' callbacks." 1742 | require 'bundler/setup' 1743 | if prefer :templates, 'haml' 1744 | say_wizard "importing html2haml conversion tool" 1745 | require 'haml/html' 1746 | end 1747 | if prefer :templates, 'slim' 1748 | say_wizard "importing html2haml and haml2slim conversion tools" 1749 | require 'haml/html' 1750 | require 'haml2slim' 1751 | end 1752 | @after_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call} 1753 | 1754 | # >-----------------------------[ Run 'After Everything' Callbacks ]-------------------------------< 1755 | 1756 | @current_recipe = nil 1757 | say_wizard "Running 'after everything' callbacks." 1758 | @after_everything_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call} 1759 | 1760 | @current_recipe = nil 1761 | if diagnostics[:recipes] == 'success' 1762 | say_wizard("WOOT! The recipes you've selected are known to work together.") 1763 | say_wizard("If they don't, open an issue for rails_apps_composer on GitHub.") 1764 | else 1765 | say_wizard("\033[1m\033[36m" + "WARNING! The recipes you've selected might not work together." + "\033[0m") 1766 | say_wizard("Help us out by reporting whether this combination works or fails.") 1767 | say_wizard("Please open an issue for rails_apps_composer on GitHub.") 1768 | say_wizard("Your new application will contain diagnostics in its README file.") 1769 | end 1770 | if diagnostics[:prefs] == 'success' 1771 | say_wizard("WOOT! The preferences you've selected are known to work together.") 1772 | say_wizard("If they don't, open an issue for rails_apps_composer on GitHub.") 1773 | else 1774 | say_wizard("\033[1m\033[36m" + "WARNING! The preferences you've selected might not work together." + "\033[0m") 1775 | say_wizard("Help us out by reporting whether this combination works or fails.") 1776 | say_wizard("Please open an issue for rails_apps_composer on GitHub.") 1777 | say_wizard("Your new application will contain diagnostics in its README file.") 1778 | end 1779 | say_wizard "Finished running the rails_apps_composer app template." 1780 | say_wizard "Your new Rails app is ready. Time to run 'bundle install'." 1781 | --------------------------------------------------------------------------------