├── .gitignore ├── README.textile ├── composer-Rails3_2.rb ├── composer.rb ├── files ├── .rubocop.yml ├── .rvmrc ├── README ├── README.md ├── README.textile ├── app │ ├── assets │ │ └── stylesheets │ │ │ ├── application-bootstrap.css.scss │ │ │ └── application.css.scss │ ├── controllers │ │ ├── application_controller-omniauth.rb │ │ └── registrations_controller-devise.rb │ ├── helpers │ │ └── application_helper-simple_form.rb │ └── views │ │ ├── devise │ │ ├── .DS_Store │ │ ├── registrations │ │ │ ├── edit-simple_form.html.erb │ │ │ ├── edit.html.erb │ │ │ ├── new-simple_form.html.erb │ │ │ └── new.html.erb │ │ ├── sessions │ │ │ └── new-simple_form.html.erb │ │ └── shared │ │ │ └── _links.html.erb │ │ ├── home │ │ ├── index-subdomains_app.html.erb │ │ └── index.html.erb │ │ ├── layouts │ │ ├── _messages-bootstrap.html.erb │ │ ├── _messages.html.erb │ │ ├── _navigation-cancan-omniauth.html.erb │ │ ├── _navigation-cancan.html.erb │ │ ├── _navigation-devise.html.erb │ │ ├── _navigation-omniauth.html.erb │ │ ├── _navigation-subdomains_app.html.erb │ │ ├── _navigation.html.erb │ │ ├── application-bootstrap.html.erb │ │ └── application.html.erb │ │ ├── profiles │ │ └── show-subdomains_app.html.erb │ │ └── users │ │ ├── _user-simple_form.html.erb │ │ ├── _user.html.erb │ │ ├── edit-omniauth.html.erb │ │ ├── index-admin_app.html.erb │ │ ├── index.html.erb │ │ ├── show-subdomains_app.html.erb │ │ └── show.html.erb ├── config │ ├── database-mysql.yml │ ├── database-postgresql.yml │ └── secrets.yml ├── gitignore.txt └── public │ └── humans.txt └── railsComposer.sh /.gitignore: -------------------------------------------------------------------------------- 1 | #---------------------------------------------------------------------------- 2 | # This is the .gitignore file for the rails-composer repository. 3 | # 4 | # Rails Composer is an application template that creates a Rails starter app. 5 | # 6 | # The Rails Composer application template is generated by the rails_apps_composer gem: 7 | # https://github.com/RailsApps/rails_apps_composer 8 | # 9 | # The Rails Composer application template will create a .gitignore file for any starter app. 10 | # This file isn't used by the Rails Composer application template; instead the template uses: 11 | # https://github.com/RailsApps/rails-composer/blob/master/files/gitignore.txt 12 | # 13 | # Corrections? Improvements? Create a GitHub issue: 14 | # http://github.com/RailsApps/rails-composer/issues 15 | #---------------------------------------------------------------------------- 16 | 17 | # bundler state 18 | /.bundle 19 | /vendor/bundle/ 20 | /vendor/ruby/ 21 | 22 | # minimal Rails specific artifacts 23 | db/*.sqlite3 24 | /log/* 25 | /tmp/* 26 | 27 | # various artifacts 28 | **.war 29 | *.rbc 30 | *.sassc 31 | .rspec 32 | .redcar/ 33 | .sass-cache 34 | /config/config.yml 35 | /config/database.yml 36 | /coverage.data 37 | /coverage/ 38 | /db/*.javadb/ 39 | /db/*.sqlite3 40 | /doc/api/ 41 | /doc/app/ 42 | /doc/features.html 43 | /doc/specs.html 44 | /public/cache 45 | /public/stylesheets/compiled 46 | /public/system/* 47 | /spec/tmp/* 48 | /cache 49 | /capybara* 50 | /capybara-*.html 51 | /gems 52 | /spec/requests 53 | /spec/routing 54 | /spec/views 55 | /specifications 56 | rerun.txt 57 | pickle-email-*.html 58 | 59 | # If you find yourself ignoring temporary files generated by your text editor 60 | # or operating system, you probably want to add a global ignore instead: 61 | # git config --global core.excludesfile ~/.gitignore_global 62 | # 63 | # Here are some files you may want to ignore globally: 64 | 65 | # scm revert files 66 | **.orig 67 | 68 | # Mac finder artifacts 69 | .DS_Store 70 | 71 | # Netbeans project directory 72 | /nbproject/ 73 | 74 | # RubyMine project files 75 | .idea 76 | 77 | # Textmate project files 78 | /*.tmproj 79 | 80 | # vim artifacts 81 | **.swp 82 | -------------------------------------------------------------------------------- /README.textile: -------------------------------------------------------------------------------- 1 | h1. !http://railsapps.github.io/images/rails-36x36.jpg(Rails Composer)! Rails Composer 2 | 3 | An application template that creates starter applications for Rails. 4 | 5 | It's the Rails generator on steroids. 6 | 7 | Watch the videos: 8 | 9 | * "Rails Composer Introduction":https://fullstackvideos.com/videos/13 (for beginners) 10 | * "RailsClips Episode 007: Rails Composer":https://devchat.tv/rails-clips/007-railsclips-rails-composer from Charles Max Wood. 11 | 12 | |_. |_. | 13 | | !http://railsapps.github.io/images/rails-composer-mailing-list.png(Sign up for the Rails Composer mailing list)!:http://mailinglist.railscomposer.com/ | !http://railsapps.github.io/images/join/join-railsapps.png(Join the RailsApps Project)!:http://railsapps.github.io/ | 14 | | "Rails Composer mailing list":http://mailinglist.railscomposer.com/ | "Support the project":http://railsapps.github.io/ | 15 | 16 | h4. From the RailsApps Project 17 | 18 | The "RailsApps":http://railsapps.github.io/ open source project offers starter applications and tutorials for Rails developers. Generate the applications with the Rails Composer tool. 19 | 20 | All the code is explained in the Capstone Rails Tutorials. You can purchase the "Capstone Rails Tutorials":https://tutorials.railsapps.org/ to support the project. 21 | 22 | "Sign up for the Rails Composer mailing list":http://mailinglist.railscomposer.com/ for news and announcements. 23 | 24 | h2. Starter Apps and Tutorials 25 | 26 | |_. Example |_. Tutorial |_. Comments | 27 | | "learn-rails":https://github.com/RailsApps/learn-rails | "Learn Ruby on Rails":http://learn-rails.com/learn-ruby-on-rails.html | from the book for beginners | 28 | | "rails-bootstrap":https://github.com/RailsApps/rails-bootstrap | "Rails and Bootstrap":http://railsapps.github.io/twitter-bootstrap-rails.html | Bootstrap front-end framework | 29 | | "rails-foundation":https://github.com/RailsApps/rails-foundation | "Rails and Foundation":http://railsapps.github.io/rails-foundation.html | Foundation front-end framework | 30 | | "rails-mailinglist-activejob":https://github.com/RailsApps/rails-mailinglist-activejob | "Mailing List with Active Job Tutorial":https://tutorials.railsapps.org/ | sign up for a mailing list using background processing | 31 | | "rails-omniauth":https://github.com/RailsApps/rails-omniauth | "OmniAuth Tutorial":https://tutorials.railsapps.org/ | authentication with OmniAuth | 32 | | "rails-devise":https://github.com/RailsApps/rails-devise | "Rails Devise Tutorial":https://tutorials.railsapps.org/ | authentication with Devise | 33 | | "rails-devise-roles":https://github.com/RailsApps/rails-devise-roles | "Role-Based Authorization":https://tutorials.railsapps.org/ | authorization with roles | 34 | | "rails-devise-pundit":https://github.com/RailsApps/rails-devise-pundit | "Rails Pundit Tutorial":https://tutorials.railsapps.org/ | authorization with Pundit | 35 | | "rails-signup-download":https://github.com/RailsApps/rails-signup-download | "Rails Signup Download":https://tutorials.railsapps.org/ | Devise plus download a PDF file | 36 | | "rails-stripe-checkout":https://github.com/RailsApps/rails-stripe-checkout | "Stripe Checkout":https://tutorials.railsapps.org/ | selling a product with Stripe Checkout | 37 | | "rails-stripe-coupons":https://github.com/RailsApps/rails-stripe-coupons | "Stripe JS With Coupons":https://tutorials.railsapps.org/ | complex Rails and Stripe integration | 38 | 39 | h4. The rails_apps_composer Gem 40 | 41 | Do you want to customize the Rails Composer application template? The Rails Composer application template is built from recipes provided by the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem. 42 | 43 | h4. If You Are New to Rails 44 | 45 | If you're new to Rails, see "What is Ruby on Rails?":http://railsapps.github.io/what-is-ruby-rails.html, the book "Learn Ruby on Rails":http://learn-rails.com/learn-ruby-on-rails.html, and recommendations for a "Rails tutorial":https://tutorials.railsapps.org/rails-tutorial. 46 | 47 | h2. Dependencies 48 | 49 | Before running the Rails Composer tool, you need to install: 50 | 51 | * The Ruby language 52 | * Rails 53 | 54 | Check that appropriate versions of Ruby and Rails are installed in your development environment: 55 | @$ ruby -v@ 56 | @$ rails -v@ 57 | 58 | Be sure to read the article "Installing Rails":http://railsapps.github.io/installing-rails.html to make sure your development environment is set up properly. 59 | 60 | h2. How To Use Rails Composer 61 | 62 | To build a Rails application using the Rails Composer tool: 63 | 64 |
 65 | $ rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
 66 | 
67 | 68 | Replace @myapp@ with the name of your application. 69 | 70 | The @$@ character indicates a shell prompt; don't include it when you run the command. 71 | 72 | See the "Troubleshooting" section below if you see errors. In general, you'll avoid problems if you create your application using RVM as described in the next section. 73 | 74 | h3. Creating a Starter App Using RVM 75 | 76 | I recommend using "RVM":https://rvm.io/, the Ruby Version Manager, to manage your Rails versions, as described in the "Installing Rails":http://railsapps.github.io/installing-rails.html article. 77 | 78 | Here's how to generate a new Rails application using the Rails Composer tool and RVM: 79 | 80 |
 81 | $ mkdir myapp
 82 | $ cd myapp
 83 | $ rvm use ruby-2.4.0@myapp --ruby-version --create
 84 | $ gem install rails
 85 | $ rails new . -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
 86 | 
87 | 88 | Instead of installing Rails into the global gemset and running @rails new@, we'll create a root directory for a new application, create a new gemset, install Rails, and then generate a starter application. 89 | 90 | When we create the gemset, the option "--ruby-version" creates *.ruby-version* and *.ruby-gemset* files in the root directory. RVM recognizes these files in an application's root directory and loads the required version of Ruby and the correct gemset whenever you enter the directory. 91 | 92 | When we create the gemset, it will be empty (though it inherits use of all the gems in the global gemset). We immediately install Rails. The command @gem install rails@ installs the most recent stable release of Rails. 93 | 94 | Finally we run @rails new .@. We use the Unix "dot" convention to refer to the current directory. This assigns the name of the directory to the new application. 95 | 96 | This approach is different from the way most beginners are taught to create a Rails application. Our approach makes it easy to create a project-specific gemset to avoid clashes between gem versions when using the Rails Composer tool. 97 | 98 | h2. Choose a RailsApps Starter Application 99 | 100 | Use Rails Composer to generate any of the example applications from the "RailsApps project":http://railsapps.github.io/. You'll be able to choose your own project name when you generate the app. Generating the application gives you additional options. 101 | 102 | To build the example application, Rails must be installed in your development environment. 103 | 104 | You'll see a prompt: 105 | 106 |
107 | option  Build a starter application?
108 |     1)  Build a RailsApps example application
109 |     2)  Contributed applications
110 |     3)  Custom application
111 | 
112 | 113 | Enter "1" to select *Build a starter application*. You'll see a prompt: 114 | 115 |
116 | option  Choose a starter application.
117 |     1)  learn-rails
118 |     2)  rails-bootstrap
119 |     3)  rails-foundation
120 |     4)  rails-mailinglist-activejob
121 |     5)  rails-omniauth
122 |     6)  rails-devise
123 |     7)  rails-devise-roles
124 |     8)  rails-devise-pundit
125 |     9)  rails-signup-download
126 |    10)  rails-stripe-checkout
127 |    11)  rails-stripe-coupons
128 | 
129 | 130 | Each of these applications is available as an example in the "RailsApps GitHub repo":https://github.com/RailsApps and each is accompanied by a tutorial on the "Capstone Rails Tutorials":https://tutorials.railsapps.org/ site. 131 | 132 | Make your choice. The Rails Composer tool may give you other options (other applications may have been added since these notes were written). 133 | 134 | h4. Options 135 | 136 | The application generator template will ask you for additional preferences. Options vary, depending on the example application you build. Options may have changed in a newer version of Rails Composer. 137 | 138 |
139 |  option  Web server for development?
140 |        1)  WEBrick (default)
141 |        2)  Thin
142 |        3)  Unicorn
143 |        4)  Puma
144 |        5)  Phusion Passenger (Apache/Nginx)
145 |        6)  Phusion Passenger (Standalone)
146 |  option  Web server for production?
147 |        1)  Same as development
148 |        2)  Thin
149 |        3)  Unicorn
150 |        4)  Puma
151 |        5)  Phusion Passenger (Apache/Nginx)
152 |        6)  Phusion Passenger (Standalone)
153 |  option  Database used in development?
154 |        1)  SQLite
155 |        2)  PostgreSQL
156 |        3)  MySQL
157 |  option  Template engine?
158 |        1)  ERB
159 |        2)  Haml
160 |        3)  Slim
161 |  option  Test framework?
162 |        1)  None
163 |        2)  RSpec with Capybara
164 |  option  Front-end framework?
165 |        1)  None
166 |        2)  Bootstrap 3.0
167 |        3)  Bootstrap 2.3
168 |        4)  Zurb Foundation 5.0
169 |        5)  Zurb Foundation 4.0
170 |        6)  Simple CSS
171 |  option  Install page-view analytics?
172 |        1)  None
173 |        2)  Google Analytics
174 |        3)  Segment.io
175 |    extras  Set a robots.txt file to ban spiders? (y/n)
176 |    extras  Create a GitHub repository? (y/n)
177 |    extras  Use or create a project-specific rvm gemset? (y/n)
178 | 
179 | 180 | h4. Web Servers 181 | 182 | If you plan to deploy to Heroku, select Puma as your production webserver. Puma is recommended by Heroku. 183 | 184 | h4. Database 185 | 186 | Choose "SQLite" for the easiest setup. If you choose PostgreSQL or MySQL, the databases must be installed and running before you run Rails Composer. 187 | 188 | h4. Template Engine 189 | 190 | The example applications use the default "ERB" Rails template engine. Optionally, you can use another template engine, such as Haml or Slim. See instructions for "Haml and Rails":http://railsapps.github.io/rails-haml.html. 191 | 192 | h4. Testing 193 | 194 | If you are a beginner, select "None." Select "RSpec with Capybara" if you want tests. 195 | 196 | h4. Front-end Framework 197 | 198 | If you choose a front-end framework, you'll get an application layout file, plus navigation and flash messages, styled with a default theme. 199 | 200 | h4. Other Choices 201 | 202 | Set a robots.txt file to ban spiders if you want to keep your new site out of Google search results. 203 | 204 | If you choose to create a GitHub repository, the generator will prompt you for a GitHub username and password. 205 | 206 | It is a good idea to use "RVM":https://rvm.io/, the Ruby Version Manager, and create a project-specific rvm gemset (not available on Windows). See "Installing Rails":http://railsapps.github.io/installing-rails.html. 207 | 208 | h2. Contributed Applications 209 | 210 | Currently, there are no contributed applications available. If you would like to add your favorite starter application to Rails Composer, open an issue to let us know. 211 | 212 | h2. Build Your Own Application 213 | 214 | If you choose "Custom application," you will get a wide set of choices. Not all are actively supported. 215 | 216 | A large community of developers contributes code that supports additional gems and favorite configurations offered with the "build your own options." However, not all contributions are actively maintained. That means not all options are tested or fully supported, so you may need to spend time debugging a "build your own application." 217 | 218 | When you choose "Custom application," you will see something similar to this: 219 | 220 |
221 | option  Build a starter application?
222 |       1)  Build a RailsApps example application
223 |       2)  Contributed applications
224 |       3)  Custom application
225 | 
226 | option  Web server for development?
227 |       1)  WEBrick (default)
228 |       2)  Thin
229 |       3)  Unicorn
230 |       4)  Puma
231 |       5)  Phusion Passenger (Apache/Nginx)
232 |       6)  Phusion Passenger (Standalone)
233 | 
234 | option  Web server for production?
235 |       1)  Same as development
236 |       2)  Thin
237 |       3)  Unicorn
238 |       4)  Puma
239 |       5)  Phusion Passenger (Apache/Nginx)
240 |       6)  Phusion Passenger (Standalone)
241 | 
242 | option  Database used in development?
243 |       1)  SQLite
244 |       2)  PostgreSQL
245 |       3)  MySQL
246 | 
247 | option  Template engine?
248 |       1)  ERB
249 |       2)  Haml
250 |       3)  Slim
251 | 
252 | option  Test framework?
253 |       1)  None
254 |       2)  RSpec with Capybara
255 | 
256 | option  Continuous testing?
257 |       1)  None
258 |       2)  Guard
259 | 
260 | option  Front-end framework?
261 |       1)  None
262 |       2)  Bootstrap 3.0
263 |       3)  Bootstrap 2.3
264 |       4)  Zurb Foundation 5.0
265 |       5)  Zurb Foundation 4.0
266 |       6)  Simple CSS
267 | 
268 | option  Add support for sending email?
269 |       1)  None
270 |       2)  Gmail
271 |       3)  SMTP
272 |       4)  SendGrid
273 |       5)  Mandrill
274 | 
275 | option  Authentication?
276 |       1)  None
277 |       2)  Devise
278 |       3)  OmniAuth
279 | 
280 | option  Devise modules?
281 |       1)  Devise with default modules
282 |       2)  Devise with Confirmable module
283 | 
284 | option  Authorization?
285 |       1)  None
286 |       2)  Pundit
287 | 
288 | option  Use a form builder gem?
289 |       1)  None
290 |       2)  SimpleForm
291 | 
292 | option  Install a starter app?
293 |       1)  None
294 |       2)  Home Page
295 |       3)  Home Page, User Accounts
296 |       4)  Home Page, User Accounts, Admin Dashboard
297 | 
298 | extras  Add 'therubyracer' JavaScript runtime (for Linux users without node.js)? (y/n)
299 | extras  Set a robots.txt file to ban spiders? (y/n)
300 | extras  Create a GitHub repository? (y/n)
301 | 
302 | option  Add gem and file for environment variables?
303 |       1)  None
304 |       2)  Add .env with Foreman
305 |       3)  Add application.yml with Figaro
306 | 
307 | extras  Reduce assets logger noise during development? (y/n)
308 | extras  Improve error reporting with 'better_errors' during development? (y/n)
309 | extras  Use 'pry' as console replacement during development and test? (y/n)
310 | extras  Use or create a project-specific rvm gemset? (y/n)
311 | 
312 | option  Add a deployment mechanism?
313 |       1)  None
314 |       2)  Capistrano3
315 | 
316 | 317 | h2. Run the Application 318 | 319 | Switch to the application directory to examine and test what you've built. 320 | 321 |
322 | $ cd myapp
323 | 
324 | 325 | h4. Quick Test 326 | 327 | For a "smoke test" to see if everything runs, display a list of Rake tasks. 328 | 329 |
330 | $ rake -T
331 | 
332 | 333 | There's no need to run @bundle exec rake@ instead of @rake@ when you are using rvm (see "rvm and bundler integration":https://rvm.io/integration/bundler/). 334 | 335 | h4. Start the Web Server 336 | 337 | If you've chosen WEBrick or Thin for your web server, can run the app by entering the command: 338 | 339 | @$ rails server@ 340 | 341 | To see your application in action, open a browser window and navigate to "http://localhost:3000/":http://localhost:3000. 342 | 343 | For the Unicorn web server: 344 | 345 | @$ unicorn@ 346 | 347 | See the app at "http://localhost:8080/":http://localhost:8080. 348 | 349 | For the Puma web server: 350 | 351 | @$ rails server puma@ 352 | 353 | See the app at "http://localhost:3000/":http://localhost:3000. 354 | 355 | For Phusion Passenger (Apache or Nginx integration mode), please refer to "the official documentation":https://www.phusionpassenger.com/documentation_and_support. 356 | 357 | For Phusion Passenger (Standalone): 358 | 359 | @$ passenger start@ 360 | 361 | h4. Login 362 | 363 | If you've created a version of the application that sets up a default user, log in with: 364 | 365 | * email: user@example.com 366 | * password: changeme 367 | 368 | You should delete or change any pre-configured logins before you deploy your application. 369 | 370 | h2. Testing 371 | 372 | Some versions of the starter application will contain a suite of RSpec feature and unit tests. 373 | 374 | Run @rspec@ to run all RSpec tests. 375 | 376 | Please send the author a message, create an issue, or submit a pull request if you want to contribute improved RSpec tests. 377 | 378 | h2. Deployment 379 | 380 | For easy deployment, use a “platform as a service” provider such as: 381 | 382 | * "Heroku":http://www.heroku.com/ 383 | * "CloudFoundry":http://www.cloudfoundry.com/ 384 | * "EngineYard":http://www.engineyard.com/ 385 | * "OpenShift":https://openshift.redhat.com/app/ 386 | 387 | For deployment on Heroku, see the article: 388 | 389 | * "Rails on Heroku":http://railsapps.github.io/rails-heroku-tutorial.html 390 | 391 | h2. Troubleshooting 392 | 393 | Problems? Please check both "issues for the Rails Composer tool":https://github.com/RailsApps/rails-composer/issues and the "issues for the rails_apps_composer gem":https://github.com/RailsApps/rails_apps_composer/issues. 394 | 395 | You should review the article "Installing Rails":http://railsapps.github.io/installing-rails.html to make sure you've updated all the components that are required to run Rails successfully. 396 | 397 | h4. Problems with "Could not be loaded... You have already activated..." 398 | 399 | If you get an error like this: 400 | 401 |
402 | Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
403 |     composer  Running 'after bundler' callbacks.
404 | The template [...] could not be loaded.
405 | Error: You have already activated ..., but your Gemfile requires ....
406 | Using bundle exec may solve this.
407 | 
408 | 409 | It's due to conflicting gem versions. See the article "Rails Error: “You have already activated (…)”":http://railsapps.github.io/rails-error-you-have-already-activated.html. 410 | 411 | h4. Problems with "Certificate Verify Failed" 412 | 413 | 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.io/openssl-certificate-verify-failed.html. 414 | 415 | h4. Problems with "Segmentation Fault" 416 | 417 | If you get a "segfault" when you try @rails new@, try removing and reinstalling rvm. 418 | 419 | h2. Application Template Default 420 | 421 | The @rails new@ command creates a new Rails application. If you want to use the Rails Composer application 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 the template when you create a new Rails application: 422 | 423 |
424 | # ~/.railsrc
425 | -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
426 | 
427 | 428 | h2. Documentation and Support 429 | 430 | The Rails Composer application template is 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 Rails Composer application works. 431 | 432 | h4. Customizing the Template 433 | 434 | If you wish to change the 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. 435 | 436 | h4. Writing Recipes 437 | 438 | 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. A big thanks to Yehuda Katz for "creating Thor":http://yehudakatz.com/2008/05/12/by-thors-hammer/. 439 | 440 | h4. About Rails Application Templates 441 | 442 | There is an unfinished Rails Guide on "Rails Application Templates":https://github.com/rails/rails/blob/master/guides/source/rails_application_templates.md. 443 | 444 | Also see: 445 | 446 | "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 447 | "Rails Application Templates (16 Sept 2010) by Collin Schaafsma":http://quickleft.com/blog/rails-application-templates 448 | "Application templates in Rails 3 (18 Sept 2009) by Ben Scofield":http://benscofield.com/2009/09/application-templates-in-rails-3/ 449 | "Railscasts: App Templates in Rails 2.3 (9 Feb 2009) by Ryan Bates":http://railscasts.com/episodes/148-app-templates-in-rails-2-3 450 | "Rails templates (4 Dec 2008) by Pratik Naik":http://m.onkey.org/rails-templates 451 | 452 | h4. Similar Projects 453 | 454 | There are many similar projects: 455 | 456 | * "Rails application template projects":http://railsapps.github.io/rails-application-templates.html 457 | * "Rails examples, tutorials, and starter apps":http://railsapps.github.io/rails-examples-tutorials.html. 458 | 459 | h4. Issues 460 | 461 | Problems? Please check both "issues for the Rails Composer tool":https://github.com/RailsApps/rails-composer/issues and the "issues for the rails_apps_composer gem":https://github.com/RailsApps/rails_apps_composer/issues. 462 | 463 | h4. Where to Get Help 464 | 465 | Your best source for help with problems is "Stack Overflow":http://stackoverflow.com/questions/tagged/railsapps. Your issue may have been encountered and addressed by others. 466 | 467 | Use the tag "railsapps" on Stack Overflow for extra attention. 468 | 469 | h2. Contributing 470 | 471 | Please make changes to the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem rather than changing the Rails Composer application template. 472 | 473 | h2. Credits 474 | 475 | Daniel Kehoe initiated the "RailsApps project":https://github.com/RailsApps. The "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem is derived from Michael Bleigh’s RailsWizard gem. 476 | 477 | Is it useful to you? Follow the project on Twitter: 478 | "@rails_apps":http://twitter.com/rails_apps 479 | and tweet some praise. I'd love to know you were helped out by what I've put together. 480 | 481 | h2. License 482 | 483 | "MIT License":http://www.opensource.org/licenses/mit-license 484 | 485 | Copyright 2012-14 Daniel Kehoe 486 | 487 | h2. Useful Links 488 | 489 | |_. Getting Started |_. Articles |_. Tutorials | 490 | | "Ruby on Rails":http://railsapps.github.io/ruby-and-rails.html | "Analytics for Rails":http://railsapps.github.io/rails-google-analytics.html | "Rails Bootstrap":http://railsapps.github.io/twitter-bootstrap-rails.html | 491 | | "What is Ruby on Rails?":http://railsapps.github.io/what-is-ruby-rails.html | "Heroku and Rails":http://railsapps.github.io/rails-heroku-tutorial.html | "Rails Foundation":http://railsapps.github.io/rails-foundation.html | 492 | | "Learn Ruby on Rails":http://learn-rails.com/learn-ruby-on-rails.html | "JavaScript and Rails":http://railsapps.github.io/rails-javascript-include-external.html | "RSpec Tutorial":http://railsapps.github.io/rspec.html | 493 | | "Rails Tutorial":https://tutorials.railsapps.org/rails-tutorial | "Rails Environment Variables":http://railsapps.github.io/rails-environment-variables.html | "Rails Devise Tutorial":http://railsapps.github.io/tutorial-rails-devise.html | 494 | | "Ruby on Rails Tutorial for Beginners":http://learn-rails.com/ruby-on-rails-tutorial-for-beginners | "Git and GitHub with Rails":http://railsapps.github.io/rails-git.html | "Devise RSpec":http://railsapps.github.io/tutorial-rails-devise-rspec-cucumber.html | 495 | | "Install Ruby on Rails":http://railsapps.github.io/installing-rails.html | "Send Email with Rails":http://railsapps.github.io/rails-send-email.html | "Devise Bootstrap":http://railsapps.github.io/tutorial-rails-bootstrap-devise-cancan.html | 496 | | "Install Ruby on Rails - Mac OS X":http://railsapps.github.io/installrubyonrails-mac.html | "Haml and Rails":http://railsapps.github.io/rails-haml.html | "Rails Membership Site with Stripe":https://tutorials.railsapps.org/rails-stripe-membership-saas | 497 | | "Install Ruby on Rails - Ubuntu":http://railsapps.github.io/installrubyonrails-ubuntu.html | "Rails Application Layout":http://railsapps.github.io/rails-default-application-layout.html | "Rails Subscription Site with Recurly":https://tutorials.railsapps.org/rails-recurly-subscription-saas | 498 | | "Ruby on Rails - Nitrous.io":http://railsapps.github.io/rubyonrails-nitrous-io.html | "HTML5 Boilerplate for Rails":http://railsapps.github.io/rails-html5-boilerplate.html | "Startup Prelaunch Signup Application":https://tutorials.railsapps.org/rails-prelaunch-signup | 499 | | "Update Rails":http://railsapps.github.io/updating-rails.html | "Example Gemfiles for Rails":http://railsapps.github.io/rails-3-2-example-gemfile.html | 500 | | "Rails Composer":http://railsapps.github.io/rails-composer/ | "Rails Application Templates":http://railsapps.github.io/rails-application-templates.html | 501 | | "Rails Examples":http://railsapps.github.io/ | "Rails Product Planning":http://railsapps.github.io/rails-product-planning.html | 502 | | "Rails Starter Apps":http://railsapps.github.io/rails-examples-tutorials.html | "Rails Project Management":http://railsapps.github.io/rails-project-management.html | 503 | -------------------------------------------------------------------------------- /composer.rb: -------------------------------------------------------------------------------- 1 | # >---------------------------------------------------------------------------< 2 | # 3 | # _____ _ _ 4 | # | __ \ (_) | /\ 5 | # | |__) |__ _ _| |___ / \ _ __ _ __ ___ 6 | # | _ // _` | | / __| / /\ \ | '_ \| '_ \/ __| 7 | # | | \ \ (_| | | \__ \/ ____ \| |_) | |_) \__ \ 8 | # |_| \_\__,_|_|_|___/_/ \_\ .__/| .__/|___/ 9 | # | | | | 10 | # |_| |_| 11 | # 12 | # Application template generated by the rails_apps_composer gem. 13 | # Restrain your impulse to make changes to this file; instead, 14 | # make changes to the recipes in the rails_apps_composer gem. 15 | # 16 | # For more information, see: 17 | # https://github.com/RailsApps/rails_apps_composer/ 18 | # 19 | # Thank you to Michael Bleigh for leading the way with the RailsWizard gem. 20 | # 21 | # >---------------------------------------------------------------------------< 22 | 23 | # >----------------------------[ Initial Setup ]------------------------------< 24 | 25 | module Gemfile 26 | class GemInfo 27 | def initialize(name) @name=name; @group=[]; @opts={}; end 28 | attr_accessor :name, :version 29 | attr_reader :group, :opts 30 | 31 | def opts=(new_opts={}) 32 | new_group = new_opts.delete(:group) 33 | if (new_group && self.group != new_group) 34 | @group = ([self.group].flatten + [new_group].flatten).compact.uniq.sort 35 | end 36 | @opts = (self.opts || {}).merge(new_opts) 37 | end 38 | 39 | def group_key() @group end 40 | 41 | def gem_args_string 42 | args = ["'#{@name}'"] 43 | args << "'#{@version}'" if @version 44 | @opts.each do |name,value| 45 | args << ":#{name}=>#{value.inspect}" 46 | end 47 | args.join(', ') 48 | end 49 | end 50 | 51 | @geminfo = {} 52 | 53 | class << self 54 | # add(name, version, opts={}) 55 | def add(name, *args) 56 | name = name.to_s 57 | version = args.first && !args.first.is_a?(Hash) ? args.shift : nil 58 | opts = args.first && args.first.is_a?(Hash) ? args.shift : {} 59 | @geminfo[name] = (@geminfo[name] || GemInfo.new(name)).tap do |info| 60 | info.version = version if version 61 | info.opts = opts 62 | end 63 | end 64 | 65 | def write 66 | File.open('Gemfile', 'a') do |file| 67 | file.puts 68 | grouped_gem_names.sort.each do |group, gem_names| 69 | indent = "" 70 | unless group.empty? 71 | file.puts "group :#{group.join(', :')} do" unless group.empty? 72 | indent=" " 73 | end 74 | gem_names.sort.each do |gem_name| 75 | file.puts "#{indent}gem #{@geminfo[gem_name].gem_args_string}" 76 | end 77 | file.puts "end" unless group.empty? 78 | file.puts 79 | end 80 | end 81 | end 82 | 83 | private 84 | #returns {group=>[...gem names...]}, ie {[:development, :test]=>['rspec-rails', 'mocha'], :assets=>[], ...} 85 | def grouped_gem_names 86 | {}.tap do |_groups| 87 | @geminfo.each do |gem_name, geminfo| 88 | (_groups[geminfo.group_key] ||= []).push(gem_name) 89 | end 90 | end 91 | end 92 | end 93 | end 94 | def add_gem(*all) Gemfile.add(*all); end 95 | 96 | @recipes = ["core", "git", "railsapps", "learn_rails", "rails_bootstrap", "rails_foundation", "rails_omniauth", "rails_devise", "rails_devise_roles", "rails_devise_pundit", "rails_shortcut_app", "rails_signup_download", "rails_signup_thankyou", "rails_mailinglist_activejob", "rails_stripe_checkout", "rails_stripe_coupons", "rails_stripe_membership_saas", "setup", "locale", "readme", "gems", "tests", "email", "devise", "omniauth", "roles", "frontend", "pages", "init", "analytics", "deployment", "extras"] 97 | @prefs = {} 98 | @gems = [] 99 | @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"], ["email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["core", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["core", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["core", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["email", "example", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["email", "example", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["email", "example", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["apps4", "core", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["apps4", "core", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "tests"], ["apps4", "core", "deployment", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["apps4", "core", "deployment", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "tests"], ["apps4", "core", "deployment", "devise", "email", "extras", "frontend", "gems", "git", "init", "omniauth", "pundit", "railsapps", "readme", "setup", "tests"]] 100 | @diagnostics_prefs = [] 101 | diagnostics = {} 102 | 103 | # >-------------------------- templates/helpers.erb --------------------------start< 104 | def recipes; @recipes end 105 | def recipe?(name); @recipes.include?(name) end 106 | def prefs; @prefs end 107 | def prefer(key, value); @prefs[key].eql? value end 108 | def gems; @gems end 109 | def diagnostics_recipes; @diagnostics_recipes end 110 | def diagnostics_prefs; @diagnostics_prefs end 111 | 112 | def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m" + " #{text}" end 113 | def say_loud(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + " #{text}" + "\033[0m" end 114 | def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end 115 | def say_wizard(text); say_custom(@current_recipe || 'composer', text) end 116 | 117 | def ask_wizard(question) 118 | ask "\033[1m\033[36m" + ("option").rjust(10) + "\033[1m\033[36m" + " #{question}\033[0m" 119 | end 120 | 121 | def whisper_ask_wizard(question) 122 | ask "\033[1m\033[36m" + ("choose").rjust(10) + "\033[0m" + " #{question}" 123 | end 124 | 125 | def yes_wizard?(question) 126 | answer = ask_wizard(question + " \033[33m(y/n)\033[0m") 127 | case answer.downcase 128 | when "yes", "y" 129 | true 130 | when "no", "n" 131 | false 132 | else 133 | yes_wizard?(question) 134 | end 135 | end 136 | 137 | def no_wizard?(question); !yes_wizard?(question) end 138 | 139 | def multiple_choice(question, choices) 140 | say_custom('option', "\033[1m\033[36m" + "#{question}\033[0m") 141 | values = {} 142 | choices.each_with_index do |choice,i| 143 | values[(i + 1).to_s] = choice[1] 144 | say_custom( (i + 1).to_s + ')', choice[0] ) 145 | end 146 | answer = whisper_ask_wizard("Enter your selection:") while !values.keys.include?(answer) 147 | values[answer] 148 | end 149 | 150 | @current_recipe = nil 151 | @configs = {} 152 | 153 | @after_blocks = [] 154 | def stage_two(&block); @after_blocks << [@current_recipe, block]; end 155 | @stage_three_blocks = [] 156 | def stage_three(&block); @stage_three_blocks << [@current_recipe, block]; end 157 | @stage_four_blocks = [] 158 | def stage_four(&block); @stage_four_blocks << [@current_recipe, block]; end 159 | @before_configs = {} 160 | def before_config(&block); @before_configs[@current_recipe] = block; end 161 | 162 | def copy_from(source, destination) 163 | begin 164 | remove_file destination 165 | get source, destination 166 | rescue OpenURI::HTTPError 167 | say_wizard "Unable to obtain #{source}" 168 | end 169 | end 170 | 171 | def copy_from_repo(filename, opts = {}) 172 | repo = 'https://raw.github.com/RailsApps/rails-composer/master/files/' 173 | repo = opts[:repo] unless opts[:repo].nil? 174 | if (!opts[:prefs].nil?) && (!prefs.has_value? opts[:prefs]) 175 | return 176 | end 177 | source_filename = filename 178 | destination_filename = filename 179 | unless opts[:prefs].nil? 180 | if filename.include? opts[:prefs] 181 | destination_filename = filename.gsub(/\-#{opts[:prefs]}/, '') 182 | end 183 | end 184 | if (prefer :templates, 'haml') && (filename.include? 'views') 185 | remove_file destination_filename 186 | destination_filename = destination_filename.gsub(/.erb/, '.haml') 187 | end 188 | if (prefer :templates, 'slim') && (filename.include? 'views') 189 | remove_file destination_filename 190 | destination_filename = destination_filename.gsub(/.erb/, '.slim') 191 | end 192 | begin 193 | remove_file destination_filename 194 | if (prefer :templates, 'haml') && (filename.include? 'views') 195 | create_file destination_filename, html_to_haml(repo + source_filename) 196 | elsif (prefer :templates, 'slim') && (filename.include? 'views') 197 | create_file destination_filename, html_to_slim(repo + source_filename) 198 | else 199 | get repo + source_filename, destination_filename 200 | end 201 | rescue OpenURI::HTTPError 202 | say_wizard "Unable to obtain #{source_filename} from the repo #{repo}" 203 | end 204 | end 205 | 206 | def html_to_haml(source) 207 | begin 208 | html = open(source) {|input| input.binmode.read } 209 | Html2haml::HTML.new(html, :erb => true, :xhtml => true).render 210 | rescue RubyParser::SyntaxError 211 | say_wizard "Ignoring RubyParser::SyntaxError" 212 | # special case to accommodate https://github.com/RailsApps/rails-composer/issues/55 213 | html = open(source) {|input| input.binmode.read } 214 | say_wizard "applying patch" if html.include? 'card_month' 215 | say_wizard "applying patch" if html.include? 'card_year' 216 | html = html.gsub(/, {add_month_numbers: true}, {name: nil, id: "card_month"}/, '') 217 | html = html.gsub(/, {start_year: Date\.today\.year, end_year: Date\.today\.year\+10}, {name: nil, id: "card_year"}/, '') 218 | result = Html2haml::HTML.new(html, :erb => true, :xhtml => true).render 219 | result = result.gsub(/select_month nil/, "select_month nil, {add_month_numbers: true}, {name: nil, id: \"card_month\"}") 220 | result = result.gsub(/select_year nil/, "select_year nil, {start_year: Date.today.year, end_year: Date.today.year+10}, {name: nil, id: \"card_year\"}") 221 | end 222 | end 223 | 224 | def html_to_slim(source) 225 | html = open(source) {|input| input.binmode.read } 226 | haml = Html2haml::HTML.new(html, :erb => true, :xhtml => true).render 227 | Haml2Slim.convert!(haml) 228 | end 229 | 230 | # full credit to @mislav in this StackOverflow answer for the #which() method: 231 | # - http://stackoverflow.com/a/5471032 232 | def which(cmd) 233 | exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] 234 | ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| 235 | exts.each do |ext| 236 | exe = "#{path}#{File::SEPARATOR}#{cmd}#{ext}" 237 | return exe if File.executable? exe 238 | end 239 | end 240 | return nil 241 | end 242 | # >-------------------------- templates/helpers.erb --------------------------end< 243 | 244 | say_wizard("\033[1m\033[36m" + "" + "\033[0m") 245 | 246 | say_wizard("\033[1m\033[36m" + ' _____ _ _' + "\033[0m") 247 | say_wizard("\033[1m\033[36m" + "| __ \\ \(_\) | /\\" + "\033[0m") 248 | say_wizard("\033[1m\033[36m" + "| |__) |__ _ _| |___ / \\ _ __ _ __ ___" + "\033[0m") 249 | say_wizard("\033[1m\033[36m" + "| _ /\/ _` | | / __| / /\\ \\ | \'_ \| \'_ \\/ __|" + "\033[0m") 250 | say_wizard("\033[1m\033[36m" + "| | \\ \\ (_| | | \\__ \\/ ____ \\| |_) | |_) \\__ \\" + "\033[0m") 251 | say_wizard("\033[1m\033[36m" + "|_| \\_\\__,_|_|_|___/_/ \\_\\ .__/| .__/|___/" + "\033[0m") 252 | say_wizard("\033[1m\033[36m" + " \| \| \| \|" + "\033[0m") 253 | say_wizard("\033[1m\033[36m" + " \| \| \| \|" + "\033[0m") 254 | say_wizard("\033[1m\033[36m" + '' + "\033[0m") 255 | say_wizard("Need help? Ask on Stack Overflow with the tag \'railsapps.\'") 256 | say_wizard("Your new application will contain diagnostics in its README file.") 257 | 258 | if diagnostics_recipes.sort.include? recipes.sort 259 | diagnostics[:recipes] = 'success' 260 | else 261 | diagnostics[:recipes] = 'fail' 262 | end 263 | 264 | # this application template only supports Rails version 4.1 and newer 265 | case Rails::VERSION::MAJOR.to_s 266 | when "5" 267 | say_wizard "You are using Rails version #{Rails::VERSION::STRING}. Please report any issues." 268 | when "3" 269 | say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer." 270 | raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer." 271 | when "4" 272 | case Rails::VERSION::MINOR.to_s 273 | when "0" 274 | say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer." 275 | raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer." 276 | end 277 | else 278 | say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer." 279 | raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer." 280 | end 281 | 282 | # >---------------------------[ Autoload Modules/Classes ]-----------------------------< 283 | 284 | inject_into_file 'config/application.rb', :after => 'config.autoload_paths += %W(#{config.root}/extras)' do <<-'RUBY' 285 | 286 | config.autoload_paths += %W(#{config.root}/lib) 287 | RUBY 288 | end 289 | 290 | # >---------------------------------[ Recipes ]----------------------------------< 291 | 292 | # >-------------------------- templates/recipe.erb ---------------------------start< 293 | # >---------------------------------[ core ]----------------------------------< 294 | @current_recipe = "core" 295 | @before_configs["core"].call if @before_configs["core"] 296 | say_recipe 'core' 297 | @configs[@current_recipe] = config 298 | # >----------------------------- recipes/core.rb -----------------------------start< 299 | 300 | # Application template recipe for the rails_apps_composer. Change the recipe here: 301 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/core.rb 302 | 303 | ## Git 304 | say_wizard "selected all core recipes" 305 | # >----------------------------- recipes/core.rb -----------------------------end< 306 | # >-------------------------- templates/recipe.erb ---------------------------end< 307 | 308 | # >-------------------------- templates/recipe.erb ---------------------------start< 309 | # >----------------------------------[ git ]----------------------------------< 310 | @current_recipe = "git" 311 | @before_configs["git"].call if @before_configs["git"] 312 | say_recipe 'git' 313 | @configs[@current_recipe] = config 314 | # >----------------------------- recipes/git.rb ------------------------------start< 315 | 316 | # Application template recipe for the rails_apps_composer. Change the recipe here: 317 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/git.rb 318 | 319 | ## Git 320 | say_wizard "initialize git" 321 | prefs[:git] = true unless prefs.has_key? :git 322 | if prefer :git, true 323 | copy_from 'https://raw.github.com/RailsApps/rails-composer/master/files/gitignore.txt', '.gitignore' 324 | git :init 325 | git :add => '-A' 326 | git :commit => '-qm "rails_apps_composer: initial commit"' 327 | else 328 | stage_three do 329 | say_wizard "recipe stage three" 330 | say_wizard "removing .gitignore and .gitkeep files" 331 | git_files = Dir[File.join('**','.gitkeep')] + Dir[File.join('**','.gitignore')] 332 | File.unlink git_files 333 | end 334 | end 335 | # >----------------------------- recipes/git.rb ------------------------------end< 336 | # >-------------------------- templates/recipe.erb ---------------------------end< 337 | 338 | # >-------------------------- templates/recipe.erb ---------------------------start< 339 | # >-------------------------------[ railsapps ]-------------------------------< 340 | @current_recipe = "railsapps" 341 | @before_configs["railsapps"].call if @before_configs["railsapps"] 342 | say_recipe 'railsapps' 343 | @configs[@current_recipe] = config 344 | # >-------------------------- recipes/railsapps.rb ---------------------------start< 345 | 346 | # Application template recipe for the rails_apps_composer. Change the recipe here: 347 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/railsapps.rb 348 | 349 | raise if (defined? defaults) || (defined? preferences) # Shouldn't happen. 350 | if options[:verbose] 351 | print "\nrecipes: ";p recipes 352 | print "\ngems: " ;p gems 353 | print "\nprefs: " ;p prefs 354 | print "\nconfig: " ;p config 355 | end 356 | 357 | case Rails::VERSION::MAJOR.to_s 358 | when "5" 359 | prefs[:apps4] = multiple_choice "Build a starter application?", 360 | [["Build a RailsApps example application", "railsapps"], 361 | ["Contributed applications", "contributed_app"], 362 | ["Custom application (experimental)", "none"]] unless prefs.has_key? :apps4 363 | case prefs[:apps4] 364 | when 'railsapps' 365 | prefs[:apps4] = multiple_choice "Choose a starter application.", 366 | [["learn-rails", "learn-rails"], 367 | ["rails-bootstrap", "rails-bootstrap"], 368 | ["rails-foundation", "rails-foundation"], 369 | ["rails-mailinglist-activejob", "rails-mailinglist-activejob"], 370 | ["rails-omniauth", "rails-omniauth"], 371 | ["rails-devise", "rails-devise"], 372 | ["rails-devise-roles", "rails-devise-roles"], 373 | ["rails-devise-pundit", "rails-devise-pundit"], 374 | ["rails-signup-download", "rails-signup-download"], 375 | ["rails-stripe-checkout", "rails-stripe-checkout"], 376 | ["rails-stripe-coupons", "rails-stripe-coupons"]] 377 | when 'contributed_app' 378 | prefs[:apps4] = multiple_choice "Choose a starter application.", 379 | [["rails-shortcut-app", "rails-shortcut-app"], 380 | ["rails-signup-thankyou", "rails-signup-thankyou"]] 381 | end 382 | when "3" 383 | say_wizard "Please upgrade to Rails 4.1 or newer." 384 | when "4" 385 | case Rails::VERSION::MINOR.to_s 386 | when "0" 387 | say_wizard "Please upgrade to Rails 4.1 or newer." 388 | else 389 | prefs[:apps4] = multiple_choice "Build a starter application?", 390 | [["Build a RailsApps example application", "railsapps"], 391 | ["Contributed applications (none available)", "contributed_app"], 392 | ["Custom application (experimental)", "none"]] unless prefs.has_key? :apps4 393 | case prefs[:apps4] 394 | when 'railsapps' 395 | case Rails::VERSION::MINOR.to_s 396 | when "2" 397 | prefs[:apps4] = multiple_choice "Choose a starter application.", 398 | [["learn-rails", "learn-rails"], 399 | ["rails-bootstrap", "rails-bootstrap"], 400 | ["rails-foundation", "rails-foundation"], 401 | ["rails-mailinglist-activejob", "rails-mailinglist-activejob"], 402 | ["rails-omniauth", "rails-omniauth"], 403 | ["rails-devise", "rails-devise"], 404 | ["rails-devise-roles", "rails-devise-roles"], 405 | ["rails-devise-pundit", "rails-devise-pundit"], 406 | ["rails-signup-download", "rails-signup-download"], 407 | ["rails-stripe-checkout", "rails-stripe-checkout"], 408 | ["rails-stripe-coupons", "rails-stripe-coupons"], 409 | ["rails-stripe-membership-saas", "rails-stripe-membership-saas"]] 410 | else 411 | prefs[:apps4] = multiple_choice "Upgrade to Rails 4.2 for more choices.", 412 | [["learn-rails", "learn-rails"], 413 | ["rails-bootstrap", "rails-bootstrap"], 414 | ["rails-foundation", "rails-foundation"], 415 | ["rails-omniauth", "rails-omniauth"], 416 | ["rails-devise", "rails-devise"], 417 | ["rails-devise-roles", "rails-devise-roles"], 418 | ["rails-devise-pundit", "rails-devise-pundit"]] 419 | end 420 | when 'contributed_app' 421 | prefs[:apps4] = multiple_choice "No contributed applications are available.", 422 | [["create custom application", "railsapps"]] 423 | end 424 | end 425 | end 426 | 427 | unless prefs[:announcements] 428 | say_loud '', 'Get on the mailing list for Rails Composer news?' 429 | prefs[:announcements] = ask_wizard('Enter your email address:') 430 | if prefs[:announcements].present? 431 | system "curl --silent http://mailinglist.railscomposer.com/api -d'visitor[email]=#{prefs[:announcements]}' > /dev/null" 432 | prefs[:announcements] = 'mailinglist' 433 | else 434 | prefs[:announcements] = 'none' 435 | end 436 | end 437 | # >-------------------------- recipes/railsapps.rb ---------------------------end< 438 | # >-------------------------- templates/recipe.erb ---------------------------end< 439 | 440 | # >-------------------------- templates/recipe.erb ---------------------------start< 441 | # >------------------------------[ learn_rails ]------------------------------< 442 | @current_recipe = "learn_rails" 443 | @before_configs["learn_rails"].call if @before_configs["learn_rails"] 444 | say_recipe 'learn_rails' 445 | @configs[@current_recipe] = config 446 | # >------------------------- recipes/learn_rails.rb --------------------------start< 447 | 448 | # Application template recipe for the rails_apps_composer. Change the recipe here: 449 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/learn_rails.rb 450 | 451 | if prefer :apps4, 'learn-rails' 452 | 453 | # preferences 454 | prefs[:authentication] = false 455 | prefs[:authorization] = false 456 | prefs[:dashboard] = 'none' 457 | prefs[:ban_spiders] = false 458 | prefs[:better_errors] = true 459 | prefs[:database] = 'sqlite' 460 | prefs[:deployment] = 'heroku' 461 | prefs[:devise_modules] = false 462 | prefs[:dev_webserver] = 'puma' 463 | prefs[:email] = 'sendgrid' 464 | prefs[:frontend] = 'bootstrap3' 465 | prefs[:layouts] = 'none' 466 | prefs[:pages] = 'none' 467 | prefs[:github] = false 468 | prefs[:git] = true 469 | prefs[:local_env_file] = 'none' 470 | prefs[:prod_webserver] = 'same' 471 | prefs[:pry] = false 472 | prefs[:secrets] = ['owner_email', 'mailchimp_list_id', 'mailchimp_api_key'] 473 | prefs[:templates] = 'erb' 474 | prefs[:tests] = false 475 | prefs[:locale] = 'none' 476 | prefs[:analytics] = 'none' 477 | prefs[:rubocop] = false 478 | prefs[:disable_turbolinks] = false 479 | prefs[:rvmrc] = true 480 | 481 | if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1 482 | prefs[:form_builder] = false 483 | prefs[:jquery] = 'gem' 484 | else 485 | # Rails 5.0 version uses SimpleForm 486 | prefs[:form_builder] = 'simple_form' 487 | add_gem 'minitest-rails-capybara', :group => :test 488 | end 489 | 490 | # gems 491 | add_gem 'high_voltage' 492 | add_gem 'gibbon' 493 | add_gem 'minitest-spec-rails', :group => :test 494 | gsub_file 'Gemfile', /gem 'sqlite3'\n/, '' 495 | add_gem 'sqlite3', :group => :development 496 | 497 | stage_three do 498 | say_wizard "recipe stage three" 499 | repo = 'https://raw.github.com/RailsApps/learn-rails/master/' 500 | 501 | # >-------------------------------[ Models ]--------------------------------< 502 | 503 | copy_from_repo 'app/models/contact.rb', :repo => repo 504 | copy_from_repo 'app/models/visitor.rb', :repo => repo 505 | 506 | # >-------------------------------[ Controllers ]--------------------------------< 507 | 508 | copy_from_repo 'app/controllers/contacts_controller.rb', :repo => repo 509 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 510 | 511 | # >-------------------------------[ Mailers ]--------------------------------< 512 | 513 | generate 'mailer UserMailer' 514 | copy_from_repo 'app/mailers/user_mailer.rb', :repo => repo 515 | 516 | # >-------------------------------[ Views ]--------------------------------< 517 | 518 | if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1 519 | copy_from_repo 'app/views/visitors/new.html.erb', :repo => repo 520 | copy_from_repo 'app/views/contacts/new.html.erb', :repo => repo 521 | else 522 | # Rails 5.0 version uses SimpleForm 523 | copy_from_repo 'app/views/visitors/new.html.erb', :repo => 'https://raw.githubusercontent.com/RailsApps/learn-rails/rails50/' 524 | copy_from_repo 'app/views/contacts/new.html.erb', :repo => 'https://raw.githubusercontent.com/RailsApps/learn-rails/rails50/' 525 | end 526 | 527 | copy_from_repo 'app/views/pages/about.html.erb', :repo => repo 528 | copy_from_repo 'app/views/user_mailer/contact_email.html.erb', :repo => repo 529 | copy_from_repo 'app/views/user_mailer/contact_email.text.erb', :repo => repo 530 | 531 | # create navigation links using the rails_layout gem 532 | generate 'layout:navigation -f' 533 | 534 | # >-------------------------------[ Routes ]--------------------------------< 535 | 536 | copy_from_repo 'config/routes.rb', :repo => repo 537 | 538 | # >-------------------------------[ Assets ]--------------------------------< 539 | 540 | copy_from_repo 'app/assets/javascripts/segment.js', :repo => repo 541 | 542 | # >-------------------------------[ Tests ]--------------------------------< 543 | 544 | copy_from_repo 'test/test_helper.rb', :repo => repo 545 | copy_from_repo 'test/integration/home_page_test.rb', :repo => repo 546 | copy_from_repo 'test/models/visitor_test.rb', :repo => repo 547 | 548 | run 'bundle exec rake db:migrate' 549 | end 550 | end 551 | # >------------------------- recipes/learn_rails.rb --------------------------end< 552 | # >-------------------------- templates/recipe.erb ---------------------------end< 553 | 554 | # >-------------------------- templates/recipe.erb ---------------------------start< 555 | # >----------------------------[ rails_bootstrap ]----------------------------< 556 | @current_recipe = "rails_bootstrap" 557 | @before_configs["rails_bootstrap"].call if @before_configs["rails_bootstrap"] 558 | say_recipe 'rails_bootstrap' 559 | @configs[@current_recipe] = config 560 | # >----------------------- recipes/rails_bootstrap.rb ------------------------start< 561 | 562 | # Application template recipe for the rails_apps_composer. Change the recipe here: 563 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_bootstrap.rb 564 | 565 | if prefer :apps4, 'rails-bootstrap' 566 | prefs[:authentication] = false 567 | prefs[:authorization] = false 568 | prefs[:dashboard] = 'none' 569 | prefs[:better_errors] = true 570 | prefs[:devise_modules] = false 571 | prefs[:email] = 'none' 572 | prefs[:git] = true 573 | prefs[:local_env_file] = false 574 | prefs[:pry] = false 575 | prefs[:pages] = 'about' 576 | prefs[:locale] = 'none' 577 | prefs[:rubocop] = false 578 | prefs[:frontend] = multiple_choice "Front-end framework?", 579 | [["Bootstrap 4.0", "bootstrap4"], ["Bootstrap 3.3", "bootstrap3"]] unless prefs.has_key? :frontend 580 | prefs[:rvmrc] = true 581 | end 582 | # >----------------------- recipes/rails_bootstrap.rb ------------------------end< 583 | # >-------------------------- templates/recipe.erb ---------------------------end< 584 | 585 | # >-------------------------- templates/recipe.erb ---------------------------start< 586 | # >---------------------------[ rails_foundation ]----------------------------< 587 | @current_recipe = "rails_foundation" 588 | @before_configs["rails_foundation"].call if @before_configs["rails_foundation"] 589 | say_recipe 'rails_foundation' 590 | @configs[@current_recipe] = config 591 | # >----------------------- recipes/rails_foundation.rb -----------------------start< 592 | 593 | # Application template recipe for the rails_apps_composer. Change the recipe here: 594 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_foundation.rb 595 | 596 | if prefer :apps4, 'rails-foundation' 597 | prefs[:authentication] = false 598 | prefs[:authorization] = false 599 | prefs[:dashboard] = 'none' 600 | prefs[:better_errors] = true 601 | prefs[:devise_modules] = false 602 | prefs[:email] = 'none' 603 | prefs[:frontend] = 'foundation5' 604 | prefs[:git] = true 605 | prefs[:local_env_file] = false 606 | prefs[:pry] = false 607 | prefs[:pages] = 'about' 608 | prefs[:locale] = 'none' 609 | prefs[:rubocop] = false 610 | prefs[:rvmrc] = true 611 | end 612 | # >----------------------- recipes/rails_foundation.rb -----------------------end< 613 | # >-------------------------- templates/recipe.erb ---------------------------end< 614 | 615 | # >-------------------------- templates/recipe.erb ---------------------------start< 616 | # >----------------------------[ rails_omniauth ]-----------------------------< 617 | @current_recipe = "rails_omniauth" 618 | @before_configs["rails_omniauth"].call if @before_configs["rails_omniauth"] 619 | say_recipe 'rails_omniauth' 620 | @configs[@current_recipe] = config 621 | # >------------------------ recipes/rails_omniauth.rb ------------------------start< 622 | 623 | # Application template recipe for the rails_apps_composer. Change the recipe here: 624 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_omniauth.rb 625 | 626 | if prefer :apps4, 'rails-omniauth' 627 | prefs[:authentication] = 'omniauth' 628 | prefs[:authorization] = 'none' 629 | prefs[:dashboard] = 'none' 630 | prefs[:better_errors] = true 631 | prefs[:email] = 'none' 632 | prefs[:git] = true 633 | prefs[:local_env_file] = false 634 | prefs[:pry] = false 635 | prefs[:pages] = 'about+users' 636 | prefs[:locale] = 'none' 637 | prefs[:rubocop] = false 638 | prefs[:rvmrc] = true 639 | end 640 | # >------------------------ recipes/rails_omniauth.rb ------------------------end< 641 | # >-------------------------- templates/recipe.erb ---------------------------end< 642 | 643 | # >-------------------------- templates/recipe.erb ---------------------------start< 644 | # >-----------------------------[ rails_devise ]------------------------------< 645 | @current_recipe = "rails_devise" 646 | @before_configs["rails_devise"].call if @before_configs["rails_devise"] 647 | say_recipe 'rails_devise' 648 | @configs[@current_recipe] = config 649 | # >------------------------- recipes/rails_devise.rb -------------------------start< 650 | 651 | # Application template recipe for the rails_apps_composer. Change the recipe here: 652 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_devise.rb 653 | 654 | if prefer :apps4, 'rails-devise' 655 | prefs[:authentication] = 'devise' 656 | prefs[:authorization] = false 657 | prefs[:dashboard] = 'none' 658 | prefs[:better_errors] = true 659 | prefs[:git] = true 660 | prefs[:local_env_file] = false 661 | prefs[:pry] = false 662 | prefs[:pages] = 'about+users' 663 | prefs[:locale] = 'none' 664 | prefs[:rubocop] = false 665 | prefs[:rvmrc] = true 666 | end 667 | # >------------------------- recipes/rails_devise.rb -------------------------end< 668 | # >-------------------------- templates/recipe.erb ---------------------------end< 669 | 670 | # >-------------------------- templates/recipe.erb ---------------------------start< 671 | # >--------------------------[ rails_devise_roles ]---------------------------< 672 | @current_recipe = "rails_devise_roles" 673 | @before_configs["rails_devise_roles"].call if @before_configs["rails_devise_roles"] 674 | say_recipe 'rails_devise_roles' 675 | @configs[@current_recipe] = config 676 | # >---------------------- recipes/rails_devise_roles.rb ----------------------start< 677 | 678 | # Application template recipe for the rails_apps_composer. Change the recipe here: 679 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_devise_roles.rb 680 | 681 | if prefer :apps4, 'rails-devise-roles' 682 | prefs[:authentication] = 'devise' 683 | prefs[:authorization] = 'roles' 684 | prefs[:better_errors] = true 685 | prefs[:git] = true 686 | prefs[:local_env_file] = false 687 | prefs[:pry] = false 688 | prefs[:pages] = 'about+users' 689 | prefs[:locale] = 'none' 690 | prefs[:rubocop] = false 691 | prefs[:rvmrc] = true 692 | end 693 | # >---------------------- recipes/rails_devise_roles.rb ----------------------end< 694 | # >-------------------------- templates/recipe.erb ---------------------------end< 695 | 696 | # >-------------------------- templates/recipe.erb ---------------------------start< 697 | # >--------------------------[ rails_devise_pundit ]--------------------------< 698 | @current_recipe = "rails_devise_pundit" 699 | @before_configs["rails_devise_pundit"].call if @before_configs["rails_devise_pundit"] 700 | say_recipe 'rails_devise_pundit' 701 | @configs[@current_recipe] = config 702 | # >--------------------- recipes/rails_devise_pundit.rb ----------------------start< 703 | 704 | # Application template recipe for the rails_apps_composer. Change the recipe here: 705 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_devise_pundit.rb 706 | 707 | if prefer :apps4, 'rails-devise-pundit' 708 | prefs[:authentication] = 'devise' 709 | prefs[:authorization] = 'pundit' 710 | prefs[:better_errors] = true 711 | prefs[:git] = true 712 | prefs[:local_env_file] = false 713 | prefs[:pry] = false 714 | prefs[:pages] = 'about+users' 715 | prefs[:locale] = 'none' 716 | prefs[:rubocop] = false 717 | prefs[:rvmrc] = true 718 | end 719 | # >--------------------- recipes/rails_devise_pundit.rb ----------------------end< 720 | # >-------------------------- templates/recipe.erb ---------------------------end< 721 | 722 | # >-------------------------- templates/recipe.erb ---------------------------start< 723 | # >--------------------------[ rails_shortcut_app ]---------------------------< 724 | @current_recipe = "rails_shortcut_app" 725 | @before_configs["rails_shortcut_app"].call if @before_configs["rails_shortcut_app"] 726 | say_recipe 'rails_shortcut_app' 727 | @configs[@current_recipe] = config 728 | # >---------------------- recipes/rails_shortcut_app.rb ----------------------start< 729 | 730 | # Application template recipe for the rails_apps_composer. Change the recipe here: 731 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_shortcut_app.rb 732 | 733 | if prefer :apps4, 'rails-shortcut-app' 734 | prefs[:authentication] = 'devise' 735 | prefs[:authorization] = 'roles' 736 | prefs[:dashboard] = 'none' 737 | prefs[:ban_spiders] = false 738 | prefs[:better_errors] = true 739 | prefs[:database] = 'sqlite' 740 | prefs[:deployment] = 'none' 741 | prefs[:devise_modules] = false 742 | prefs[:dev_webserver] = 'puma' 743 | prefs[:email] = 'none' 744 | prefs[:frontend] = 'bootstrap3' 745 | prefs[:layouts] = 'none' 746 | prefs[:pages] = 'none' 747 | prefs[:github] = false 748 | prefs[:git] = true 749 | prefs[:local_env_file] = false 750 | prefs[:prod_webserver] = 'same' 751 | prefs[:pry] = false 752 | prefs[:pages] = 'about+users' 753 | prefs[:templates] = 'erb' 754 | prefs[:tests] = 'none' 755 | prefs[:locale] = 'none' 756 | prefs[:analytics] = 'none' 757 | prefs[:rubocop] = false 758 | prefs[:disable_turbolinks] = true 759 | prefs[:rvmrc] = true 760 | prefs[:form_builder] = false 761 | prefs[:jquery] = 'gem' 762 | end 763 | # >---------------------- recipes/rails_shortcut_app.rb ----------------------end< 764 | # >-------------------------- templates/recipe.erb ---------------------------end< 765 | 766 | # >-------------------------- templates/recipe.erb ---------------------------start< 767 | # >-------------------------[ rails_signup_download ]-------------------------< 768 | @current_recipe = "rails_signup_download" 769 | @before_configs["rails_signup_download"].call if @before_configs["rails_signup_download"] 770 | say_recipe 'rails_signup_download' 771 | @configs[@current_recipe] = config 772 | # >-------------------- recipes/rails_signup_download.rb ---------------------start< 773 | 774 | # Application template recipe for the rails_apps_composer. Change the recipe here: 775 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_signup_download.rb 776 | 777 | if prefer :apps4, 'rails-signup-download' 778 | prefs[:authentication] = 'devise' 779 | prefs[:authorization] = 'roles' 780 | prefs[:better_errors] = true 781 | prefs[:devise_modules] = false 782 | prefs[:form_builder] = false 783 | prefs[:git] = true 784 | prefs[:local_env_file] = false 785 | prefs[:pry] = false 786 | prefs[:secrets] = ['mailchimp_list_id', 'mailchimp_api_key'] 787 | prefs[:pages] = 'about+users' 788 | prefs[:locale] = 'none' 789 | prefs[:rubocop] = false 790 | prefs[:rvmrc] = true 791 | 792 | # gems 793 | add_gem 'gibbon' 794 | add_gem 'sucker_punch' 795 | 796 | stage_three do 797 | say_wizard "recipe stage three" 798 | repo = 'https://raw.github.com/RailsApps/rails-signup-download/master/' 799 | 800 | # >-------------------------------[ Config ]---------------------------------< 801 | 802 | copy_from_repo 'config/initializers/active_job.rb', :repo => repo 803 | 804 | # >-------------------------------[ Models ]--------------------------------< 805 | 806 | copy_from_repo 'app/models/user.rb', :repo => repo 807 | 808 | # >-------------------------------[ Controllers ]--------------------------------< 809 | 810 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 811 | copy_from_repo 'app/controllers/products_controller.rb', :repo => repo 812 | 813 | # >-------------------------------[ Jobs ]---------------------------------< 814 | 815 | copy_from_repo 'app/jobs/mailing_list_signup_job.rb', :repo => repo 816 | 817 | # >-------------------------------[ Views ]--------------------------------< 818 | 819 | copy_from_repo 'app/views/visitors/index.html.erb', :repo => repo 820 | copy_from_repo 'app/views/products/product.pdf', :repo => repo 821 | 822 | # >-------------------------------[ Routes ]--------------------------------< 823 | 824 | copy_from_repo 'config/routes.rb', :repo => repo 825 | 826 | # >-------------------------------[ Tests ]--------------------------------< 827 | 828 | copy_from_repo 'spec/features/users/product_acquisition_spec.rb', :repo => repo 829 | copy_from_repo 'spec/controllers/products_controller_spec.rb', :repo => repo 830 | 831 | end 832 | end 833 | # >-------------------- recipes/rails_signup_download.rb ---------------------end< 834 | # >-------------------------- templates/recipe.erb ---------------------------end< 835 | 836 | # >-------------------------- templates/recipe.erb ---------------------------start< 837 | # >-------------------------[ rails_signup_thankyou ]-------------------------< 838 | @current_recipe = "rails_signup_thankyou" 839 | @before_configs["rails_signup_thankyou"].call if @before_configs["rails_signup_thankyou"] 840 | say_recipe 'rails_signup_thankyou' 841 | @configs[@current_recipe] = config 842 | # >-------------------- recipes/rails_signup_thankyou.rb ---------------------start< 843 | 844 | # Application template recipe for the rails_apps_composer. Change the recipe here: 845 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_signup_thankyou.rb 846 | 847 | if prefer :apps4, 'rails-signup-thankyou' 848 | prefs[:authentication] = 'devise' 849 | prefs[:authorization] = 'roles' 850 | prefs[:dashboard] = 'none' 851 | prefs[:ban_spiders] = false 852 | prefs[:better_errors] = true 853 | prefs[:database] = 'sqlite' 854 | prefs[:deployment] = 'none' 855 | prefs[:devise_modules] = false 856 | prefs[:dev_webserver] = 'puma' 857 | prefs[:email] = 'none' 858 | prefs[:frontend] = 'bootstrap3' 859 | prefs[:layouts] = 'none' 860 | prefs[:pages] = 'none' 861 | prefs[:github] = false 862 | prefs[:git] = true 863 | prefs[:local_env_file] = false 864 | prefs[:prod_webserver] = 'same' 865 | prefs[:pry] = false 866 | prefs[:pages] = 'about+users' 867 | prefs[:templates] = 'erb' 868 | prefs[:tests] = 'none' 869 | prefs[:locale] = 'none' 870 | prefs[:analytics] = 'none' 871 | prefs[:rubocop] = false 872 | prefs[:disable_turbolinks] = true 873 | prefs[:rvmrc] = true 874 | prefs[:form_builder] = false 875 | prefs[:jquery] = 'gem' 876 | 877 | stage_three do 878 | say_wizard "recipe stage three" 879 | repo = 'https://raw.github.com/RailsApps/rails-signup-thankyou/master/' 880 | 881 | # >-------------------------------[ Models ]--------------------------------< 882 | 883 | copy_from_repo 'app/models/user.rb', :repo => repo 884 | 885 | # >-------------------------------[ Controllers ]--------------------------------< 886 | 887 | copy_from_repo 'app/controllers/application_controller.rb', :repo => repo 888 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 889 | copy_from_repo 'app/controllers/products_controller.rb', :repo => repo 890 | copy_from_repo 'app/controllers/thank_you_controller.rb', :repo => repo 891 | 892 | # >-------------------------------[ Views ]--------------------------------< 893 | 894 | copy_from_repo 'app/views/visitors/index.html.erb', :repo => repo 895 | copy_from_repo 'app/views/products/product.pdf', :repo => repo 896 | copy_from_repo 'app/views/thank_you/index.html.erb', :repo => repo 897 | 898 | # >-------------------------------[ Routes ]--------------------------------< 899 | 900 | copy_from_repo 'config/routes.rb', :repo => repo 901 | 902 | # >-------------------------------[ Tests ]--------------------------------< 903 | 904 | copy_from_repo 'spec/features/users/product_acquisition_spec.rb', :repo => repo 905 | copy_from_repo 'spec/controllers/products_controller_spec.rb', :repo => repo 906 | 907 | end 908 | end 909 | # >-------------------- recipes/rails_signup_thankyou.rb ---------------------end< 910 | # >-------------------------- templates/recipe.erb ---------------------------end< 911 | 912 | # >-------------------------- templates/recipe.erb ---------------------------start< 913 | # >----------------------[ rails_mailinglist_activejob ]----------------------< 914 | @current_recipe = "rails_mailinglist_activejob" 915 | @before_configs["rails_mailinglist_activejob"].call if @before_configs["rails_mailinglist_activejob"] 916 | say_recipe 'rails_mailinglist_activejob' 917 | @configs[@current_recipe] = config 918 | # >----------------- recipes/rails_mailinglist_activejob.rb ------------------start< 919 | 920 | # Application template recipe for the rails_apps_composer. Change the recipe here: 921 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_mailinglist_activejob.rb 922 | 923 | if prefer :apps4, 'rails-mailinglist-activejob' 924 | prefs[:authentication] = false 925 | prefs[:authorization] = false 926 | prefs[:dashboard] = 'none' 927 | prefs[:better_errors] = true 928 | prefs[:form_builder] = 'simple_form' 929 | prefs[:git] = true 930 | prefs[:local_env_file] = false 931 | prefs[:pry] = false 932 | prefs[:secrets] = ['mailchimp_list_id', 'mailchimp_api_key'] 933 | prefs[:pages] = 'about' 934 | prefs[:locale] = 'none' 935 | prefs[:rubocop] = false 936 | prefs[:rvmrc] = true 937 | 938 | # gems 939 | add_gem 'gibbon' 940 | add_gem 'high_voltage' 941 | add_gem 'sucker_punch' 942 | 943 | stage_two do 944 | say_wizard "recipe stage two" 945 | generate 'model Visitor email:string' 946 | end 947 | 948 | stage_three do 949 | say_wizard "recipe stage three" 950 | repo = 'https://raw.github.com/RailsApps/rails-mailinglist-activejob/master/' 951 | 952 | # >-------------------------------[ Config ]---------------------------------< 953 | 954 | copy_from_repo 'config/initializers/active_job.rb', :repo => repo 955 | 956 | # >-------------------------------[ Models ]--------------------------------< 957 | 958 | copy_from_repo 'app/models/visitor.rb', :repo => repo 959 | 960 | # >-------------------------------[ Controllers ]--------------------------< 961 | 962 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 963 | 964 | # >-------------------------------[ Jobs ]---------------------------------< 965 | 966 | copy_from_repo 'app/jobs/mailing_list_signup_job.rb', :repo => repo 967 | 968 | # >-------------------------------[ Views ]--------------------------------< 969 | 970 | remove_file 'app/views/visitors/index.html.erb' 971 | copy_from_repo 'app/views/visitors/new.html.erb', :repo => repo 972 | 973 | # >-------------------------------[ Routes ]-------------------------------< 974 | 975 | gsub_file 'config/routes.rb', / root to: 'visitors#index'\n/, '' 976 | inject_into_file 'config/routes.rb', " root to: 'visitors#new'\n", :after => "routes.draw do\n" 977 | route = ' resources :visitors, only: [:new, :create]' 978 | inject_into_file 'config/routes.rb', route + "\n", :after => "routes.draw do\n" 979 | 980 | # >-------------------------------[ Tests ]--------------------------------< 981 | 982 | ### tests not implemented 983 | 984 | end 985 | end 986 | # >----------------- recipes/rails_mailinglist_activejob.rb ------------------end< 987 | # >-------------------------- templates/recipe.erb ---------------------------end< 988 | 989 | # >-------------------------- templates/recipe.erb ---------------------------start< 990 | # >-------------------------[ rails_stripe_checkout ]-------------------------< 991 | @current_recipe = "rails_stripe_checkout" 992 | @before_configs["rails_stripe_checkout"].call if @before_configs["rails_stripe_checkout"] 993 | say_recipe 'rails_stripe_checkout' 994 | @configs[@current_recipe] = config 995 | # >-------------------- recipes/rails_stripe_checkout.rb ---------------------start< 996 | 997 | # Application template recipe for the rails_apps_composer. Change the recipe here: 998 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_stripe_checkout.rb 999 | 1000 | if prefer :apps4, 'rails-stripe-checkout' 1001 | prefs[:frontend] = 'bootstrap3' 1002 | prefs[:authentication] = 'devise' 1003 | prefs[:authorization] = 'roles' 1004 | prefs[:better_errors] = true 1005 | prefs[:devise_modules] = false 1006 | prefs[:form_builder] = false 1007 | prefs[:git] = true 1008 | prefs[:local_env_file] = false 1009 | prefs[:pry] = false 1010 | prefs[:secrets] = ['product_price', 1011 | 'product_title', 1012 | 'stripe_publishable_key', 1013 | 'stripe_api_key', 1014 | 'mailchimp_list_id', 1015 | 'mailchimp_api_key'] 1016 | prefs[:pages] = 'about+users' 1017 | prefs[:locale] = 'none' 1018 | prefs[:rubocop] = false 1019 | prefs[:rvmrc] = true 1020 | 1021 | # gems 1022 | add_gem 'gibbon' 1023 | add_gem 'stripe' 1024 | add_gem 'sucker_punch' 1025 | 1026 | stage_three do 1027 | say_wizard "recipe stage three" 1028 | repo = 'https://raw.github.com/RailsApps/rails-stripe-checkout/master/' 1029 | 1030 | # >-------------------------------[ Config ]---------------------------------< 1031 | 1032 | copy_from_repo 'config/initializers/active_job.rb', :repo => repo 1033 | copy_from_repo 'config/initializers/devise_permitted_parameters.rb', :repo => repo 1034 | copy_from_repo 'config/initializers/stripe.rb', :repo => repo 1035 | 1036 | # >-------------------------------[ Assets ]--------------------------------< 1037 | 1038 | copy_from_repo 'app/assets/images/rubyonrails.png', :repo => repo 1039 | 1040 | # >-------------------------------[ Models ]--------------------------------< 1041 | 1042 | copy_from_repo 'app/models/user.rb', :repo => repo 1043 | 1044 | # >-------------------------------[ Controllers ]--------------------------------< 1045 | 1046 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 1047 | copy_from_repo 'app/controllers/products_controller.rb', :repo => repo 1048 | copy_from_repo 'app/controllers/registrations_controller.rb', :repo => repo 1049 | 1050 | # >-------------------------------[ Jobs ]---------------------------------< 1051 | 1052 | copy_from_repo 'app/jobs/mailing_list_signup_job.rb', :repo => repo 1053 | 1054 | # >-------------------------------[ Views ]--------------------------------< 1055 | 1056 | copy_from_repo 'app/views/devise/registrations/new.html.erb', :repo => repo 1057 | copy_from_repo 'app/views/visitors/_purchase.html.erb', :repo => repo 1058 | copy_from_repo 'app/views/visitors/index.html.erb', :repo => repo 1059 | copy_from_repo 'app/views/products/product.pdf', :repo => repo 1060 | 1061 | # >-------------------------------[ Routes ]--------------------------------< 1062 | 1063 | copy_from_repo 'config/routes.rb', :repo => repo 1064 | 1065 | # >-------------------------------[ Tests ]--------------------------------< 1066 | 1067 | ### tests not implemented 1068 | 1069 | end 1070 | end 1071 | # >-------------------- recipes/rails_stripe_checkout.rb ---------------------end< 1072 | # >-------------------------- templates/recipe.erb ---------------------------end< 1073 | 1074 | # >-------------------------- templates/recipe.erb ---------------------------start< 1075 | # >-------------------------[ rails_stripe_coupons ]--------------------------< 1076 | @current_recipe = "rails_stripe_coupons" 1077 | @before_configs["rails_stripe_coupons"].call if @before_configs["rails_stripe_coupons"] 1078 | say_recipe 'rails_stripe_coupons' 1079 | @configs[@current_recipe] = config 1080 | # >--------------------- recipes/rails_stripe_coupons.rb ---------------------start< 1081 | 1082 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1083 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_stripe_coupons.rb 1084 | 1085 | if prefer :apps4, 'rails-stripe-coupons' 1086 | prefs[:frontend] = 'bootstrap3' 1087 | prefs[:authentication] = 'devise' 1088 | prefs[:authorization] = 'roles' 1089 | prefs[:better_errors] = true 1090 | prefs[:devise_modules] = false 1091 | prefs[:form_builder] = false 1092 | prefs[:git] = true 1093 | prefs[:local_env_file] = false 1094 | prefs[:pry] = false 1095 | prefs[:secrets] = ['stripe_publishable_key', 1096 | 'stripe_api_key', 1097 | 'product_price', 1098 | 'product_title', 1099 | 'mailchimp_list_id', 1100 | 'mailchimp_api_key'] 1101 | prefs[:pages] = 'about+users' 1102 | prefs[:locale] = 'none' 1103 | prefs[:rubocop] = false 1104 | prefs[:rvmrc] = true 1105 | 1106 | # gems 1107 | add_gem 'gibbon' 1108 | add_gem 'stripe' 1109 | add_gem 'sucker_punch' 1110 | 1111 | stage_three do 1112 | say_wizard "recipe stage three" 1113 | repo = 'https://raw.github.com/RailsApps/rails-stripe-coupons/master/' 1114 | 1115 | # >-------------------------------[ Migrations ]---------------------------------< 1116 | 1117 | generate 'migration AddStripeTokenToUsers stripe_token:string' 1118 | generate 'scaffold Coupon code role mailing_list_id list_group price:integer --no-test-framework --no-helper --no-assets --no-jbuilder' 1119 | generate 'migration AddCouponRefToUsers coupon:references' 1120 | run 'bundle exec rake db:migrate' 1121 | 1122 | # >-------------------------------[ Config ]---------------------------------< 1123 | 1124 | copy_from_repo 'config/initializers/active_job.rb', :repo => repo 1125 | copy_from_repo 'config/initializers/stripe.rb', :repo => repo 1126 | 1127 | # >-------------------------------[ Assets ]--------------------------------< 1128 | 1129 | copy_from_repo 'app/assets/images/rubyonrails.png', :repo => repo 1130 | 1131 | # >-------------------------------[ Controllers ]--------------------------------< 1132 | 1133 | copy_from_repo 'app/controllers/coupons_controller.rb', :repo => repo 1134 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 1135 | copy_from_repo 'app/controllers/products_controller.rb', :repo => repo 1136 | copy_from_repo 'app/controllers/registrations_controller.rb', :repo => repo 1137 | 1138 | # >-------------------------------[ Helpers ]--------------------------------< 1139 | 1140 | copy_from_repo 'app/helpers/application_helper.rb', :repo => repo 1141 | 1142 | # >-------------------------------[ Jobs ]---------------------------------< 1143 | 1144 | copy_from_repo 'app/jobs/mailing_list_signup_job.rb', :repo => repo 1145 | copy_from_repo 'app/jobs/payment_job.rb', :repo => repo 1146 | 1147 | # >-------------------------------[ Mailers ]--------------------------------< 1148 | 1149 | copy_from_repo 'app/mailers/application_mailer.rb', :repo => repo 1150 | copy_from_repo 'app/mailers/payment_failure_mailer.rb', :repo => repo 1151 | 1152 | # >-------------------------------[ Models ]--------------------------------< 1153 | 1154 | copy_from_repo 'app/models/coupon.rb', :repo => repo 1155 | copy_from_repo 'app/models/user.rb', :repo => repo 1156 | 1157 | # >-------------------------------[ Services ]---------------------------------< 1158 | 1159 | copy_from_repo 'app/services/create_couponcodes_service.rb', :repo => repo 1160 | copy_from_repo 'app/services/mailing_list_signup_service.rb', :repo => repo 1161 | copy_from_repo 'app/services/make_payment_service.rb', :repo => repo 1162 | 1163 | # >-------------------------------[ Views ]--------------------------------< 1164 | 1165 | copy_from_repo 'app/views/coupons/_form.html.erb', :repo => repo 1166 | copy_from_repo 'app/views/coupons/edit.html.erb', :repo => repo 1167 | copy_from_repo 'app/views/coupons/index.html.erb', :repo => repo 1168 | copy_from_repo 'app/views/coupons/new.html.erb', :repo => repo 1169 | copy_from_repo 'app/views/coupons/show.html.erb', :repo => repo 1170 | copy_from_repo 'app/views/devise/registrations/_javascript.html.erb', :repo => repo 1171 | copy_from_repo 'app/views/devise/registrations/edit.html.erb', :repo => repo 1172 | copy_from_repo 'app/views/devise/registrations/new.html.erb', :repo => repo 1173 | copy_from_repo 'app/views/layouts/_navigation_links.html.erb', :repo => repo 1174 | copy_from_repo 'app/views/layouts/application.html.erb', :repo => repo 1175 | copy_from_repo 'app/views/layouts/mailer.html.erb', :repo => repo 1176 | copy_from_repo 'app/views/layouts/mailer.text.erb', :repo => repo 1177 | copy_from_repo 'app/views/pages/downloads.html.erb', :repo => repo 1178 | copy_from_repo 'app/views/payment_failure_mailer/failed_payment_email.html.erb', :repo => repo 1179 | copy_from_repo 'app/views/payment_failure_mailer/failed_payment_email.text.erb', :repo => repo 1180 | copy_from_repo 'app/views/users/show.html.erb', :repo => repo 1181 | copy_from_repo 'app/views/visitors/_purchase.html.erb', :repo => repo 1182 | copy_from_repo 'app/views/visitors/index.html.erb', :repo => repo 1183 | copy_from_repo 'app/views/products/product.pdf', :repo => repo 1184 | copy_from_repo 'public/offer.html', :repo => repo 1185 | 1186 | # >-------------------------------[ Routes ]--------------------------------< 1187 | 1188 | copy_from_repo 'config/routes.rb', :repo => repo 1189 | 1190 | # >-------------------------------[ Tests ]--------------------------------< 1191 | 1192 | ### tests not implemented 1193 | 1194 | end 1195 | end 1196 | # >--------------------- recipes/rails_stripe_coupons.rb ---------------------end< 1197 | # >-------------------------- templates/recipe.erb ---------------------------end< 1198 | 1199 | # >-------------------------- templates/recipe.erb ---------------------------start< 1200 | # >---------------------[ rails_stripe_membership_saas ]----------------------< 1201 | @current_recipe = "rails_stripe_membership_saas" 1202 | @before_configs["rails_stripe_membership_saas"].call if @before_configs["rails_stripe_membership_saas"] 1203 | say_recipe 'rails_stripe_membership_saas' 1204 | @configs[@current_recipe] = config 1205 | # >----------------- recipes/rails_stripe_membership_saas.rb -----------------start< 1206 | 1207 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1208 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_stripe_membership_saas.rb 1209 | 1210 | if prefer :apps4, 'rails-stripe-membership-saas' 1211 | prefs[:frontend] = 'bootstrap3' 1212 | prefs[:authentication] = 'devise' 1213 | prefs[:authorization] = 'roles' 1214 | prefs[:better_errors] = true 1215 | prefs[:devise_modules] = false 1216 | prefs[:form_builder] = false 1217 | prefs[:git] = true 1218 | prefs[:local_env_file] = false 1219 | prefs[:pry] = false 1220 | prefs[:disable_turbolinks] = true 1221 | prefs[:secrets] = ['stripe_publishable_key', 1222 | 'stripe_api_key', 1223 | 'mailchimp_list_id', 1224 | 'mailchimp_api_key'] 1225 | prefs[:pages] = 'about+users' 1226 | prefs[:locale] = 'none' 1227 | prefs[:rubocop] = false 1228 | prefs[:rvmrc] = true 1229 | 1230 | # gems 1231 | add_gem 'gibbon' 1232 | add_gem 'payola-payments' 1233 | add_gem 'sucker_punch' 1234 | 1235 | stage_three do 1236 | say_wizard "recipe stage three" 1237 | repo = 'https://raw.github.com/RailsApps/rails-stripe-membership-saas/master/' 1238 | 1239 | # >-------------------------------[ Migrations ]---------------------------------< 1240 | 1241 | generate 'payola:install' 1242 | generate 'model Plan name stripe_id interval amount:integer --no-test-framework' 1243 | generate 'migration AddPlanRefToUsers plan:references' 1244 | generate 'migration RemoveNameFromUsers name' 1245 | run 'bundle exec rake db:migrate' 1246 | 1247 | # >-------------------------------[ Config ]---------------------------------< 1248 | 1249 | copy_from_repo 'config/initializers/active_job.rb', :repo => repo 1250 | copy_from_repo 'config/initializers/payola.rb', :repo => repo 1251 | copy_from_repo 'db/seeds.rb', :repo => repo 1252 | 1253 | # >-------------------------------[ Assets ]--------------------------------< 1254 | 1255 | copy_from_repo 'app/assets/stylesheets/pricing.css.scss', :repo => repo 1256 | 1257 | # >-------------------------------[ Controllers ]--------------------------------< 1258 | 1259 | copy_from_repo 'app/controllers/application_controller.rb', :repo => repo 1260 | copy_from_repo 'app/controllers/content_controller.rb', :repo => repo 1261 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 1262 | copy_from_repo 'app/controllers/products_controller.rb', :repo => repo 1263 | copy_from_repo 'app/controllers/registrations_controller.rb', :repo => repo 1264 | 1265 | # >-------------------------------[ Jobs ]---------------------------------< 1266 | 1267 | copy_from_repo 'app/jobs/mailing_list_signup_job.rb', :repo => repo 1268 | 1269 | # >-------------------------------[ Mailers ]--------------------------------< 1270 | 1271 | copy_from_repo 'app/mailers/application_mailer.rb', :repo => repo 1272 | copy_from_repo 'app/mailers/user_mailer.rb', :repo => repo 1273 | 1274 | # >-------------------------------[ Models ]--------------------------------< 1275 | 1276 | copy_from_repo 'app/models/plan.rb', :repo => repo 1277 | copy_from_repo 'app/models/user.rb', :repo => repo 1278 | 1279 | # >-------------------------------[ Services ]---------------------------------< 1280 | 1281 | copy_from_repo 'app/services/create_plan_service.rb', :repo => repo 1282 | 1283 | # >-------------------------------[ Views ]--------------------------------< 1284 | 1285 | copy_from_repo 'app/views/content/gold.html.erb', :repo => repo 1286 | copy_from_repo 'app/views/content/platinum.html.erb', :repo => repo 1287 | copy_from_repo 'app/views/content/silver.html.erb', :repo => repo 1288 | copy_from_repo 'app/views/devise/registrations/edit.html.erb', :repo => repo 1289 | copy_from_repo 'app/views/devise/registrations/new.html.erb', :repo => repo 1290 | copy_from_repo 'app/views/layouts/_navigation_links.html.erb', :repo => repo 1291 | copy_from_repo 'app/views/layouts/application.html.erb', :repo => repo 1292 | copy_from_repo 'app/views/layouts/mailer.html.erb', :repo => repo 1293 | copy_from_repo 'app/views/layouts/mailer.text.erb', :repo => repo 1294 | copy_from_repo 'app/views/user_mailer/expire_email.html.erb', :repo => repo 1295 | copy_from_repo 'app/views/user_mailer/expire_email.text.erb', :repo => repo 1296 | copy_from_repo 'app/views/visitors/index.html.erb', :repo => repo 1297 | copy_from_repo 'app/views/products/product.pdf', :repo => repo 1298 | 1299 | # >-------------------------------[ Routes ]--------------------------------< 1300 | 1301 | copy_from_repo 'config/routes.rb', :repo => repo 1302 | 1303 | # >-------------------------------[ Tests ]--------------------------------< 1304 | 1305 | ### tests not implemented 1306 | 1307 | end 1308 | end 1309 | # >----------------- recipes/rails_stripe_membership_saas.rb -----------------end< 1310 | # >-------------------------- templates/recipe.erb ---------------------------end< 1311 | 1312 | # >-------------------------- templates/recipe.erb ---------------------------start< 1313 | # >---------------------------------[ setup ]---------------------------------< 1314 | @current_recipe = "setup" 1315 | @before_configs["setup"].call if @before_configs["setup"] 1316 | say_recipe 'setup' 1317 | @configs[@current_recipe] = config 1318 | # >---------------------------- recipes/setup.rb -----------------------------start< 1319 | 1320 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1321 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/setup.rb 1322 | 1323 | ## Ruby on Rails 1324 | HOST_OS = RbConfig::CONFIG['host_os'] 1325 | say_wizard "Your operating system is #{HOST_OS}." 1326 | say_wizard "You are using Ruby version #{RUBY_VERSION}." 1327 | say_wizard "You are using Rails version #{Rails::VERSION::STRING}." 1328 | 1329 | ## Is sqlite3 in the Gemfile? 1330 | gemfile = File.read(destination_root() + '/Gemfile') 1331 | sqlite_detected = gemfile.include? 'sqlite3' 1332 | 1333 | ## Web Server 1334 | prefs[:dev_webserver] = multiple_choice "Web server for development?", [["Puma (default)", "puma"], 1335 | ["Thin", "thin"], ["Unicorn", "unicorn"], ["Phusion Passenger (Apache/Nginx)", "passenger"], 1336 | ["Phusion Passenger (Standalone)", "passenger_standalone"]] unless prefs.has_key? :dev_webserver 1337 | prefs[:prod_webserver] = multiple_choice "Web server for production?", [["Same as development", "same"], 1338 | ["Thin", "thin"], ["Unicorn", "unicorn"], ["Phusion Passenger (Apache/Nginx)", "passenger"], 1339 | ["Phusion Passenger (Standalone)", "passenger_standalone"]] unless prefs.has_key? :prod_webserver 1340 | prefs[:prod_webserver] = prefs[:dev_webserver] if prefs[:prod_webserver] == 'same' 1341 | 1342 | ## Database Adapter 1343 | prefs[:database] = "sqlite" if prefer :database, 'default' 1344 | prefs[:database] = multiple_choice "Database used in development?", [["SQLite", "sqlite"], ["PostgreSQL", "postgresql"], 1345 | ["MySQL", "mysql"]] unless prefs.has_key? :database 1346 | 1347 | ## Template Engine 1348 | prefs[:templates] = multiple_choice "Template engine?", [["ERB", "erb"], ["Haml", "haml"], ["Slim", "slim"]] unless prefs.has_key? :templates 1349 | 1350 | ## Testing Framework 1351 | if recipes.include? 'tests' 1352 | prefs[:tests] = multiple_choice "Test framework?", [["None", "none"], 1353 | ["RSpec", "rspec"]] unless prefs.has_key? :tests 1354 | case prefs[:tests] 1355 | when 'rspec' 1356 | say_wizard "Adding DatabaseCleaner, FactoryGirl, Faker, Launchy, Selenium" 1357 | prefs[:continuous_testing] = multiple_choice "Continuous testing?", [["None", "none"], ["Guard", "guard"]] unless prefs.has_key? :continuous_testing 1358 | end 1359 | end 1360 | 1361 | ## Front-end Framework 1362 | if recipes.include? 'frontend' 1363 | prefs[:frontend] = multiple_choice "Front-end framework?", [["None", "none"], 1364 | ["Bootstrap 4.0", "bootstrap4"], ["Bootstrap 3.3", "bootstrap3"], ["Bootstrap 2.3", "bootstrap2"], 1365 | ["Zurb Foundation 5.5", "foundation5"], ["Zurb Foundation 4.0", "foundation4"], 1366 | ["Simple CSS", "simple"]] unless prefs.has_key? :frontend 1367 | end 1368 | 1369 | ## jQuery 1370 | if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1 1371 | if prefs[:frontend] == 'none' 1372 | prefs[:jquery] = multiple_choice "Add jQuery?", [["No", "none"], 1373 | ["Add jquery-rails gem", "gem"], 1374 | ["Add using yarn", "yarn"]] unless prefs.has_key? :jquery 1375 | else 1376 | prefs[:jquery] = multiple_choice "How to install jQuery?", 1377 | [["Add jquery-rails gem", "gem"], 1378 | ["Add using yarn", "yarn"]] unless prefs.has_key? :jquery 1379 | end 1380 | end 1381 | 1382 | ## Email 1383 | if recipes.include? 'email' 1384 | unless prefs.has_key? :email 1385 | say_wizard "The Devise 'forgot password' feature requires email." if prefer :authentication, 'devise' 1386 | prefs[:email] = multiple_choice "Add support for sending email?", [["None", "none"], ["Gmail","gmail"], ["SMTP","smtp"], 1387 | ["SendGrid","sendgrid"], ["Mandrill","mandrill"]] 1388 | end 1389 | else 1390 | prefs[:email] = 'none' 1391 | end 1392 | 1393 | ## Authentication and Authorization 1394 | if (recipes.include? 'devise') || (recipes.include? 'omniauth') 1395 | prefs[:authentication] = multiple_choice "Authentication?", [["None", "none"], ["Devise", "devise"], ["OmniAuth", "omniauth"]] unless prefs.has_key? :authentication 1396 | case prefs[:authentication] 1397 | when 'devise' 1398 | prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"], 1399 | ["Devise with Confirmable module","confirmable"], 1400 | ["Devise with Confirmable and Invitable modules","invitable"]] unless prefs.has_key? :devise_modules 1401 | when 'omniauth' 1402 | prefs[:omniauth_provider] = multiple_choice "OmniAuth provider?", [["Facebook", "facebook"], ["Twitter", "twitter"], ["GitHub", "github"], 1403 | ["LinkedIn", "linkedin"], ["Google-Oauth-2", "google_oauth2"], ["Tumblr", "tumblr"]] unless prefs.has_key? :omniauth_provider 1404 | end 1405 | prefs[:authorization] = multiple_choice "Authorization?", [["None", "none"], ["Simple role-based", "roles"], ["Pundit", "pundit"]] unless prefs.has_key? :authorization 1406 | if prefer :authentication, 'devise' 1407 | if (prefer :authorization, 'roles') || (prefer :authorization, 'pundit') 1408 | prefs[:dashboard] = multiple_choice "Admin interface for database?", [["None", "none"], 1409 | ["Thoughtbot Administrate", "administrate"]] unless prefs.has_key? :dashboard 1410 | end 1411 | end 1412 | end 1413 | 1414 | ## Form Builder 1415 | ## (no simple_form for Bootstrap 4 yet) 1416 | unless prefs[:frontend] == 'bootstrap4' 1417 | prefs[:form_builder] = multiple_choice "Use a form builder gem?", [["None", "none"], ["SimpleForm", "simple_form"]] unless prefs.has_key? :form_builder 1418 | end 1419 | 1420 | ## Pages 1421 | if recipes.include? 'pages' 1422 | prefs[:pages] = multiple_choice "Add pages?", [["None", "none"], 1423 | ["Home", "home"], ["Home and About", "about"], 1424 | ["Home and Users", "users"], 1425 | ["Home, About, and Users", "about+users"]] unless prefs.has_key? :pages 1426 | end 1427 | 1428 | ## Bootstrap Page Templates 1429 | if recipes.include? 'pages' 1430 | if prefs[:frontend] == 'bootstrap3' 1431 | say_wizard "Which Bootstrap page template? Visit startbootstrap.com." 1432 | prefs[:layouts] = multiple_choice "Add Bootstrap page templates?", [["None", "none"], 1433 | ["1 Col Portfolio", "one_col_portfolio"], 1434 | ["2 Col Portfolio", "two_col_portfolio"], 1435 | ["3 Col Portfolio", "three_col_portfolio"], 1436 | ["4 Col Portfolio", "four_col_portfolio"], 1437 | ["Bare", "bare"], 1438 | ["Blog Home", "blog_home"], 1439 | ["Business Casual", "business_casual"], 1440 | ["Business Frontpage", "business_frontpage"], 1441 | ["Clean Blog", "clean_blog"], 1442 | ["Full Width Pics", "full_width_pics"], 1443 | ["Heroic Features", "heroic_features"], 1444 | ["Landing Page", "landing_page"], 1445 | ["Modern Business", "modern_business"], 1446 | ["One Page Wonder", "one_page_wonder"], 1447 | ["Portfolio Item", "portfolio_item"], 1448 | ["Round About", "round_about"], 1449 | ["Shop Homepage", "shop_homepage"], 1450 | ["Shop Item", "shop_item"], 1451 | ["Simple Sidebar", "simple_sidebar"], 1452 | ["Small Business", "small_business"], 1453 | ["Stylish Portfolio", "stylish_portfolio"], 1454 | ["The Big Picture", "the_big_picture"], 1455 | ["Thumbnail Gallery", "thumbnail_gallery"]] unless prefs.has_key? :layouts 1456 | end 1457 | end 1458 | 1459 | # save configuration before anything can fail 1460 | create_file 'config/railscomposer.yml', "# This application was generated with Rails Composer\n\n" 1461 | append_to_file 'config/railscomposer.yml' do <<-TEXT 1462 | development: 1463 | apps4: #{prefs[:apps4]} 1464 | announcements: #{prefs[:announcements]} 1465 | dev_webserver: #{prefs[:dev_webserver]} 1466 | prod_webserver: #{prefs[:prod_webserver]} 1467 | database: #{prefs[:database]} 1468 | templates: #{prefs[:templates]} 1469 | tests: #{prefs[:tests]} 1470 | continuous_testing: #{prefs[:continuous_testing]} 1471 | frontend: #{prefs[:frontend]} 1472 | email: #{prefs[:email]} 1473 | authentication: #{prefs[:authentication]} 1474 | devise_modules: #{prefs[:devise_modules]} 1475 | omniauth_provider: #{prefs[:omniauth_provider]} 1476 | authorization: #{prefs[:authorization]} 1477 | form_builder: #{prefs[:form_builder]} 1478 | pages: #{prefs[:pages]} 1479 | layouts: #{prefs[:layouts]} 1480 | locale: #{prefs[:locale]} 1481 | analytics: #{prefs[:analytics]} 1482 | deployment: #{prefs[:deployment]} 1483 | ban_spiders: #{prefs[:ban_spiders]} 1484 | github: #{prefs[:github]} 1485 | local_env_file: #{prefs[:local_env_file]} 1486 | better_errors: #{prefs[:better_errors]} 1487 | pry: #{prefs[:pry]} 1488 | rvmrc: #{prefs[:rvmrc]} 1489 | dashboard: #{prefs[:dashboard]} 1490 | TEXT 1491 | end 1492 | # >---------------------------- recipes/setup.rb -----------------------------end< 1493 | # >-------------------------- templates/recipe.erb ---------------------------end< 1494 | 1495 | # >-------------------------- templates/recipe.erb ---------------------------start< 1496 | # >--------------------------------[ locale ]---------------------------------< 1497 | @current_recipe = "locale" 1498 | @before_configs["locale"].call if @before_configs["locale"] 1499 | say_recipe 'locale' 1500 | @configs[@current_recipe] = config 1501 | # >---------------------------- recipes/locale.rb ----------------------------start< 1502 | 1503 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1504 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/locale.rb 1505 | 1506 | unless prefs[:locale] 1507 | prefs[:locale] = ask_wizard('Set a locale? Enter nothing for English, or es, de, etc:') 1508 | prefs[:locale] = 'none' unless prefs[:locale].present? 1509 | end 1510 | 1511 | unless prefer :locale, 'none' 1512 | add_gem 'devise-i18n' if prefer :authentication, 'devise' 1513 | end 1514 | 1515 | stage_two do 1516 | unless prefer :locale, 'none' 1517 | locale_for_app = prefs[:locale].include?('-') ? "'#{prefs[:locale]}'" : prefs[:locale] 1518 | gsub_file 'config/application.rb', /# config.i18n.default_locale.*$/, "config.i18n.default_locale = :#{locale_for_app}" 1519 | locale_filename = "config/locales/#{prefs[:locale]}.yml" 1520 | create_file locale_filename 1521 | append_to_file locale_filename, "#{prefs[:locale]}:" 1522 | end 1523 | end 1524 | # >---------------------------- recipes/locale.rb ----------------------------end< 1525 | # >-------------------------- templates/recipe.erb ---------------------------end< 1526 | 1527 | # >-------------------------- templates/recipe.erb ---------------------------start< 1528 | # >--------------------------------[ readme ]---------------------------------< 1529 | @current_recipe = "readme" 1530 | @before_configs["readme"].call if @before_configs["readme"] 1531 | say_recipe 'readme' 1532 | @configs[@current_recipe] = config 1533 | # >---------------------------- recipes/readme.rb ----------------------------start< 1534 | 1535 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1536 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/readme.rb 1537 | 1538 | stage_three do 1539 | say_wizard "recipe stage three" 1540 | 1541 | # remove default READMEs 1542 | %w{ 1543 | README 1544 | README.rdoc 1545 | doc/README_FOR_APP 1546 | }.each { |file| remove_file file } 1547 | 1548 | # add diagnostics to README 1549 | create_file 'README', "#{app_name.humanize.titleize}\n================\n\n" 1550 | append_to_file 'README' do <<-TEXT 1551 | Rails Composer is supported by developers who purchase our RailsApps tutorials. 1552 | Need help? Ask on Stack Overflow with the tag 'railsapps.' 1553 | Problems? Submit an issue: https://github.com/RailsApps/rails_apps_composer/issues 1554 | Your application contains diagnostics in this README file. 1555 | Please provide a copy of this README file when reporting any issues. 1556 | \n 1557 | TEXT 1558 | end 1559 | append_to_file 'README' do <<-TEXT 1560 | option Build a starter application? 1561 | choose Enter your selection: [#{prefs[:apps4]}] 1562 | option Get on the mailing list for Rails Composer news? 1563 | choose Enter your selection: [#{prefs[:announcements]}] 1564 | option Web server for development? 1565 | choose Enter your selection: [#{prefs[:dev_webserver]}] 1566 | option Web server for production? 1567 | choose Enter your selection: [#{prefs[:prod_webserver]}] 1568 | option Database used in development? 1569 | choose Enter your selection: [#{prefs[:database]}] 1570 | option Template engine? 1571 | choose Enter your selection: [#{prefs[:templates]}] 1572 | option Test framework? 1573 | choose Enter your selection: [#{prefs[:tests]}] 1574 | option Continuous testing? 1575 | choose Enter your selection: [#{prefs[:continuous_testing]}] 1576 | option Front-end framework? 1577 | choose Enter your selection: [#{prefs[:frontend]}] 1578 | option Add support for sending email? 1579 | choose Enter your selection: [#{prefs[:email]}] 1580 | option Authentication? 1581 | choose Enter your selection: [#{prefs[:authentication]}] 1582 | option Devise modules? 1583 | choose Enter your selection: [#{prefs[:devise_modules]}] 1584 | option OmniAuth provider? 1585 | choose Enter your selection: [#{prefs[:omniauth_provider]}] 1586 | option Authorization? 1587 | choose Enter your selection: [#{prefs[:authorization]}] 1588 | option Use a form builder gem? 1589 | choose Enter your selection: [#{prefs[:form_builder]}] 1590 | option Add pages? 1591 | choose Enter your selection: [#{prefs[:pages]}] 1592 | option Set a locale? 1593 | choose Enter your selection: [#{prefs[:locale]}] 1594 | option Install page-view analytics? 1595 | choose Enter your selection: [#{prefs[:analytics]}] 1596 | option Add a deployment mechanism? 1597 | choose Enter your selection: [#{prefs[:deployment]}] 1598 | option Set a robots.txt file to ban spiders? 1599 | choose Enter your selection: [#{prefs[:ban_spiders]}] 1600 | option Create a GitHub repository? (y/n) 1601 | choose Enter your selection: [#{prefs[:github]}] 1602 | option Add gem and file for environment variables? 1603 | choose Enter your selection: [#{prefs[:local_env_file]}] 1604 | option Improve error reporting with 'better_errors' during development? 1605 | choose Enter your selection: [#{prefs[:better_errors]}] 1606 | option Use 'pry' as console replacement during development and test? 1607 | choose Enter your selection: [#{prefs[:pry]}] 1608 | option Use or create a project-specific rvm gemset? 1609 | choose Enter your selection: [#{prefs[:rvmrc]}] 1610 | TEXT 1611 | end 1612 | 1613 | create_file 'public/humans.txt' do <<-TEXT 1614 | /* the humans responsible & colophon */ 1615 | /* humanstxt.org */ 1616 | 1617 | 1618 | /* TEAM */ 1619 | : 1620 | Site: 1621 | Twitter: 1622 | Location: 1623 | 1624 | /* THANKS */ 1625 | Daniel Kehoe (@rails_apps) for the RailsApps project 1626 | 1627 | /* SITE */ 1628 | Standards: HTML5, CSS3 1629 | Components: jQuery 1630 | Software: Ruby on Rails 1631 | 1632 | /* GENERATED BY */ 1633 | Rails Composer: http://railscomposer.com/ 1634 | TEXT 1635 | end 1636 | 1637 | remove_file 'README.md' 1638 | create_file 'README.md', "#{app_name.humanize.titleize}\n================\n\n" 1639 | 1640 | if prefer :deployment, 'heroku' 1641 | append_to_file 'README.md' do <<-TEXT 1642 | [![Deploy to Heroku](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) 1643 | 1644 | TEXT 1645 | end 1646 | end 1647 | 1648 | append_to_file 'README.md' do <<-TEXT 1649 | This application was generated with the [rails_apps_composer](https://github.com/RailsApps/rails_apps_composer) gem 1650 | provided by the [RailsApps Project](http://railsapps.github.io/). 1651 | 1652 | Rails Composer is supported by developers who purchase our RailsApps tutorials. 1653 | 1654 | Problems? Issues? 1655 | ----------- 1656 | 1657 | Need help? Ask on Stack Overflow with the tag 'railsapps.' 1658 | 1659 | Your application contains diagnostics in the README file. Please provide a copy of the README file when reporting any issues. 1660 | 1661 | If the application doesn't work as expected, please [report an issue](https://github.com/RailsApps/rails_apps_composer/issues) 1662 | and include the diagnostics. 1663 | 1664 | Ruby on Rails 1665 | ------------- 1666 | 1667 | This application requires: 1668 | 1669 | - Ruby #{RUBY_VERSION} 1670 | - Rails #{Rails::VERSION::STRING} 1671 | 1672 | Learn more about [Installing Rails](http://railsapps.github.io/installing-rails.html). 1673 | 1674 | Getting Started 1675 | --------------- 1676 | 1677 | Documentation and Support 1678 | ------------------------- 1679 | 1680 | Issues 1681 | ------------- 1682 | 1683 | Similar Projects 1684 | ---------------- 1685 | 1686 | Contributing 1687 | ------------ 1688 | 1689 | Credits 1690 | ------- 1691 | 1692 | License 1693 | ------- 1694 | TEXT 1695 | end 1696 | 1697 | git :add => '-A' if prefer :git, true 1698 | git :commit => '-qm "rails_apps_composer: add README files"' if prefer :git, true 1699 | 1700 | end 1701 | # >---------------------------- recipes/readme.rb ----------------------------end< 1702 | # >-------------------------- templates/recipe.erb ---------------------------end< 1703 | 1704 | # >-------------------------- templates/recipe.erb ---------------------------start< 1705 | # >---------------------------------[ gems ]----------------------------------< 1706 | @current_recipe = "gems" 1707 | @before_configs["gems"].call if @before_configs["gems"] 1708 | say_recipe 'gems' 1709 | @configs[@current_recipe] = config 1710 | # >----------------------------- recipes/gems.rb -----------------------------start< 1711 | 1712 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1713 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/gems.rb 1714 | 1715 | ### GEMFILE ### 1716 | 1717 | ## Ruby on Rails 1718 | insert_into_file('Gemfile', "ruby '#{RUBY_VERSION}'\n", :before => /^ *gem 'rails'/, :force => false) 1719 | 1720 | ## Cleanup 1721 | # remove the 'sdoc' gem 1722 | if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2 1723 | gsub_file 'Gemfile', /gem 'sdoc',\s+'~> 0.4.0',\s+group: :doc/, '' 1724 | else 1725 | gsub_file 'Gemfile', /group :doc do/, '' 1726 | gsub_file 'Gemfile', /\s*gem 'sdoc', require: false\nend/, '' 1727 | end 1728 | 1729 | ## Web Server 1730 | if (prefs[:dev_webserver] == prefs[:prod_webserver]) 1731 | add_gem 'thin' if prefer :dev_webserver, 'thin' 1732 | add_gem 'unicorn' if prefer :dev_webserver, 'unicorn' 1733 | add_gem 'unicorn-rails' if prefer :dev_webserver, 'unicorn' 1734 | add_gem 'passenger' if prefer :dev_webserver, 'passenger_standalone' 1735 | else 1736 | add_gem 'thin', :group => [:development, :test] if prefer :dev_webserver, 'thin' 1737 | add_gem 'unicorn', :group => [:development, :test] if prefer :dev_webserver, 'unicorn' 1738 | add_gem 'unicorn-rails', :group => [:development, :test] if prefer :dev_webserver, 'unicorn' 1739 | add_gem 'passenger', :group => [:development, :test] if prefer :dev_webserver, 'passenger_standalone' 1740 | add_gem 'thin', :group => :production if prefer :prod_webserver, 'thin' 1741 | add_gem 'unicorn', :group => :production if prefer :prod_webserver, 'unicorn' 1742 | add_gem 'passenger', :group => :production if prefer :prod_webserver, 'passenger_standalone' 1743 | end 1744 | 1745 | ## Database Adapter 1746 | gsub_file 'Gemfile', /gem 'sqlite3'\n/, '' unless prefer :database, 'sqlite' 1747 | gsub_file 'Gemfile', /gem 'pg'.*/, '' 1748 | if prefer :database, 'postgresql' 1749 | if Rails::VERSION::MAJOR < 5 1750 | add_gem 'pg', '~> 0.18' 1751 | else 1752 | if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR <= 1 && Rails::VERSION::MINOR <= 5 1753 | add_gem 'pg', '~> 0.18' 1754 | else 1755 | add_gem 'pg' 1756 | end 1757 | end 1758 | end 1759 | gsub_file 'Gemfile', /gem 'mysql2'.*/, '' 1760 | add_gem 'mysql2', '~> 0.3.18' if prefer :database, 'mysql' 1761 | ## Gem to set up controllers, views, and routing in the 'apps4' recipe 1762 | add_gem 'rails_apps_pages', :group => :development if prefs[:apps4] 1763 | 1764 | ## Template Engine 1765 | if prefer :templates, 'haml' 1766 | add_gem 'haml-rails' 1767 | add_gem 'html2haml', :group => :development 1768 | end 1769 | if prefer :templates, 'slim' 1770 | add_gem 'slim-rails' 1771 | add_gem 'haml2slim', :group => :development 1772 | add_gem 'html2haml', :group => :development 1773 | end 1774 | 1775 | ## Testing Framework 1776 | if prefer :tests, 'rspec' 1777 | add_gem 'rails_apps_testing', :group => :development 1778 | add_gem 'rspec-rails', :group => [:development, :test] 1779 | add_gem 'spring-commands-rspec', :group => :development 1780 | add_gem 'factory_bot_rails', :group => [:development, :test] 1781 | add_gem 'faker', :group => [:development, :test] 1782 | unless Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1 1783 | add_gem 'capybara', :group => :test 1784 | add_gem 'selenium-webdriver', :group => :test 1785 | end 1786 | add_gem 'database_cleaner', :group => :test 1787 | add_gem 'launchy', :group => :test 1788 | if prefer :continuous_testing, 'guard' 1789 | add_gem 'guard-bundler', :group => :development 1790 | add_gem 'guard-rails', :group => :development 1791 | add_gem 'guard-rspec', :group => :development 1792 | add_gem 'rb-inotify', :group => :development, :require => false 1793 | add_gem 'rb-fsevent', :group => :development, :require => false 1794 | add_gem 'rb-fchange', :group => :development, :require => false 1795 | end 1796 | end 1797 | 1798 | ## Front-end Framework 1799 | add_gem 'rails_layout', :group => :development 1800 | case prefs[:frontend] 1801 | when 'bootstrap2' 1802 | add_gem 'bootstrap-sass', '~> 2.3.2.2' 1803 | when 'bootstrap3' 1804 | add_gem 'bootstrap-sass' 1805 | when 'bootstrap4' 1806 | add_gem 'bootstrap', '~> 4.0.0' 1807 | when 'foundation4' 1808 | add_gem 'zurb-foundation', '~> 4.3.2' 1809 | add_gem 'compass-rails', '~> 1.1.2' 1810 | when 'foundation5' 1811 | add_gem 'foundation-rails', '~> 5.5' 1812 | end 1813 | 1814 | ## jQuery 1815 | case prefs[:jquery] 1816 | when 'gem' 1817 | add_gem 'jquery-rails' 1818 | when 'yarn' 1819 | run 'bundle exec yarn add jquery' 1820 | end 1821 | 1822 | ## Pages 1823 | case prefs[:pages] 1824 | when 'about' 1825 | add_gem 'high_voltage' 1826 | when 'about+users' 1827 | add_gem 'high_voltage' 1828 | end 1829 | 1830 | ## Authentication (Devise) 1831 | if prefer :authentication, 'devise' 1832 | add_gem 'devise' 1833 | add_gem 'devise_invitable' if prefer :devise_modules, 'invitable' 1834 | end 1835 | 1836 | ## Administratative Interface 1837 | if prefer :dashboard, 'administrate' 1838 | add_gem 'administrate' 1839 | add_gem 'bourbon' 1840 | end 1841 | 1842 | ## Authentication (OmniAuth) 1843 | add_gem 'omniauth' if prefer :authentication, 'omniauth' 1844 | add_gem 'omniauth-twitter' if prefer :omniauth_provider, 'twitter' 1845 | add_gem 'omniauth-facebook' if prefer :omniauth_provider, 'facebook' 1846 | add_gem 'omniauth-github' if prefer :omniauth_provider, 'github' 1847 | add_gem 'omniauth-linkedin' if prefer :omniauth_provider, 'linkedin' 1848 | add_gem 'omniauth-google-oauth2' if prefer :omniauth_provider, 'google_oauth2' 1849 | add_gem 'omniauth-tumblr' if prefer :omniauth_provider, 'tumblr' 1850 | 1851 | ## Authorization 1852 | add_gem 'pundit' if prefer :authorization, 'pundit' 1853 | 1854 | ## Form Builder 1855 | add_gem 'simple_form' if prefer :form_builder, 'simple_form' 1856 | 1857 | ## Gems from a defaults file or added interactively 1858 | gems.each do |g| 1859 | add_gem(*g) 1860 | end 1861 | 1862 | ## Git 1863 | git :add => '-A' if prefer :git, true 1864 | git :commit => '-qm "rails_apps_composer: Gemfile"' if prefer :git, true 1865 | 1866 | ### CREATE DATABASE ### 1867 | stage_two do 1868 | say_wizard "recipe stage two" 1869 | say_wizard "configuring database" 1870 | unless prefer :database, 'sqlite' 1871 | copy_from_repo 'config/database-postgresql.yml', :prefs => 'postgresql' 1872 | copy_from_repo 'config/database-mysql.yml', :prefs => 'mysql' 1873 | if prefer :database, 'postgresql' 1874 | begin 1875 | pg_username = prefs[:pg_username] || ask_wizard("Username for PostgreSQL?(leave blank to use the app name)") 1876 | pg_host = prefs[:pg_host] || ask_wizard("Host for PostgreSQL in database.yml? (leave blank to use default socket connection)") 1877 | if pg_username.blank? 1878 | say_wizard "Creating a user named '#{app_name}' for PostgreSQL" 1879 | run "createuser --createdb #{app_name}" if prefer :database, 'postgresql' 1880 | gsub_file "config/database.yml", /username: .*/, "username: #{app_name}" 1881 | else 1882 | gsub_file "config/database.yml", /username: .*/, "username: #{pg_username}" 1883 | pg_password = prefs[:pg_password] || ask_wizard("Password for PostgreSQL user #{pg_username}?") 1884 | gsub_file "config/database.yml", /password:/, "password: #{pg_password}" 1885 | say_wizard "set config/database.yml for username/password #{pg_username}/#{pg_password}" 1886 | end 1887 | if pg_host.present? 1888 | gsub_file "config/database.yml", / host: localhost/, " host: #{pg_host}" 1889 | end 1890 | rescue StandardError => e 1891 | raise "unable to create a user for PostgreSQL, reason: #{e}" 1892 | end 1893 | gsub_file "config/database.yml", /database: myapp_development/, "database: #{app_name}_development" 1894 | gsub_file "config/database.yml", /database: myapp_test/, "database: #{app_name}_test" 1895 | gsub_file "config/database.yml", /database: myapp_production/, "database: #{app_name}_production" 1896 | end 1897 | if prefer :database, 'mysql' 1898 | mysql_username = prefs[:mysql_username] || ask_wizard("Username for MySQL? (leave blank to use the app name)") 1899 | if mysql_username.blank? 1900 | gsub_file "config/database.yml", /username: .*/, "username: #{app_name}" 1901 | else 1902 | gsub_file "config/database.yml", /username: .*/, "username: #{mysql_username}" 1903 | mysql_password = prefs[:mysql_password] || ask_wizard("Password for MySQL user #{mysql_username}?") 1904 | gsub_file "config/database.yml", /password:/, "password: #{mysql_password}" 1905 | say_wizard "set config/database.yml for username/password #{mysql_username}/#{mysql_password}" 1906 | end 1907 | gsub_file "config/database.yml", /database: myapp_development/, "database: #{app_name}_development" 1908 | gsub_file "config/database.yml", /database: myapp_test/, "database: #{app_name}_test" 1909 | gsub_file "config/database.yml", /database: myapp_production/, "database: #{app_name}_production" 1910 | end 1911 | unless prefer :database, 'sqlite' 1912 | if (prefs.has_key? :drop_database) ? prefs[:drop_database] : 1913 | (yes_wizard? "Okay to drop all existing databases named #{app_name}? 'No' will abort immediately!") 1914 | run 'bundle exec rake db:drop' 1915 | else 1916 | raise "aborted at user's request" 1917 | end 1918 | end 1919 | run 'bundle exec rake db:create:all' 1920 | ## Git 1921 | git :add => '-A' if prefer :git, true 1922 | git :commit => '-qm "rails_apps_composer: create database"' if prefer :git, true 1923 | end 1924 | end 1925 | 1926 | ### GENERATORS ### 1927 | stage_two do 1928 | say_wizard "recipe stage two" 1929 | say_wizard "running generators" 1930 | ## Form Builder 1931 | if prefer :form_builder, 'simple_form' 1932 | case prefs[:frontend] 1933 | when 'bootstrap2' 1934 | say_wizard "recipe installing simple_form for use with Bootstrap" 1935 | generate 'simple_form:install --bootstrap' 1936 | when 'bootstrap3' 1937 | say_wizard "recipe installing simple_form for use with Bootstrap" 1938 | generate 'simple_form:install --bootstrap' 1939 | when 'bootstrap4' 1940 | say_wizard "simple_form not yet available for use with Bootstrap 4" 1941 | when 'foundation5' 1942 | say_wizard "recipe installing simple_form for use with Zurb Foundation" 1943 | generate 'simple_form:install --foundation' 1944 | when 'foundation4' 1945 | say_wizard "recipe installing simple_form for use with Zurb Foundation" 1946 | generate 'simple_form:install --foundation' 1947 | else 1948 | say_wizard "recipe installing simple_form" 1949 | generate 'simple_form:install' 1950 | end 1951 | end 1952 | ## Figaro Gem 1953 | if prefer :local_env_file, 'figaro' 1954 | run 'figaro install' 1955 | gsub_file 'config/application.yml', /# PUSHER_.*\n/, '' 1956 | gsub_file 'config/application.yml', /# STRIPE_.*\n/, '' 1957 | prepend_to_file 'config/application.yml' do <<-FILE 1958 | # Add account credentials and API keys here. 1959 | # See http://railsapps.github.io/rails-environment-variables.html 1960 | # This file should be listed in .gitignore to keep your settings secret! 1961 | # Each entry sets a local environment variable. 1962 | # For example, setting: 1963 | # GMAIL_USERNAME: Your_Gmail_Username 1964 | # makes 'Your_Gmail_Username' available as ENV["GMAIL_USERNAME"] 1965 | 1966 | FILE 1967 | end 1968 | end 1969 | ## Foreman Gem 1970 | if prefer :local_env_file, 'foreman' 1971 | create_file '.env' do <<-FILE 1972 | # Add account credentials and API keys here. 1973 | # This file should be listed in .gitignore to keep your settings secret! 1974 | # Each entry sets a local environment variable. 1975 | # For example, setting: 1976 | # GMAIL_USERNAME=Your_Gmail_Username 1977 | # makes 'Your_Gmail_Username' available as ENV["GMAIL_USERNAME"] 1978 | 1979 | FILE 1980 | end 1981 | create_file 'Procfile', "web: bundle exec rails server -p $PORT\n" if prefer :prod_webserver, 'thin' 1982 | create_file 'Procfile', "web: bundle exec unicorn -p $PORT\n" if prefer :prod_webserver, 'unicorn' 1983 | create_file 'Procfile', "web: bundle exec passenger start -p $PORT\n" if prefer :prod_webserver, 'passenger_standalone' 1984 | if (prefs[:dev_webserver] != prefs[:prod_webserver]) 1985 | create_file 'Procfile.dev', "web: bundle exec rails server -p $PORT\n" if prefer :dev_webserver, 'thin' 1986 | create_file 'Procfile.dev', "web: bundle exec unicorn -p $PORT\n" if prefer :dev_webserver, 'unicorn' 1987 | create_file 'Procfile.dev', "web: bundle exec passenger start -p $PORT\n" if prefer :dev_webserver, 'passenger_standalone' 1988 | end 1989 | end 1990 | ## Git 1991 | git :add => '-A' if prefer :git, true 1992 | git :commit => '-qm "rails_apps_composer: generators"' if prefer :git, true 1993 | end 1994 | # >----------------------------- recipes/gems.rb -----------------------------end< 1995 | # >-------------------------- templates/recipe.erb ---------------------------end< 1996 | 1997 | # >-------------------------- templates/recipe.erb ---------------------------start< 1998 | # >---------------------------------[ tests ]---------------------------------< 1999 | @current_recipe = "tests" 2000 | @before_configs["tests"].call if @before_configs["tests"] 2001 | say_recipe 'tests' 2002 | @configs[@current_recipe] = config 2003 | # >---------------------------- recipes/tests.rb -----------------------------start< 2004 | 2005 | # Application template recipe for the rails_apps_composer. Change the recipe here: 2006 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/tests.rb 2007 | 2008 | stage_two do 2009 | say_wizard "recipe stage two" 2010 | if prefer :tests, 'rspec' 2011 | say_wizard "recipe installing RSpec" 2012 | generate 'testing:configure rspec -f' 2013 | end 2014 | if prefer :continuous_testing, 'guard' 2015 | say_wizard "recipe initializing Guard" 2016 | run 'bundle exec guard init' 2017 | end 2018 | git :add => '-A' if prefer :git, true 2019 | git :commit => '-qm "rails_apps_composer: testing framework"' if prefer :git, true 2020 | end 2021 | 2022 | stage_three do 2023 | say_wizard "recipe stage three" 2024 | if prefer :tests, 'rspec' 2025 | if prefer :authentication, 'devise' 2026 | generate 'testing:configure devise -f' 2027 | if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable') 2028 | inject_into_file 'spec/factories/users.rb', " confirmed_at Time.now\n", :after => "factory :user do\n" 2029 | default_url = ' config.action_mailer.default_url_options = { :host => Rails.application.secrets.domain_name }' 2030 | inject_into_file 'config/environments/test.rb', default_url, :after => "delivery_method = :test\n" 2031 | gsub_file 'spec/features/users/user_edit_spec.rb', /successfully./, 'successfully,' 2032 | gsub_file 'spec/features/visitors/sign_up_spec.rb', /Welcome! You have signed up successfully./, 'A message with a confirmation' 2033 | end 2034 | end 2035 | if prefer :authentication, 'omniauth' 2036 | generate 'testing:configure omniauth -f' 2037 | end 2038 | if (prefer :authorization, 'roles') || (prefer :authorization, 'pundit') 2039 | generate 'testing:configure pundit -f' 2040 | remove_file 'spec/policies/user_policy_spec.rb' unless %w(users about+users).include?(prefs[:pages]) 2041 | remove_file 'spec/policies/user_policy_spec.rb' if prefer :authorization, 'roles' 2042 | remove_file 'spec/support/pundit.rb' if prefer :authorization, 'roles' 2043 | if (prefer :authentication, 'devise') &&\ 2044 | ((prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')) 2045 | inject_into_file 'spec/factories/users.rb', " confirmed_at Time.now\n", :after => "factory :user do\n" 2046 | end 2047 | end 2048 | unless %w(users about+users).include?(prefs[:pages]) 2049 | remove_file 'spec/features/users/user_index_spec.rb' 2050 | remove_file 'spec/features/users/user_show_spec.rb' 2051 | end 2052 | end 2053 | end 2054 | # >---------------------------- recipes/tests.rb -----------------------------end< 2055 | # >-------------------------- templates/recipe.erb ---------------------------end< 2056 | 2057 | # >-------------------------- templates/recipe.erb ---------------------------start< 2058 | # >---------------------------------[ email ]---------------------------------< 2059 | @current_recipe = "email" 2060 | @before_configs["email"].call if @before_configs["email"] 2061 | say_recipe 'email' 2062 | @configs[@current_recipe] = config 2063 | # >---------------------------- recipes/email.rb -----------------------------start< 2064 | 2065 | # Application template recipe for the rails_apps_composer. Change the recipe here: 2066 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/email.rb 2067 | 2068 | stage_two do 2069 | say_wizard "recipe stage two" 2070 | unless prefer :email, 'none' 2071 | ## ACTIONMAILER CONFIG 2072 | dev_email_text = <<-TEXT 2073 | # ActionMailer Config 2074 | config.action_mailer.default_url_options = { :host => 'localhost:3000' } 2075 | config.action_mailer.delivery_method = :smtp 2076 | config.action_mailer.raise_delivery_errors = true 2077 | # Send email in development mode? 2078 | config.action_mailer.perform_deliveries = true 2079 | TEXT 2080 | prod_email_text = <<-TEXT 2081 | # ActionMailer Config 2082 | config.action_mailer.default_url_options = { :host => 'example.com' } 2083 | config.action_mailer.delivery_method = :smtp 2084 | config.action_mailer.perform_deliveries = true 2085 | config.action_mailer.raise_delivery_errors = false 2086 | TEXT 2087 | inject_into_file 'config/environments/development.rb', dev_email_text, :after => "config.assets.debug = true" 2088 | inject_into_file 'config/environments/production.rb', prod_email_text, :after => "config.active_support.deprecation = :notify" 2089 | gsub_file 'config/environments/production.rb', /'example.com'/, 'Rails.application.secrets.domain_name' 2090 | ## SMTP_SETTINGS 2091 | email_configuration_text = <<-TEXT 2092 | \n 2093 | config.action_mailer.smtp_settings = { 2094 | address: "smtp.gmail.com", 2095 | port: 587, 2096 | domain: Rails.application.secrets.domain_name, 2097 | authentication: "plain", 2098 | enable_starttls_auto: true, 2099 | user_name: Rails.application.secrets.email_provider_username, 2100 | password: Rails.application.secrets.email_provider_password 2101 | } 2102 | TEXT 2103 | inject_into_file 'config/environments/development.rb', email_configuration_text, :after => "config.assets.debug = true" 2104 | inject_into_file 'config/environments/production.rb', email_configuration_text, :after => "config.active_support.deprecation = :notify" 2105 | case prefs[:email] 2106 | when 'sendgrid' 2107 | gsub_file 'config/environments/development.rb', /smtp.gmail.com/, 'smtp.sendgrid.net' 2108 | gsub_file 'config/environments/production.rb', /smtp.gmail.com/, 'smtp.sendgrid.net' 2109 | when 'mandrill' 2110 | gsub_file 'config/environments/development.rb', /smtp.gmail.com/, 'smtp.mandrillapp.com' 2111 | gsub_file 'config/environments/production.rb', /smtp.gmail.com/, 'smtp.mandrillapp.com' 2112 | gsub_file 'config/environments/development.rb', /email_provider_password/, 'email_provider_apikey' 2113 | gsub_file 'config/environments/production.rb', /email_provider_password/, 'email_provider_apikey' 2114 | end 2115 | end 2116 | ### GIT 2117 | git :add => '-A' if prefer :git, true 2118 | git :commit => '-qm "rails_apps_composer: set email accounts"' if prefer :git, true 2119 | end 2120 | # >---------------------------- recipes/email.rb -----------------------------end< 2121 | # >-------------------------- templates/recipe.erb ---------------------------end< 2122 | 2123 | # >-------------------------- templates/recipe.erb ---------------------------start< 2124 | # >--------------------------------[ devise ]---------------------------------< 2125 | @current_recipe = "devise" 2126 | @before_configs["devise"].call if @before_configs["devise"] 2127 | say_recipe 'devise' 2128 | @configs[@current_recipe] = config 2129 | # >---------------------------- recipes/devise.rb ----------------------------start< 2130 | 2131 | # Application template recipe for the rails_apps_composer. Change the recipe here: 2132 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/devise.rb 2133 | 2134 | stage_two do 2135 | say_wizard "recipe stage two" 2136 | if prefer :authentication, 'devise' 2137 | # prevent logging of password_confirmation 2138 | gsub_file 'config/initializers/filter_parameter_logging.rb', /:password/, ':password, :password_confirmation' 2139 | generate 'devise:install' 2140 | generate 'devise_invitable:install' if prefer :devise_modules, 'invitable' 2141 | generate 'devise user' # create the User model 2142 | unless :apps4.to_s.include? 'rails-stripe-' 2143 | generate 'migration AddNameToUsers name:string' 2144 | end 2145 | if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable') 2146 | gsub_file 'app/models/user.rb', /:registerable,/, ":registerable, :confirmable," 2147 | generate 'migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string' 2148 | end 2149 | run 'bundle exec rake db:migrate' 2150 | end 2151 | ### GIT ### 2152 | git :add => '-A' if prefer :git, true 2153 | git :commit => '-qm "rails_apps_composer: devise"' if prefer :git, true 2154 | end 2155 | # >---------------------------- recipes/devise.rb ----------------------------end< 2156 | # >-------------------------- templates/recipe.erb ---------------------------end< 2157 | 2158 | # >-------------------------- templates/recipe.erb ---------------------------start< 2159 | # >-------------------------------[ omniauth ]--------------------------------< 2160 | @current_recipe = "omniauth" 2161 | @before_configs["omniauth"].call if @before_configs["omniauth"] 2162 | say_recipe 'omniauth' 2163 | @configs[@current_recipe] = config 2164 | # >--------------------------- recipes/omniauth.rb ---------------------------start< 2165 | 2166 | # Application template recipe for the rails_apps_composer. Change the recipe here: 2167 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/omniauth.rb 2168 | 2169 | stage_two do 2170 | say_wizard "recipe stage two" 2171 | if prefer :authentication, 'omniauth' 2172 | repo = 'https://raw.github.com/RailsApps/rails-omniauth/master/' 2173 | copy_from_repo 'config/initializers/omniauth.rb', :repo => repo 2174 | gsub_file 'config/initializers/omniauth.rb', /twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter' 2175 | generate 'model User name:string provider:string uid:string' 2176 | run 'bundle exec rake db:migrate' 2177 | copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails-omniauth/master/' 2178 | copy_from_repo 'app/controllers/application_controller.rb', :repo => repo 2179 | filename = 'app/controllers/sessions_controller.rb' 2180 | copy_from_repo filename, :repo => repo 2181 | gsub_file filename, /twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter' 2182 | routes = <<-TEXT 2183 | get '/auth/:provider/callback' => 'sessions#create' 2184 | get '/signin' => 'sessions#new', :as => :signin 2185 | get '/signout' => 'sessions#destroy', :as => :signout 2186 | get '/auth/failure' => 'sessions#failure' 2187 | TEXT 2188 | inject_into_file 'config/routes.rb', routes + "\n", :after => "routes.draw do\n" 2189 | end 2190 | ### GIT ### 2191 | git :add => '-A' if prefer :git, true 2192 | git :commit => '-qm "rails_apps_composer: omniauth"' if prefer :git, true 2193 | end 2194 | # >--------------------------- recipes/omniauth.rb ---------------------------end< 2195 | # >-------------------------- templates/recipe.erb ---------------------------end< 2196 | 2197 | # >-------------------------- templates/recipe.erb ---------------------------start< 2198 | # >---------------------------------[ roles ]---------------------------------< 2199 | @current_recipe = "roles" 2200 | @before_configs["roles"].call if @before_configs["roles"] 2201 | say_recipe 'roles' 2202 | @configs[@current_recipe] = config 2203 | # >---------------------------- recipes/roles.rb -----------------------------start< 2204 | 2205 | # Application template recipe for the rails_apps_composer. Change the recipe here: 2206 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/roles.rb 2207 | 2208 | stage_two do 2209 | say_wizard "recipe stage two" 2210 | if (prefer :authorization, 'roles') || (prefer :authorization, 'pundit') 2211 | if prefer :authentication, 'none' 2212 | generate 'model User email:string' 2213 | run 'bundle exec rake db:migrate' 2214 | end 2215 | generate 'migration AddRoleToUsers role:integer' 2216 | role_boilerplate = " enum role: [:user, :vip, :admin]\n after_initialize :set_default_role, :if => :new_record?\n\n" 2217 | role_boilerplate << " def set_default_role\n self.role ||= :user\n end\n\n" if prefer :authentication, 'devise' 2218 | if prefer :authentication, 'omniauth' 2219 | role_boilerplate << <<-RUBY 2220 | def set_default_role 2221 | if User.count == 0 2222 | self.role ||= :admin 2223 | else 2224 | self.role ||= :user 2225 | end 2226 | end 2227 | RUBY 2228 | end 2229 | inject_into_class 'app/models/user.rb', 'User', role_boilerplate 2230 | end 2231 | ### GIT ### 2232 | git :add => '-A' if prefer :git, true 2233 | git :commit => '-qm "rails_apps_composer: add roles to a User model"' if prefer :git, true 2234 | end 2235 | # >---------------------------- recipes/roles.rb -----------------------------end< 2236 | # >-------------------------- templates/recipe.erb ---------------------------end< 2237 | 2238 | # >-------------------------- templates/recipe.erb ---------------------------start< 2239 | # >-------------------------------[ frontend ]--------------------------------< 2240 | @current_recipe = "frontend" 2241 | @before_configs["frontend"].call if @before_configs["frontend"] 2242 | say_recipe 'frontend' 2243 | @configs[@current_recipe] = config 2244 | # >--------------------------- recipes/frontend.rb ---------------------------start< 2245 | 2246 | # Application template recipe for the rails_apps_composer. Change the recipe here: 2247 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/frontend.rb 2248 | 2249 | stage_two do 2250 | say_wizard "recipe stage two" 2251 | # set up a front-end framework using the rails_layout gem 2252 | case prefs[:frontend] 2253 | when 'simple' 2254 | generate 'layout:install simple -f' 2255 | when 'bootstrap2' 2256 | generate 'layout:install bootstrap2 -f' 2257 | when 'bootstrap3' 2258 | generate 'layout:install bootstrap3 -f' 2259 | when 'bootstrap4' 2260 | generate 'layout:install bootstrap4 -f' 2261 | when 'foundation4' 2262 | generate 'layout:install foundation4 -f' 2263 | when 'foundation5' 2264 | generate 'layout:install foundation5 -f' 2265 | else 2266 | case prefs[:jquery] 2267 | when 'gem', 'yarn' 2268 | say_wizard "modifying application.js for jQuery" 2269 | insert_into_file('app/assets/javascripts/application.js', "//= require jquery\n", :before => /^ *\/\/= require rails-ujs/, :force => false) 2270 | end 2271 | end 2272 | 2273 | ### GIT ### 2274 | git :add => '-A' if prefer :git, true 2275 | git :commit => '-qm "rails_apps_composer: front-end framework"' if prefer :git, true 2276 | end 2277 | # >--------------------------- recipes/frontend.rb ---------------------------end< 2278 | # >-------------------------- templates/recipe.erb ---------------------------end< 2279 | 2280 | # >-------------------------- templates/recipe.erb ---------------------------start< 2281 | # >---------------------------------[ pages ]---------------------------------< 2282 | @current_recipe = "pages" 2283 | @before_configs["pages"].call if @before_configs["pages"] 2284 | say_recipe 'pages' 2285 | @configs[@current_recipe] = config 2286 | # >---------------------------- recipes/pages.rb -----------------------------start< 2287 | 2288 | # Application template recipe for the rails_apps_composer. Change the recipe here: 2289 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/pages.rb 2290 | 2291 | stage_two do 2292 | say_wizard "recipe stage two" 2293 | case prefs[:pages] 2294 | when 'home' 2295 | generate 'pages:home -f' 2296 | when 'about' 2297 | generate 'pages:about -f' 2298 | when 'users' 2299 | generate 'pages:users -f' 2300 | generate 'pages:roles -f' if prefer :authorization, 'roles' 2301 | generate 'pages:authorized -f' if prefer :authorization, 'pundit' 2302 | when 'about+users' 2303 | generate 'pages:about -f' 2304 | generate 'pages:users -f' 2305 | generate 'pages:roles -f' if prefer :authorization, 'roles' 2306 | generate 'pages:authorized -f' if prefer :authorization, 'pundit' 2307 | end 2308 | ### GIT ### 2309 | git :add => '-A' if prefer :git, true 2310 | git :commit => '-qm "rails_apps_composer: add pages"' if prefer :git, true 2311 | end 2312 | 2313 | stage_four do 2314 | say_wizard "recipe stage four" 2315 | generate 'administrate:install' if prefer :dashboard, 'administrate' 2316 | case prefs[:layouts] 2317 | when 'bare' 2318 | generate 'theme:bare -f' 2319 | when 'blog_home' 2320 | generate 'theme:blog_home -f' 2321 | when 'business_casual' 2322 | generate 'theme:business_casual -f' 2323 | when 'business_frontpage' 2324 | generate 'theme:business_frontpage -f' 2325 | when 'clean_blog' 2326 | generate 'theme:clean_blog -f' 2327 | when 'four_col_portfolio' 2328 | generate 'theme:four_col_portfolio -f' 2329 | when 'full_width_pics' 2330 | generate 'theme:full_width_pics -f' 2331 | when 'heroic_features' 2332 | generate 'theme:heroic_features -f' 2333 | when 'landing_page' 2334 | generate 'theme:landing_page -f' 2335 | when 'modern_business' 2336 | generate 'theme:modern_business -f' 2337 | when 'one_col_portfolio' 2338 | generate 'theme:one_col_portfolio -f' 2339 | when 'one_page_wonder' 2340 | generate 'theme:one_page_wonder -f' 2341 | when 'portfolio_item' 2342 | generate 'theme:portfolio_item -f' 2343 | when 'round_about' 2344 | generate 'theme:round_about -f' 2345 | when 'shop_homepage' 2346 | generate 'theme:shop_homepage -f' 2347 | when 'shop_item' 2348 | generate 'theme:shop_item -f' 2349 | when 'simple_sidebar' 2350 | generate 'theme:simple_sidebar -f' 2351 | when 'small_business' 2352 | generate 'theme:small_business -f' 2353 | when 'stylish_portfolio' 2354 | generate 'theme:stylish_portfolio -f' 2355 | when 'the_big_picture' 2356 | generate 'theme:the_big_picture -f' 2357 | when 'three_col_portfolio' 2358 | generate 'theme:three_col_portfolio -f' 2359 | when 'thumbnail_gallery' 2360 | generate 'theme:thumbnail_gallery -f' 2361 | when 'two_col_portfolio' 2362 | generate 'theme:two_col_portfolio -f' 2363 | end 2364 | ### GIT ### 2365 | git :add => '-A' if prefer :git, true 2366 | git :commit => '-qm "rails_apps_composer: add Bootstrap page layouts"' if prefer :git, true 2367 | end 2368 | # >---------------------------- recipes/pages.rb -----------------------------end< 2369 | # >-------------------------- templates/recipe.erb ---------------------------end< 2370 | 2371 | # >-------------------------- templates/recipe.erb ---------------------------start< 2372 | # >---------------------------------[ init ]----------------------------------< 2373 | @current_recipe = "init" 2374 | @before_configs["init"].call if @before_configs["init"] 2375 | say_recipe 'init' 2376 | @configs[@current_recipe] = config 2377 | # >----------------------------- recipes/init.rb -----------------------------start< 2378 | 2379 | # Application template recipe for the rails_apps_composer. Change the recipe here: 2380 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/init.rb 2381 | 2382 | stage_three do 2383 | say_wizard "recipe stage three" 2384 | copy_from_repo 'config/secrets.yml' if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 2 2385 | copy_from_repo 'config/secrets.yml' if Rails::VERSION::MAJOR >= 6 2386 | if (!prefs[:secrets].nil?) 2387 | prefs[:secrets].each do |secret| 2388 | env_var = " #{secret}: <%= ENV[\"#{secret.upcase}\"] %>" 2389 | inject_into_file 'config/secrets.yml', "\n" + env_var, :after => "development:" 2390 | ### 'inject_into_file' doesn't let us inject the same text twice unless we append the extra space, why? 2391 | inject_into_file 'config/secrets.yml', "\n" + env_var + " ", :after => "\n" + "production:" 2392 | end 2393 | end 2394 | case prefs[:email] 2395 | when 'none' 2396 | secrets_email = foreman_email = '' 2397 | when 'smtp' 2398 | secrets_email = foreman_email = '' 2399 | when 'gmail' 2400 | secrets_email = " email_provider_username: <%= ENV[\"GMAIL_USERNAME\"] %>\n email_provider_password: <%= ENV[\"GMAIL_PASSWORD\"] %>" 2401 | foreman_email = "GMAIL_USERNAME=Your_Username\nGMAIL_PASSWORD=Your_Password\nDOMAIN_NAME=example.com\n" 2402 | when 'sendgrid' 2403 | secrets_email = " email_provider_username: <%= ENV[\"SENDGRID_USERNAME\"] %>\n email_provider_password: <%= ENV[\"SENDGRID_PASSWORD\"] %>" 2404 | foreman_email = "SENDGRID_USERNAME=Your_Username\nSENDGRID_PASSWORD=Your_Password\nDOMAIN_NAME=example.com\n" 2405 | when 'mandrill' 2406 | secrets_email = " email_provider_username: <%= ENV[\"MANDRILL_USERNAME\"] %>\n email_provider_apikey: <%= ENV[\"MANDRILL_APIKEY\"] %>" 2407 | foreman_email = "MANDRILL_USERNAME=Your_Username\nMANDRILL_APIKEY=Your_API_Key\nDOMAIN_NAME=example.com\n" 2408 | end 2409 | figaro_email = foreman_email.gsub('=', ': ') 2410 | secrets_d_devise = " admin_name: First User\n admin_email: user@example.com\n admin_password: changeme" 2411 | secrets_p_devise = " admin_name: <%= ENV[\"ADMIN_NAME\"] %>\n admin_email: <%= ENV[\"ADMIN_EMAIL\"] %>\n admin_password: <%= ENV[\"ADMIN_PASSWORD\"] %>" 2412 | foreman_devise = "ADMIN_NAME=First User\nADMIN_EMAIL=user@example.com\nADMIN_PASSWORD=changeme\n" 2413 | figaro_devise = foreman_devise.gsub('=', ': ') 2414 | secrets_omniauth = " omniauth_provider_key: <%= ENV[\"OMNIAUTH_PROVIDER_KEY\"] %>\n omniauth_provider_secret: <%= ENV[\"OMNIAUTH_PROVIDER_SECRET\"] %>" 2415 | foreman_omniauth = "OMNIAUTH_PROVIDER_KEY=Your_Provider_Key\nOMNIAUTH_PROVIDER_SECRET=Your_Provider_Secret\n" 2416 | figaro_omniauth = foreman_omniauth.gsub('=', ': ') 2417 | ## EMAIL 2418 | inject_into_file 'config/secrets.yml', "\n" + " domain_name: example.com", :after => "development:" 2419 | inject_into_file 'config/secrets.yml', "\n" + " domain_name: <%= ENV[\"DOMAIN_NAME\"] %>", :after => "\n" + "production:" 2420 | inject_into_file 'config/secrets.yml', "\n" + secrets_email, :after => "development:" 2421 | unless prefer :email, 'none' 2422 | ### 'inject_into_file' doesn't let us inject the same text twice unless we append the extra space, why? 2423 | inject_into_file 'config/secrets.yml', "\n" + secrets_email + " ", :after => "\n" + "production:" 2424 | append_file '.env', foreman_email if prefer :local_env_file, 'foreman' 2425 | append_file 'config/application.yml', figaro_email if prefer :local_env_file, 'figaro' 2426 | end 2427 | ## DEVISE 2428 | if prefer :authentication, 'devise' 2429 | inject_into_file 'config/secrets.yml', "\n" + ' domain_name: example.com' + " ", :after => "test:" 2430 | inject_into_file 'config/secrets.yml', "\n" + secrets_d_devise, :after => "development:" 2431 | inject_into_file 'config/secrets.yml', "\n" + secrets_p_devise, :after => "\n" + "production:" 2432 | append_file '.env', foreman_devise if prefer :local_env_file, 'foreman' 2433 | append_file 'config/application.yml', figaro_devise if prefer :local_env_file, 'figaro' 2434 | gsub_file 'config/initializers/devise.rb', /'please-change-me-at-config-initializers-devise@example.com'/, "'no-reply@' + Rails.application.secrets.domain_name" 2435 | end 2436 | ## OMNIAUTH 2437 | if prefer :authentication, 'omniauth' 2438 | inject_into_file 'config/secrets.yml', "\n" + secrets_omniauth, :after => "development:" 2439 | ### 'inject_into_file' doesn't let us inject the same text twice unless we append the extra space, why? 2440 | inject_into_file 'config/secrets.yml', "\n" + secrets_omniauth + " ", :after => "\n" + "production:" 2441 | append_file '.env', foreman_omniauth if prefer :local_env_file, 'foreman' 2442 | append_file 'config/application.yml', figaro_omniauth if prefer :local_env_file, 'figaro' 2443 | end 2444 | ## rails-stripe-coupons 2445 | if prefer :apps4, 'rails-stripe-coupons' 2446 | gsub_file 'config/secrets.yml', /<%= ENV\["PRODUCT_TITLE"\] %>/, 'What is Ruby on Rails' 2447 | gsub_file 'config/secrets.yml', /<%= ENV\["PRODUCT_PRICE"\] %>/, '995' 2448 | end 2449 | ### EXAMPLE FILE FOR FOREMAN AND FIGARO ### 2450 | if prefer :local_env_file, 'figaro' 2451 | copy_file destination_root + '/config/application.yml', destination_root + '/config/application.example.yml' 2452 | elsif prefer :local_env_file, 'foreman' 2453 | copy_file destination_root + '/.env', destination_root + '/.env.example' 2454 | end 2455 | ### DATABASE SEED ### 2456 | if prefer :authentication, 'devise' 2457 | copy_from_repo 'db/seeds.rb', :repo => 'https://raw.github.com/RailsApps/rails-devise/master/' 2458 | if prefer :authorization, 'roles' 2459 | copy_from_repo 'app/services/create_admin_service.rb', :repo => 'https://raw.github.com/RailsApps/rails-devise-roles/master/' 2460 | elsif prefer :authorization, 'pundit' 2461 | copy_from_repo 'app/services/create_admin_service.rb', :repo => 'https://raw.github.com/RailsApps/rails-devise-pundit/master/' 2462 | else 2463 | copy_from_repo 'app/services/create_admin_service.rb', :repo => 'https://raw.github.com/RailsApps/rails-devise/master/' 2464 | end 2465 | end 2466 | if prefer :apps4, 'rails-stripe-coupons' 2467 | copy_from_repo 'app/services/create_couponcodes_service.rb', :repo => 'https://raw.github.com/RailsApps/rails-stripe-coupons/master/' 2468 | append_file 'db/seeds.rb' do <<-FILE 2469 | CreateCouponcodesService.new.call 2470 | puts 'CREATED PROMOTIONAL CODES' 2471 | FILE 2472 | end 2473 | end 2474 | if prefer :apps4, 'rails-stripe-membership-saas' 2475 | append_file 'db/seeds.rb' do <<-FILE 2476 | CreatePlanService.new.call 2477 | puts 'CREATED PLANS' 2478 | FILE 2479 | end 2480 | end 2481 | if prefer :local_env_file, 'figaro' 2482 | append_file 'db/seeds.rb' do <<-FILE 2483 | # Environment variables (ENV['...']) can be set in the file config/application.yml. 2484 | # See http://railsapps.github.io/rails-environment-variables.html 2485 | FILE 2486 | end 2487 | elsif prefer :local_env_file, 'foreman' 2488 | append_file 'db/seeds.rb' do <<-FILE 2489 | # Environment variables (ENV['...']) can be set in the file .env file. 2490 | FILE 2491 | end 2492 | end 2493 | ## DEVISE-CONFIRMABLE 2494 | if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable') 2495 | inject_into_file 'app/services/create_admin_service.rb', " user.confirm\n", :after => "user.password_confirmation = Rails.application.secrets.admin_password\n" 2496 | end 2497 | ## DEVISE-INVITABLE 2498 | if prefer :devise_modules, 'invitable' 2499 | if prefer :local_env_file, 'foreman' 2500 | run 'foreman run bundle exec rake db:migrate' 2501 | else 2502 | run 'bundle exec rake db:migrate' 2503 | end 2504 | generate 'devise_invitable user' 2505 | end 2506 | ### APPLY DATABASE SEED ### 2507 | if File.exists?('db/migrate') 2508 | ## ACTIVE_RECORD 2509 | say_wizard "applying migrations and seeding the database" 2510 | if prefer :local_env_file, 'foreman' 2511 | run 'foreman run bundle exec rake db:migrate' 2512 | else 2513 | run 'bundle exec rake db:migrate' 2514 | end 2515 | end 2516 | unless prefs[:skip_seeds] 2517 | if prefer :local_env_file, 'foreman' 2518 | run 'foreman run bundle exec rake db:seed' 2519 | else 2520 | run 'bundle exec rake db:seed' 2521 | end 2522 | end 2523 | ### GIT ### 2524 | git :add => '-A' if prefer :git, true 2525 | git :commit => '-qm "rails_apps_composer: set up database"' if prefer :git, true 2526 | ### FRONTEND (must run after database migrations) ### 2527 | # generate Devise views with appropriate styling 2528 | if prefer :authentication, 'devise' 2529 | case prefs[:frontend] 2530 | when 'bootstrap3' 2531 | generate 'layout:devise bootstrap3 -f' 2532 | when 'bootstrap4' 2533 | generate 'layout:devise bootstrap3 -f' 2534 | when 'foundation5' 2535 | generate 'layout:devise foundation5 -f' 2536 | end 2537 | end 2538 | # create navigation links using the rails_layout gem 2539 | if prefs[:frontend] == 'bootstrap4' 2540 | generate 'layout:navigation bootstrap4 -f' 2541 | else 2542 | generate 'layout:navigation -f' 2543 | end 2544 | if prefer :apps4, 'rails-stripe-coupons' 2545 | inject_into_file 'app/views/layouts/_nav_links_for_auth.html.erb', ", data: { no_turbolink: true }", :after => "new_user_registration_path" 2546 | inject_into_file 'app/views/layouts/_nav_links_for_auth.html.erb', "\n
  • <%= link_to 'Coupons', coupons_path %>
  • ", :after => "users_path %>" 2547 | end 2548 | if prefer :apps4, 'rails-stripe-membership-saas' 2549 | inject_into_file 'app/views/layouts/_nav_links_for_auth.html.erb', ", data: { no_turbolink: true }", :after => "new_user_registration_path" 2550 | copy_from_repo 'app/views/devise/registrations/edit.html.erb', :repo => 'https://raw.github.com/RailsApps/rails-stripe-membership-saas/master/' 2551 | end 2552 | ### GIT ### 2553 | git :add => '-A' if prefer :git, true 2554 | git :commit => '-qm "rails_apps_composer: navigation links"' if prefer :git, true 2555 | end 2556 | # >----------------------------- recipes/init.rb -----------------------------end< 2557 | # >-------------------------- templates/recipe.erb ---------------------------end< 2558 | 2559 | # >-------------------------- templates/recipe.erb ---------------------------start< 2560 | # >-------------------------------[ analytics ]-------------------------------< 2561 | @current_recipe = "analytics" 2562 | @before_configs["analytics"].call if @before_configs["analytics"] 2563 | say_recipe 'analytics' 2564 | @configs[@current_recipe] = config 2565 | # >-------------------------- recipes/analytics.rb ---------------------------start< 2566 | 2567 | # Application template recipe for the rails_apps_composer. Change the recipe here: 2568 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/analytics.rb 2569 | 2570 | prefs[:analytics] = multiple_choice "Install page-view analytics?", [["None", "none"], 2571 | ["Google Analytics", "ga"], 2572 | ["Segment.com", "segmentio"]] unless prefs.has_key? :analytics 2573 | case prefs[:analytics] 2574 | when 'ga' 2575 | ga_id = ask_wizard('Google Analytics ID?') 2576 | when 'segmentio' 2577 | segmentio_api_key = ask_wizard('Segment.com Write Key?') 2578 | end 2579 | 2580 | stage_two do 2581 | say_wizard "recipe stage two" 2582 | unless prefer :analytics, 'none' 2583 | # don't add the gem if it has already been added by the railsapps recipe 2584 | add_gem 'rails_apps_pages', :group => :development unless prefs[:apps4] 2585 | end 2586 | case prefs[:analytics] 2587 | when 'ga' 2588 | generate 'analytics:google -f' 2589 | gsub_file 'app/assets/javascripts/google_analytics.js.coffee', /UA-XXXXXXX-XX/, ga_id 2590 | when 'segmentio' 2591 | generate 'analytics:segmentio -f' 2592 | gsub_file 'app/assets/javascripts/segmentio.js', /SEGMENTIO_API_KEY/, segmentio_api_key 2593 | end 2594 | ### GIT ### 2595 | git :add => '-A' if prefer :git, true 2596 | git :commit => '-qm "rails_apps_composer: add analytics"' if prefer :git, true 2597 | end 2598 | # >-------------------------- recipes/analytics.rb ---------------------------end< 2599 | # >-------------------------- templates/recipe.erb ---------------------------end< 2600 | 2601 | # >-------------------------- templates/recipe.erb ---------------------------start< 2602 | # >------------------------------[ deployment ]-------------------------------< 2603 | @current_recipe = "deployment" 2604 | @before_configs["deployment"].call if @before_configs["deployment"] 2605 | say_recipe 'deployment' 2606 | @configs[@current_recipe] = config 2607 | # >-------------------------- recipes/deployment.rb --------------------------start< 2608 | 2609 | # Application template recipe for the rails_apps_composer. Change the recipe here: 2610 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/deployment.rb 2611 | 2612 | prefs[:deployment] = multiple_choice "Prepare for deployment?", [["no", "none"], 2613 | ["Heroku", "heroku"], 2614 | ["Capistrano", "capistrano3"]] unless prefs.has_key? :deployment 2615 | 2616 | if prefer :deployment, 'heroku' 2617 | say_wizard "installing gems for Heroku" 2618 | if prefer :database, 'sqlite' 2619 | gsub_file 'Gemfile', /.*gem 'sqlite3'\n/, '' 2620 | add_gem 'sqlite3', group: [:development, :test] 2621 | add_gem 'pg', group: :production 2622 | end 2623 | end 2624 | 2625 | if prefer :deployment, 'capistrano3' 2626 | say_wizard "installing gems for Capistrano" 2627 | add_gem 'capistrano', '~> 3.0.1', group: :development 2628 | add_gem 'capistrano-rvm', '~> 0.1.1', group: :development 2629 | add_gem 'capistrano-bundler', group: :development 2630 | add_gem 'capistrano-rails', '~> 1.1.0', group: :development 2631 | add_gem 'capistrano-rails-console', group: :development 2632 | stage_two do 2633 | say_wizard "recipe stage two" 2634 | say_wizard "installing Capistrano files" 2635 | run 'bundle exec cap install' 2636 | end 2637 | end 2638 | 2639 | stage_three do 2640 | ### GIT ### 2641 | git :add => '-A' if prefer :git, true 2642 | git :commit => '-qm "rails_apps_composer: prepare for deployment"' if prefer :git, true 2643 | end 2644 | # >-------------------------- recipes/deployment.rb --------------------------end< 2645 | # >-------------------------- templates/recipe.erb ---------------------------end< 2646 | 2647 | # >-------------------------- templates/recipe.erb ---------------------------start< 2648 | # >--------------------------------[ extras ]---------------------------------< 2649 | @current_recipe = "extras" 2650 | @before_configs["extras"].call if @before_configs["extras"] 2651 | say_recipe 'extras' 2652 | config = {} 2653 | config['disable_turbolinks'] = yes_wizard?("Disable Rails Turbolinks?") if true && true unless config.key?('disable_turbolinks') || prefs.has_key?(:disable_turbolinks) 2654 | 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) 2655 | config['github'] = yes_wizard?("Create a GitHub repository?") if true && true unless config.key?('github') || prefs.has_key?(:github) 2656 | config['local_env_file'] = multiple_choice("Add gem and file for environment variables?", [["None", "none"], ["Add .env with Foreman", "foreman"]]) if true && true unless config.key?('local_env_file') || prefs.has_key?(:local_env_file) 2657 | config['better_errors'] = yes_wizard?("Improve error reporting with 'better_errors' during development?") if true && true unless config.key?('better_errors') || prefs.has_key?(:better_errors) 2658 | config['pry'] = yes_wizard?("Use 'pry' as console replacement during development and test?") if true && true unless config.key?('pry') || prefs.has_key?(:pry) 2659 | config['rubocop'] = yes_wizard?("Use 'rubocop' to ensure that your code conforms to the Ruby style guide?") if true && true unless config.key?('rubocop') || prefs.has_key?(:rubocop) 2660 | @configs[@current_recipe] = config 2661 | # >---------------------------- recipes/extras.rb ----------------------------start< 2662 | 2663 | # Application template recipe for the rails_apps_composer. Change the recipe here: 2664 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/extras.rb 2665 | 2666 | ## RVMRC 2667 | if prefs[:rvmrc] 2668 | if File.exist?('.ruby-version') 2669 | say_wizard ".ruby-version file already exists" 2670 | else 2671 | create_file '.ruby-version', "#{RUBY_VERSION}\n" 2672 | end 2673 | if File.exist?('.ruby-gemset') 2674 | say_wizard ".ruby-gemset file already exists" 2675 | else 2676 | create_file '.ruby-gemset', "#{app_name}\n" 2677 | end 2678 | end 2679 | 2680 | ## LOCAL_ENV.YML FILE 2681 | prefs[:local_env_file] = config['local_env_file'] unless (config['local_env_file'] == 'none') 2682 | 2683 | if prefer :local_env_file, 'figaro' 2684 | say_wizard "recipe creating application.yml file for environment variables with figaro" 2685 | add_gem 'figaro' 2686 | elsif prefer :local_env_file, 'foreman' 2687 | say_wizard "recipe creating .env file for development environment variables with foreman" 2688 | add_gem 'foreman', :group => :development 2689 | end 2690 | 2691 | ## BETTER ERRORS 2692 | prefs[:better_errors] = true if config['better_errors'] 2693 | if prefs[:better_errors] 2694 | say_wizard "recipe adding better_errors gem" 2695 | add_gem 'better_errors', :group => :development 2696 | if RUBY_ENGINE == 'ruby' 2697 | case RUBY_VERSION.split('.')[0] + "." + RUBY_VERSION.split('.')[1] 2698 | when '2.1' 2699 | add_gem 'binding_of_caller', :group => :development, :platforms => [:mri_21] 2700 | when '2.0' 2701 | add_gem 'binding_of_caller', :group => :development, :platforms => [:mri_20] 2702 | when '1.9' 2703 | add_gem 'binding_of_caller', :group => :development, :platforms => [:mri_19] 2704 | end 2705 | end 2706 | end 2707 | 2708 | # Pry 2709 | prefs[:pry] = true if config['pry'] 2710 | if prefs[:pry] 2711 | say_wizard "recipe adding pry-rails gem" 2712 | add_gem 'pry-rails', :group => [:development, :test] 2713 | add_gem 'pry-rescue', :group => [:development, :test] 2714 | end 2715 | 2716 | ## Rubocop 2717 | prefs[:rubocop] = true if config['rubocop'] 2718 | if prefs[:rubocop] 2719 | say_wizard "recipe adding rubocop gem and basic .rubocop.yml" 2720 | add_gem 'rubocop', :group => [:development, :test] 2721 | copy_from_repo '.rubocop.yml' 2722 | end 2723 | 2724 | ## Disable Turbolinks 2725 | if config['disable_turbolinks'] 2726 | prefs[:disable_turbolinks] = true 2727 | end 2728 | if prefs[:disable_turbolinks] 2729 | say_wizard "recipe removing support for Rails Turbolinks" 2730 | stage_two do 2731 | say_wizard "recipe stage two" 2732 | gsub_file 'Gemfile', /gem 'turbolinks'\n/, '' 2733 | gsub_file 'Gemfile', /gem 'turbolinks', '~> 5'\n/, '' 2734 | gsub_file 'app/assets/javascripts/application.js', "//= require turbolinks\n", '' 2735 | case prefs[:templates] 2736 | when 'erb' 2737 | gsub_file 'app/views/layouts/application.html.erb', /, 'data-turbolinks-track' => true/, '' 2738 | gsub_file 'app/views/layouts/application.html.erb', /, 'data-turbolinks-track' => 'reload'/, '' 2739 | when 'haml' 2740 | gsub_file 'app/views/layouts/application.html.haml', /, 'data-turbolinks-track' => true/, '' 2741 | gsub_file 'app/views/layouts/application.html.haml', /, 'data-turbolinks-track' => 'reload'/, '' 2742 | when 'slim' 2743 | gsub_file 'app/views/layouts/application.html.slim', /, 'data-turbolinks-track' => true/, '' 2744 | gsub_file 'app/views/layouts/application.html.slim', /, 'data-turbolinks-track' => 'reload'/, '' 2745 | end 2746 | end 2747 | end 2748 | 2749 | ## BAN SPIDERS 2750 | prefs[:ban_spiders] = true if config['ban_spiders'] 2751 | if prefs[:ban_spiders] 2752 | say_wizard "recipe banning spiders by modifying 'public/robots.txt'" 2753 | stage_two do 2754 | say_wizard "recipe stage two" 2755 | gsub_file 'public/robots.txt', /# User-Agent/, 'User-Agent' 2756 | gsub_file 'public/robots.txt', /# Disallow/, 'Disallow' 2757 | end 2758 | end 2759 | 2760 | ## JSRUNTIME 2761 | case RbConfig::CONFIG['host_os'] 2762 | when /linux/i 2763 | prefs[:jsruntime] = yes_wizard? "Add 'therubyracer' JavaScript runtime (for Linux users without node.js)?" unless prefs.has_key? :jsruntime 2764 | if prefs[:jsruntime] 2765 | say_wizard "recipe adding 'therubyracer' JavaScript runtime gem" 2766 | add_gem 'therubyracer', :platform => :ruby 2767 | end 2768 | end 2769 | 2770 | stage_four do 2771 | say_wizard "recipe stage four" 2772 | say_wizard "recipe removing unnecessary files and whitespace" 2773 | %w{ 2774 | public/index.html 2775 | app/assets/images/rails.png 2776 | }.each { |file| remove_file file } 2777 | # remove temporary Haml gems from Gemfile when Slim is selected 2778 | if prefer :templates, 'slim' 2779 | gsub_file 'Gemfile', /.*gem 'haml2slim'\n/, "\n" 2780 | gsub_file 'Gemfile', /.*gem 'html2haml'\n/, "\n" 2781 | end 2782 | # remove gems and files used to assist rails_apps_composer 2783 | gsub_file 'Gemfile', /.*gem 'rails_apps_pages'\n/, '' 2784 | gsub_file 'Gemfile', /.*gem 'rails_apps_testing'\n/, '' 2785 | remove_file 'config/railscomposer.yml' 2786 | # remove commented lines and multiple blank lines from Gemfile 2787 | # thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb 2788 | gsub_file 'Gemfile', /#\s.*\n/, "\n" 2789 | gsub_file 'Gemfile', /\n^\s*\n/, "\n" 2790 | remove_file 'Gemfile.lock' 2791 | # remove commented lines and multiple blank lines from config/routes.rb 2792 | gsub_file 'config/routes.rb', / #.*\n/, "\n" 2793 | gsub_file 'config/routes.rb', /\n^\s*\n/, "\n" 2794 | # GIT 2795 | git :add => '-A' if prefer :git, true 2796 | git :commit => '-qm "rails_apps_composer: extras"' if prefer :git, true 2797 | end 2798 | 2799 | ## GITHUB 2800 | prefs[:github] = true if config['github'] 2801 | if prefs[:github] 2802 | add_gem 'hub', :require => nil, :group => [:development] 2803 | stage_three do 2804 | say_wizard "recipe stage three" 2805 | say_wizard "recipe creating GitHub repository" 2806 | git_uri = `git config remote.origin.url`.strip 2807 | unless git_uri.size == 0 2808 | say_wizard "Repository already exists:" 2809 | say_wizard "#{git_uri}" 2810 | else 2811 | run "hub create #{app_name}" 2812 | run "hub push -u origin master" 2813 | end 2814 | end 2815 | end 2816 | # >---------------------------- recipes/extras.rb ----------------------------end< 2817 | # >-------------------------- templates/recipe.erb ---------------------------end< 2818 | 2819 | 2820 | # >-----------------------------[ Final Gemfile Write ]------------------------------< 2821 | Gemfile.write 2822 | 2823 | # >---------------------------------[ Diagnostics ]----------------------------------< 2824 | 2825 | # remove prefs which are diagnostically irrelevant 2826 | redacted_prefs = prefs.clone 2827 | redacted_prefs.delete(:ban_spiders) 2828 | redacted_prefs.delete(:better_errors) 2829 | redacted_prefs.delete(:pry) 2830 | redacted_prefs.delete(:dev_webserver) 2831 | redacted_prefs.delete(:git) 2832 | redacted_prefs.delete(:github) 2833 | redacted_prefs.delete(:jsruntime) 2834 | redacted_prefs.delete(:local_env_file) 2835 | redacted_prefs.delete(:main_branch) 2836 | redacted_prefs.delete(:prelaunch_branch) 2837 | redacted_prefs.delete(:prod_webserver) 2838 | redacted_prefs.delete(:rvmrc) 2839 | redacted_prefs.delete(:templates) 2840 | 2841 | if diagnostics_prefs.include? redacted_prefs 2842 | diagnostics[:prefs] = 'success' 2843 | else 2844 | diagnostics[:prefs] = 'fail' 2845 | end 2846 | 2847 | @current_recipe = nil 2848 | 2849 | # >-----------------------------[ Run 'Bundle Install' ]-------------------------------< 2850 | 2851 | say_wizard "Installing Bundler (in case it is not installed)." 2852 | run 'gem install bundler' 2853 | say_wizard "Installing gems. This will take a while." 2854 | run 'bundle install --without production' 2855 | say_wizard "Updating gem paths." 2856 | Gem.clear_paths 2857 | # >-----------------------------[ Run 'stage_two' Callbacks ]-------------------------------< 2858 | 2859 | say_wizard "Stage Two (running recipe 'stage_two' callbacks)." 2860 | if prefer :templates, 'haml' 2861 | say_wizard "importing html2haml conversion tool" 2862 | require 'html2haml' 2863 | end 2864 | if prefer :templates, 'slim' 2865 | say_wizard "importing html2haml and haml2slim conversion tools" 2866 | require 'html2haml' 2867 | require 'haml2slim' 2868 | end 2869 | @after_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; puts @current_recipe; b[1].call} 2870 | 2871 | # >-----------------------------[ Run 'stage_three' Callbacks ]-------------------------------< 2872 | 2873 | @current_recipe = nil 2874 | say_wizard "Stage Three (running recipe 'stage_three' callbacks)." 2875 | @stage_three_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; puts @current_recipe; b[1].call} 2876 | 2877 | # >-----------------------------[ Run 'stage_four' Callbacks ]-------------------------------< 2878 | 2879 | @current_recipe = nil 2880 | say_wizard "Stage Four (running recipe 'stage_four' callbacks)." 2881 | @stage_four_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; puts @current_recipe; b[1].call} 2882 | 2883 | @current_recipe = nil 2884 | say_wizard("Your new application will contain diagnostics in its README file.") 2885 | say_wizard("When reporting an issue on GitHub, include the README diagnostics.") 2886 | say_wizard "Finished running the rails_apps_composer app template." 2887 | say_wizard "Your new Rails app is ready. Time to run 'bundle install'." 2888 | -------------------------------------------------------------------------------- /files/.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | RunRailsCops: true 3 | Include: 4 | - '**/Gemfile' 5 | - '**/Rakefile' 6 | Exclude: 7 | - 'bin/*' 8 | - 'db/seeds.rb' 9 | - 'db/schema.rb' 10 | - 'vendor/bundle/**/*' 11 | -------------------------------------------------------------------------------- /files/.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-2.0.0@App_Name" 10 | 11 | # Uncomment the following lines if you want to verify rvm version per project 12 | # rvmrc_rvm_version="1.18.6 (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 | if [[ $- == *i* ]] # check for interactive shells 29 | then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green 30 | else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells 31 | fi 32 | else 33 | # If the environment file has not yet been created, use the RVM CLI to select. 34 | rvm --create use "$environment_id" || { 35 | echo "Failed to create RVM environment '${environment_id}'." 36 | return 1 37 | } 38 | fi 39 | -------------------------------------------------------------------------------- /files/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.io/ 8 | 9 | ________________________ 10 | 11 | Recipes: 12 | RECIPES 13 | 14 | Preferences: 15 | PREFERENCES 16 | 17 | ________________________ 18 | 19 | License 20 | -------------------------------------------------------------------------------- /files/README.md: -------------------------------------------------------------------------------- 1 | App_Name 2 | ========= 3 | 4 | This application was generated with the [rails_apps_composer](https://github.com/RailsApps/rails_apps_composer) gem 5 | provided by the [RailsApps Project](http://railsapps.github.io/). 6 | 7 | Diagnostics 8 | ----------- 9 | 10 | This application was built with recipes that are known to work together. 11 | 12 | This application was built with preferences that are known to work 13 | together. 14 | 15 | If the application doesn’t work as expected, please [report an issue](https://github.com/RailsApps/rails_apps_composer/issues) 16 | and include these diagnostics: 17 | 18 | We’d also like to know if you’ve found combinations of recipes or 19 | preferences that do work together. 20 | 21 | Recipes: 22 | RECIPES 23 | 24 | Preferences: 25 | PREFERENCES 26 | 27 | Ruby on Rails 28 | ------------- 29 | 30 | This application requires: 31 | 32 | - Ruby 33 | - Rails 34 | 35 | Learn more about [Installing Rails](http://railsapps.github.io/installing-rails.html). 36 | 37 | Database 38 | -------- 39 | 40 | This application uses SQLite with ActiveRecord. 41 | 42 | Development 43 | ----------- 44 | 45 | - Template Engine: ERB 46 | - Testing Framework: Test::Unit 47 | - Front-end Framework: None 48 | - Form Builder: None 49 | - Authentication: None 50 | - Authorization: None 51 | - Admin: None 52 | 53 | Email 54 | ----- 55 | 56 | The application is configured to send email using a Gmail account. 57 | 58 | Email delivery is disabled in development. 59 | 60 | Getting Started 61 | --------------- 62 | 63 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 64 | 65 | Documentation and Support 66 | ------------------------- 67 | 68 | This is the only documentation. 69 | 70 | #### Issues 71 | 72 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 73 | 74 | Similar Projects 75 | ---------------- 76 | 77 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 78 | 79 | Contributing 80 | ------------ 81 | 82 | If you make improvements to this application, please share with others. 83 | 84 | - Fork the project on GitHub. 85 | - Make your feature addition or bug fix. 86 | - Commit with Git. 87 | - Send the author a pull request. 88 | 89 | If you add functionality to this application, create an alternative 90 | implementation, or build an application that is similar, please contact 91 | me and I’ll add a note to the README so that others can find your work. 92 | 93 | Credits 94 | ------- 95 | 96 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 97 | 98 | License 99 | ------- 100 | 101 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 102 | -------------------------------------------------------------------------------- /files/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.io/. 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.io/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. 81 | -------------------------------------------------------------------------------- /files/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/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/app/controllers/application_controller-omniauth.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery 3 | helper_method :current_user 4 | helper_method :user_signed_in? 5 | helper_method :correct_user? 6 | 7 | private 8 | def current_user 9 | begin 10 | @current_user ||= User.find(session[:user_id]) if session[:user_id] 11 | rescue Exception => e 12 | nil 13 | end 14 | end 15 | 16 | def user_signed_in? 17 | return true if current_user 18 | end 19 | 20 | def correct_user? 21 | @user = User.find(params[:id]) 22 | unless current_user == @user 23 | redirect_to root_url, :alert => "Access denied." 24 | end 25 | end 26 | 27 | def authenticate_user! 28 | if !current_user 29 | redirect_to root_url, :alert => 'You need to sign in for access to this page.' 30 | end 31 | end 32 | 33 | end 34 | -------------------------------------------------------------------------------- /files/app/controllers/registrations_controller-devise.rb: -------------------------------------------------------------------------------- 1 | class RegistrationsController < Devise::RegistrationsController 2 | before_filter :update_sanitized_params, if: :devise_controller? 3 | 4 | def update_sanitized_params 5 | devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:name, :email, :password, :password_confirmation)} 6 | devise_parameter_sanitizer.for(:account_update) {|u| u.permit(:name, :email, :password, :password_confirmation, :current_password)} 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /files/app/helpers/application_helper-simple_form.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | 3 | def display_base_errors resource 4 | return '' if (resource.errors.empty?) or (resource.errors[:base].empty?) 5 | messages = resource.errors[:base].map { |msg| content_tag(:p, msg) }.join 6 | html = <<-HTML 7 |
    8 | 9 | #{messages} 10 |
    11 | HTML 12 | html.html_safe 13 | end 14 | 15 | end 16 | -------------------------------------------------------------------------------- /files/app/views/devise/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RailsApps/rails-composer/5a9985f6ddae1cc9475568c2d1f6a7ae28c005a7/files/app/views/devise/.DS_Store -------------------------------------------------------------------------------- /files/app/views/devise/registrations/edit-simple_form.html.erb: -------------------------------------------------------------------------------- 1 |

    Edit <%= resource_name.to_s.humanize %>

    2 | <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => 'form-vertical' }) do |f| %> 3 | <%= f.error_notification %> 4 | <%= display_base_errors resource %> 5 | <%= f.input :name, :autofocus => true %> 6 | <%= f.input :email, :required => true %> 7 | <%= f.input :password, :autocomplete => "off", :hint => "leave it blank if you don't want to change it", :required => false %> 8 | <%= f.input :password_confirmation, :required => false %> 9 | <%= f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true %> 10 | <%= f.button :submit, 'Update', :class => 'btn-primary' %> 11 | <% end %> 12 |

    Cancel my account

    13 |

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

    14 | <%= link_to "Back", :back %> 15 | -------------------------------------------------------------------------------- /files/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/app/views/devise/registrations/new-simple_form.html.erb: -------------------------------------------------------------------------------- 1 |

    Sign up

    2 | <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'form-vertical' }) do |f| %> 3 | <%= f.error_notification %> 4 | <%= display_base_errors resource %> 5 | <%= f.input :name, :autofocus => true %> 6 | <%= f.input :email, :required => true %> 7 | <%= f.input :password, :required => true %> 8 | <%= f.input :password_confirmation, :required => true %> 9 | <%= f.button :submit, 'Sign up', :class => 'btn-primary' %> 10 | <% end %> 11 | <%= render "devise/shared/links" %> 12 | -------------------------------------------------------------------------------- /files/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/app/views/devise/sessions/new-simple_form.html.erb: -------------------------------------------------------------------------------- 1 |

    Sign in

    2 | <%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => 'form-vertical' }) do |f| %> 3 | <%= f.input :email, :autofocus => true %> 4 | <%= f.input :password %> 5 | <%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %> 6 | <%= f.button :submit, "Sign in", :class => 'btn-primary' %> 7 | <% end %> 8 | <%= render "devise/shared/links" %> 9 | -------------------------------------------------------------------------------- /files/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 -%> 26 | -------------------------------------------------------------------------------- /files/app/views/home/index-subdomains_app.html.erb: -------------------------------------------------------------------------------- 1 |

    Home

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

    <%= user.name %> <%= link_to root_url(:subdomain => user.name), root_url(:subdomain => user.name) %>

    4 | <% end %> 5 | -------------------------------------------------------------------------------- /files/app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 |

    Home

    2 | -------------------------------------------------------------------------------- /files/app/views/layouts/_messages-bootstrap.html.erb: -------------------------------------------------------------------------------- 1 | <% flash.each do |name, msg| %> 2 | <% if msg.is_a?(String) %> 3 |
    "> 4 | × 5 | <%= content_tag :div, msg, :id => "flash_#{name}" %> 6 |
    7 | <% end %> 8 | <% end %> 9 | -------------------------------------------------------------------------------- /files/app/views/layouts/_messages.html.erb: -------------------------------------------------------------------------------- 1 | <% flash.each do |name, msg| %> 2 | <% if msg.is_a?(String) %> 3 | <%= content_tag :div, msg, :id => "flash_#{name}" %> 4 | <% end %> 5 | <% end %> 6 | -------------------------------------------------------------------------------- /files/app/views/layouts/_navigation-cancan-omniauth.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "Home", root_path, :class => 'brand' %> 2 | 20 | -------------------------------------------------------------------------------- /files/app/views/layouts/_navigation-cancan.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "Home", root_path, :class => 'brand' %> 2 | 27 | -------------------------------------------------------------------------------- /files/app/views/layouts/_navigation-devise.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "Home", root_path, :class => 'brand' %> 2 | 22 | -------------------------------------------------------------------------------- /files/app/views/layouts/_navigation-omniauth.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "Home", root_path, :class => 'brand' %> 2 | 16 | -------------------------------------------------------------------------------- /files/app/views/layouts/_navigation-subdomains_app.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "Home", root_path, :class => 'brand' %> 2 | 30 | -------------------------------------------------------------------------------- /files/app/views/layouts/_navigation.html.erb: -------------------------------------------------------------------------------- 1 | <%= link_to "Home", root_path, :class => 'brand' %> 2 | -------------------------------------------------------------------------------- /files/app/views/layouts/application-bootstrap.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= content_for?(:title) ? yield(:title) : "Home" %> 6 | "> 7 | <%= stylesheet_link_tag "application", :media => "all" %> 8 | <%= javascript_include_tag "application" %> 9 | <%= csrf_meta_tags %> 10 | <%= yield(:head) %> 11 | 12 | 13 | 20 |
    21 |
    22 |
    23 |
    24 |
    25 | <%= render 'layouts/messages' %> 26 | <%= yield %> 27 |
    28 |
    29 |
    30 |
    31 |
    32 |
    33 |
    34 | 35 | 36 | -------------------------------------------------------------------------------- /files/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= content_for?(:title) ? yield(:title) : "Home" %> 6 | "> 7 | <%= stylesheet_link_tag "application", :media => "all" %> 8 | <%= javascript_include_tag "application" %> 9 | <%= csrf_meta_tags %> 10 | <%= yield(:head) %> 11 | 12 | 13 |
    14 |
    15 | <%= render 'layouts/navigation' %> 16 | <%= render 'layouts/messages' %> 17 |
    18 |
    19 | <%= yield %> 20 |
    21 |
    22 |
    23 |
    24 | 25 | 26 | -------------------------------------------------------------------------------- /files/app/views/profiles/show-subdomains_app.html.erb: -------------------------------------------------------------------------------- 1 |

    Profile

    2 |

    <%= @user.name %>

    3 |

    <%= @user.email %>

    4 | -------------------------------------------------------------------------------- /files/app/views/users/_user-simple_form.html.erb: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /files/app/views/users/_user.html.erb: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /files/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/app/views/users/index-admin_app.html.erb: -------------------------------------------------------------------------------- 1 |

    Users

    2 |
    3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | <% @users.each do |user| %> 16 | 17 | 18 | 19 | 20 | 21 | 25 | 26 | 27 | <% end %> 28 | 29 |
    UsernameEmailRegisteredRole
    <%= link_to user.name, user %><%= user.email %><%= user.created_at.to_date %><%= user.roles.first.name.titleize unless user.roles.first.nil? %> 22 | Change role 23 | <%= render user %> 24 | <%= link_to("Delete user", user_path(user), :data => { :confirm => "Are you sure?" }, :method => :delete, :class => 'btn btn-mini') unless user == current_user %>
    30 |
    31 | -------------------------------------------------------------------------------- /files/app/views/users/index.html.erb: -------------------------------------------------------------------------------- 1 |

    Users

    2 |
      3 | <% @users.each do |user| %> 4 |
    • 5 | <%= link_to user.name, user %> signed up <%= user.created_at.to_date %> 6 |
    • 7 | <% end %> 8 |
    9 | -------------------------------------------------------------------------------- /files/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/app/views/users/show.html.erb: -------------------------------------------------------------------------------- 1 |

    User

    2 |

    User: <%= @user.name %>

    3 |

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

    4 | <%= link_to 'Edit account', edit_user_path %> 5 | -------------------------------------------------------------------------------- /files/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/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 | host: localhost 18 | encoding: unicode 19 | database: myapp_development 20 | pool: 5 21 | username: myapp 22 | password: 23 | template: template0 24 | 25 | # Connect on a TCP socket. Omitted by default since the client uses a 26 | # domain socket that doesn't need configuration. Windows does not have 27 | # domain sockets, so uncomment these lines. 28 | #host: localhost 29 | #port: 5432 30 | 31 | # Schema search path. The server defaults to $user,public 32 | #schema_search_path: myapp,sharedapp,public 33 | 34 | # Minimum log levels, in increasing order: 35 | # debug5, debug4, debug3, debug2, debug1, 36 | # log, notice, warning, error, fatal, and panic 37 | # The server defaults to notice. 38 | #min_messages: warning 39 | 40 | # Warning: The database defined as "test" will be erased and 41 | # re-generated from your development database when you run "rake". 42 | # Do not set this db to the same as development or production. 43 | test: 44 | adapter: postgresql 45 | host: localhost 46 | encoding: unicode 47 | database: myapp_test 48 | pool: 5 49 | username: myapp 50 | password: 51 | template: template0 52 | 53 | production: 54 | adapter: postgresql 55 | host: localhost 56 | encoding: unicode 57 | database: myapp_production 58 | pool: 5 59 | username: myapp 60 | password: 61 | template: template0 62 | -------------------------------------------------------------------------------- /files/config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rails secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | # If you are using Rails 5.2 or newer, consider using the 14 | # encrypted credentials feature described here: 15 | # http://edgeguides.rubyonrails.org/security.html#custom-credentials 16 | 17 | development: 18 | secret_key_base: very_long_random_string 19 | 20 | test: 21 | secret_key_base: very_long_random_string 22 | 23 | # Do not keep production secrets in the repository, 24 | # instead read values from the environment. 25 | production: 26 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 27 | -------------------------------------------------------------------------------- /files/gitignore.txt: -------------------------------------------------------------------------------- 1 | #---------------------------------------------------------------------------- 2 | # Ignore these files when committing 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/rails-composer/blob/master/files/gitignore.txt 8 | # 9 | # Corrections? Improvements? Create a GitHub issue: 10 | # http://github.com/RailsApps/rails-composer/issues 11 | #---------------------------------------------------------------------------- 12 | 13 | # bundler state 14 | /.bundle 15 | /vendor/bundle/ 16 | /vendor/ruby/ 17 | 18 | # minimal Rails specific artifacts 19 | db/*.sqlite3 20 | /db/*.sqlite3-journal 21 | /log/* 22 | /tmp/* 23 | 24 | # add /config/database.yml if it contains passwords 25 | # /config/database.yml 26 | 27 | # various artifacts 28 | **.war 29 | *.rbc 30 | *.sassc 31 | .redcar/ 32 | .sass-cache 33 | /config/config.yml 34 | /coverage.data 35 | /coverage/ 36 | /db/*.javadb/ 37 | /db/*.sqlite3 38 | /doc/api/ 39 | /doc/app/ 40 | /doc/features.html 41 | /doc/specs.html 42 | /public/cache 43 | /public/stylesheets/compiled 44 | /public/system/* 45 | /spec/tmp/* 46 | /cache 47 | /capybara* 48 | /capybara-*.html 49 | /gems 50 | /specifications 51 | rerun.txt 52 | pickle-email-*.html 53 | .zeus.sock 54 | 55 | # If you find yourself ignoring temporary files generated by your text editor 56 | # or operating system, you probably want to add a global ignore instead: 57 | # git config --global core.excludesfile ~/.gitignore_global 58 | # 59 | # Here are some files you may want to ignore globally: 60 | 61 | # scm revert files 62 | **.orig 63 | 64 | # Mac finder artifacts 65 | .DS_Store 66 | 67 | # Netbeans project directory 68 | /nbproject/ 69 | 70 | # RubyMine project files 71 | .idea 72 | 73 | # Textmate project files 74 | /*.tmproj 75 | 76 | # vim artifacts 77 | **.swp 78 | 79 | # Environment files that may contain sensitive data 80 | .env 81 | .powenv 82 | 83 | # tilde files are usually backup files from a text editor 84 | *~ 85 | -------------------------------------------------------------------------------- /files/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.io/ 21 | -------------------------------------------------------------------------------- /railsComposer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash --login 2 | # railsComposer.sh 3 | 4 | # ./railsComposer.sh AppName 5 | 6 | myapp=$1 7 | 8 | mkdir $myapp 9 | cd $myapp 10 | rvm use ruby-2.1.1@$myapp --ruby-version --create 11 | gem install rails 12 | rails new . -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb --------------------------------------------------------------------------------