rails_apps_composer 1.5.5 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.textile +185 -254
- data/lib/rails_wizard/command.rb +54 -13
- data/lib/rails_wizard/config.rb +1 -1
- data/lib/rails_wizard/diagnostics.rb +22 -0
- data/lib/rails_wizard/template.rb +36 -2
- data/lib/rails_wizard.rb +1 -0
- data/recipes/auth.rb +84 -0
- data/recipes/controllers.rb +58 -0
- data/recipes/{seed_database.rb → database.rb} +35 -22
- data/recipes/{action_mailer.rb → email.rb} +29 -50
- data/recipes/example.rb +70 -0
- data/recipes/extras.rb +91 -30
- data/recipes/frontend.rb +59 -0
- data/recipes/gems.rb +128 -0
- data/recipes/models.rb +61 -0
- data/recipes/prelaunch.rb +45 -0
- data/recipes/readme.rb +83 -0
- data/recipes/routes.rb +36 -0
- data/recipes/setup.rb +148 -0
- data/recipes/testing.rb +187 -0
- data/recipes/views.rb +39 -0
- data/spec/rails_wizard/template_spec.rb +4 -2
- data/templates/helpers.erb +53 -2
- data/templates/layout.erb +81 -20
- data/version.rb +1 -1
- metadata +19 -49
- data/recipes/active_admin.rb +0 -36
- data/recipes/activerecord.rb +0 -37
- data/recipes/add_user.rb +0 -140
- data/recipes/airbrake.rb +0 -34
- data/recipes/backbone.rb +0 -23
- data/recipes/capybara.rb +0 -34
- data/recipes/cleanup.rb +0 -40
- data/recipes/cloudfiles.rb +0 -36
- data/recipes/compass.rb +0 -46
- data/recipes/compass_960.rb +0 -48
- data/recipes/cucumber.rb +0 -75
- data/recipes/datamapper.rb +0 -111
- data/recipes/devise.rb +0 -114
- data/recipes/git.rb +0 -40
- data/recipes/guard.rb +0 -89
- data/recipes/haml.rb +0 -23
- data/recipes/heroku.rb +0 -61
- data/recipes/home_page.rb +0 -58
- data/recipes/home_page_users.rb +0 -47
- data/recipes/html5.rb +0 -152
- data/recipes/inherited_resources.rb +0 -23
- data/recipes/less.rb +0 -12
- data/recipes/mongohq.rb +0 -59
- data/recipes/mongoid.rb +0 -38
- data/recipes/mongolab.rb +0 -59
- data/recipes/omniauth.rb +0 -194
- data/recipes/omniauth_email.rb +0 -82
- data/recipes/paperclip.rb +0 -79
- data/recipes/prelaunch_signup.rb +0 -586
- data/recipes/rails_admin.rb +0 -29
- data/recipes/redis.rb +0 -23
- data/recipes/responders.rb +0 -10
- data/recipes/resque.rb +0 -25
- data/recipes/rspec.rb +0 -131
- data/recipes/sass.rb +0 -25
- data/recipes/settingslogic.rb +0 -43
- data/recipes/simple_form.rb +0 -54
- data/recipes/slim.rb +0 -46
- data/recipes/static_page.rb +0 -43
- data/recipes/subdomains.rb +0 -121
- data/recipes/turnip.rb +0 -18
- data/recipes/unicorn.rb +0 -29
- data/recipes/users_page.rb +0 -165
data/recipes/paperclip.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
if config['paperclip']
|
2
|
-
if recipes.include? 'mongoid'
|
3
|
-
gem 'mongoid-paperclip'
|
4
|
-
else
|
5
|
-
gem 'paperclip'
|
6
|
-
end
|
7
|
-
else
|
8
|
-
recipes.delete('paperclip')
|
9
|
-
end
|
10
|
-
|
11
|
-
if config['paperclip']
|
12
|
-
after_bundler do
|
13
|
-
# Code here is run after Bundler installs all the gems for the project.
|
14
|
-
# You can run generators and rake tasks in this section.
|
15
|
-
if recipes.include? 'mongoid'
|
16
|
-
create_file 'config/initializers/mongoid-paperclip.rb' do
|
17
|
-
<<-RUBY
|
18
|
-
require 'mongoid_paperclip'
|
19
|
-
RUBY
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
if recipes.include? 'cloudfiles'
|
24
|
-
# Add Storage module file for paperclip in lib
|
25
|
-
get 'https://raw.github.com/gist/2476222/986bf7a49556ac549b75768af5dce2e6e4c67b61/Cloudfilesstorage.rb', 'lib/cloud_files_storage.rb'
|
26
|
-
# Add config initialize file
|
27
|
-
create_file 'config/initializers/cloudfiles.rb' do
|
28
|
-
<<-RUBY
|
29
|
-
require 'cloudfiles'
|
30
|
-
require 'cloud_files_storage'
|
31
|
-
RUBY
|
32
|
-
end
|
33
|
-
|
34
|
-
create_file 'config/rackspace_cloudfiles.yml' do
|
35
|
-
<<-YAML
|
36
|
-
DEFAULTS: &DEFAULTS
|
37
|
-
username: [username]
|
38
|
-
api_key: [api_key]
|
39
|
-
|
40
|
-
development:
|
41
|
-
<<: *DEFAULTS
|
42
|
-
container: [container name]
|
43
|
-
|
44
|
-
test:
|
45
|
-
<<: *DEFAULTS
|
46
|
-
container: [container name]
|
47
|
-
|
48
|
-
production:
|
49
|
-
<<: *DEFAULTS
|
50
|
-
container: [container name]
|
51
|
-
YAML
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
if config['paperclip']
|
58
|
-
after_everything do
|
59
|
-
# These blocks are run after the bundler blocks and are reserved for
|
60
|
-
# special cases like committing the files to a git repository (something
|
61
|
-
# that depends on everything having been generated).
|
62
|
-
end
|
63
|
-
end
|
64
|
-
# A recipe is two parts: the Ruby code and YAML back-matter that comes
|
65
|
-
# after a blank line with the __END__ keyword.
|
66
|
-
|
67
|
-
__END__
|
68
|
-
|
69
|
-
name: Paperclip
|
70
|
-
description: "Use paperclip for file uploading."
|
71
|
-
author: merlinvn
|
72
|
-
|
73
|
-
category: persistence
|
74
|
-
tags: [storage]
|
75
|
-
|
76
|
-
config:
|
77
|
-
- paperclip:
|
78
|
-
type: boolean
|
79
|
-
prompt: "Would you like to use Paperclip to store your files?"
|
data/recipes/prelaunch_signup.rb
DELETED
@@ -1,586 +0,0 @@
|
|
1
|
-
# Application template recipe for the rails_apps_composer. Check for a newer version here:
|
2
|
-
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/prelaunch_signup.rb
|
3
|
-
|
4
|
-
@recipes = ["haml", "rspec", "cucumber", "action_mailer", "devise", "add_user",
|
5
|
-
"home_page", "seed_database", "users_page", "html5", "simple_form",
|
6
|
-
"cleanup", "extras", "git"]
|
7
|
-
|
8
|
-
# >-------------------------------[ Create an Initializer File ]--------------------------------<
|
9
|
-
create_file 'config/initializers/prelaunch-signup.rb' do <<-RUBY
|
10
|
-
# change to "true" (and restart) when you want visitors to sign up without an invitation
|
11
|
-
Rails.configuration.launched = false
|
12
|
-
RUBY
|
13
|
-
end
|
14
|
-
|
15
|
-
# >---------------------------------[ HAML ]----------------------------------<
|
16
|
-
gem 'haml', '>= 3.1.6'
|
17
|
-
gem 'haml-rails', '>= 0.3.4', :group => :development
|
18
|
-
|
19
|
-
# >---------------------------------[ RSpec ]---------------------------------<
|
20
|
-
|
21
|
-
gem 'rspec-rails', '>= 2.11.0', :group => [:development, :test]
|
22
|
-
gem 'factory_girl_rails', '>= 3.5.0', :group => [:development, :test]
|
23
|
-
# add a collection of RSpec matchers and Cucumber steps to make testing email easy
|
24
|
-
gem 'email_spec', '>= 1.2.1', :group => :test
|
25
|
-
create_file 'features/support/email_spec.rb' do <<-RUBY
|
26
|
-
require 'email_spec/cucumber'
|
27
|
-
RUBY
|
28
|
-
end
|
29
|
-
|
30
|
-
after_bundler do
|
31
|
-
say_wizard "RSpec recipe running 'after bundler'"
|
32
|
-
generate 'rspec:install'
|
33
|
-
generate 'email_spec:steps'
|
34
|
-
inject_into_file 'spec/spec_helper.rb', "require 'email_spec'\n", :after => "require 'rspec/rails'\n"
|
35
|
-
inject_into_file 'spec/spec_helper.rb', :after => "RSpec.configure do |config|\n" do <<-RUBY
|
36
|
-
config.include(EmailSpec::Helpers)
|
37
|
-
config.include(EmailSpec::Matchers)
|
38
|
-
RUBY
|
39
|
-
end
|
40
|
-
say_wizard "Removing test folder (not needed for RSpec)"
|
41
|
-
run 'rm -rf test/'
|
42
|
-
inject_into_file 'config/application.rb', :after => "Rails::Application\n" do <<-RUBY
|
43
|
-
|
44
|
-
# don't generate RSpec tests for views and helpers
|
45
|
-
config.generators do |g|
|
46
|
-
g.view_specs false
|
47
|
-
g.helper_specs false
|
48
|
-
end
|
49
|
-
|
50
|
-
RUBY
|
51
|
-
end
|
52
|
-
if recipes.include? 'devise'
|
53
|
-
# add Devise test helpers
|
54
|
-
create_file 'spec/support/devise.rb' do
|
55
|
-
<<-RUBY
|
56
|
-
RSpec.configure do |config|
|
57
|
-
config.include Devise::TestHelpers, :type => :controller
|
58
|
-
end
|
59
|
-
RUBY
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
after_everything do
|
64
|
-
say_wizard "Copying RSpec files from the rails-prelaunch-signup example app"
|
65
|
-
begin
|
66
|
-
remove_file 'spec/factories/users.rb'
|
67
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/spec/factories/users.rb', 'spec/factories/users.rb'
|
68
|
-
gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at"
|
69
|
-
remove_file 'spec/controllers/home_controller_spec.rb'
|
70
|
-
remove_file 'spec/controllers/users_controller_spec.rb'
|
71
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/spec/controllers/home_controller_spec.rb', 'spec/controllers/home_controller_spec.rb'
|
72
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/spec/controllers/users_controller_spec.rb', 'spec/controllers/users_controller_spec.rb'
|
73
|
-
remove_file 'spec/models/user_spec.rb'
|
74
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/spec/models/user_spec.rb', 'spec/models/user_spec.rb'
|
75
|
-
rescue OpenURI::HTTPError
|
76
|
-
say_wizard "Unable to obtain RSpec example files from the repo"
|
77
|
-
end
|
78
|
-
remove_file 'spec/views/home/index.html.erb_spec.rb'
|
79
|
-
remove_file 'spec/views/home/index.html.haml_spec.rb'
|
80
|
-
remove_file 'spec/views/users/show.html.erb_spec.rb'
|
81
|
-
remove_file 'spec/views/users/show.html.haml_spec.rb'
|
82
|
-
remove_file 'spec/helpers/home_helper_spec.rb'
|
83
|
-
remove_file 'spec/helpers/users_helper_spec.rb'
|
84
|
-
end
|
85
|
-
|
86
|
-
# >-------------------------------[ Cucumber ]--------------------------------<
|
87
|
-
gem 'cucumber-rails', '>= 1.3.0', :group => :test, :require => false
|
88
|
-
gem 'capybara', '>= 1.1.2', :group => :test
|
89
|
-
gem 'database_cleaner', '>= 0.8.0', :group => :test
|
90
|
-
gem 'launchy', '>= 2.1.0', :group => :test
|
91
|
-
|
92
|
-
after_bundler do
|
93
|
-
say_wizard "Cucumber recipe running 'after bundler'"
|
94
|
-
generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D' if recipes.include?('mongoid')}"
|
95
|
-
# make it easy to run Cucumber for single features without adding "--require features" to the command line
|
96
|
-
gsub_file 'config/cucumber.yml', /std_opts = "/, 'std_opts = "-r features/support/ -r features/step_definitions '
|
97
|
-
end
|
98
|
-
|
99
|
-
after_bundler do
|
100
|
-
say_wizard "Copying Cucumber scenarios from the rails-prelaunch-signup example app"
|
101
|
-
begin
|
102
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/admin/send_invitations.feature', 'features/admin/send_invitations.feature'
|
103
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/admin/view_progress.feature', 'features/admin/view_progress.feature'
|
104
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/step_definitions/admin_steps.rb', 'features/step_definitions/admin_steps.rb'
|
105
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/step_definitions/email_steps.rb', 'features/step_definitions/email_steps.rb'
|
106
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/step_definitions/user_steps.rb', 'features/step_definitions/user_steps.rb'
|
107
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/step_definitions/visitor_steps.rb', 'features/step_definitions/visitor_steps.rb'
|
108
|
-
remove_file 'features/support/paths.rb'
|
109
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/support/paths.rb', 'features/support/paths.rb'
|
110
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/users/sign_in.feature', 'features/users/sign_in.feature'
|
111
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/users/sign_out.feature', 'features/users/sign_out.feature'
|
112
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/users/sign_up.feature', 'features/users/sign_up.feature'
|
113
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/users/user_edit.feature', 'features/users/user_edit.feature'
|
114
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/users/user_show.feature', 'features/users/user_show.feature'
|
115
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/features/visitors/request_invitation.feature', 'features/visitors/request_invitation.feature'
|
116
|
-
# thank you page for testing registrations
|
117
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/public/thankyou.html', 'public/thankyou.html'
|
118
|
-
rescue OpenURI::HTTPError
|
119
|
-
say_wizard "Unable to obtain Cucumber example files from the repo"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
# >-----------------------------[ ActionMailer ]------------------------------<
|
124
|
-
case config['mailer']
|
125
|
-
when 'smtp'
|
126
|
-
recipes << 'smtp'
|
127
|
-
when 'gmail'
|
128
|
-
recipes << 'gmail'
|
129
|
-
when 'sendgrid'
|
130
|
-
gem 'sendgrid'
|
131
|
-
recipes << 'sendgrid'
|
132
|
-
when 'mandrill'
|
133
|
-
gem 'hominid'
|
134
|
-
recipes << 'mandrill'
|
135
|
-
end
|
136
|
-
|
137
|
-
after_bundler do
|
138
|
-
### modifying environment configuration files for ActionMailer
|
139
|
-
say_wizard "ActionMailer recipe running 'after bundler'"
|
140
|
-
### development environment
|
141
|
-
gsub_file 'config/environments/development.rb', /# Don't care if the mailer can't send/, '# ActionMailer Config'
|
142
|
-
gsub_file 'config/environments/development.rb', /config.action_mailer.raise_delivery_errors = false/ do
|
143
|
-
<<-RUBY
|
144
|
-
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
145
|
-
config.action_mailer.delivery_method = :smtp
|
146
|
-
# change to true to allow email to be sent during development
|
147
|
-
config.action_mailer.perform_deliveries = false
|
148
|
-
config.action_mailer.raise_delivery_errors = true
|
149
|
-
config.action_mailer.default :charset => "utf-8"
|
150
|
-
RUBY
|
151
|
-
end
|
152
|
-
### test environment
|
153
|
-
inject_into_file 'config/environments/test.rb', :before => "\nend" do
|
154
|
-
<<-RUBY
|
155
|
-
\n
|
156
|
-
# ActionMailer Config
|
157
|
-
config.action_mailer.default_url_options = { :host => 'example.com' }
|
158
|
-
RUBY
|
159
|
-
end
|
160
|
-
### production environment
|
161
|
-
gsub_file 'config/environments/production.rb', /config.active_support.deprecation = :notify/ do
|
162
|
-
<<-RUBY
|
163
|
-
config.active_support.deprecation = :notify
|
164
|
-
|
165
|
-
config.action_mailer.default_url_options = { :host => 'example.com' }
|
166
|
-
# ActionMailer Config
|
167
|
-
# Setup for production - deliveries, no errors raised
|
168
|
-
config.action_mailer.delivery_method = :smtp
|
169
|
-
config.action_mailer.perform_deliveries = true
|
170
|
-
config.action_mailer.raise_delivery_errors = false
|
171
|
-
config.action_mailer.default :charset => "utf-8"
|
172
|
-
RUBY
|
173
|
-
end
|
174
|
-
### modifying environment configuration files to send email using a GMail account
|
175
|
-
if recipes.include? 'gmail'
|
176
|
-
gmail_configuration_text = <<-TEXT
|
177
|
-
\n
|
178
|
-
config.action_mailer.smtp_settings = {
|
179
|
-
address: "smtp.gmail.com",
|
180
|
-
port: 587,
|
181
|
-
domain: "example.com",
|
182
|
-
authentication: "plain",
|
183
|
-
enable_starttls_auto: true,
|
184
|
-
user_name: ENV["GMAIL_USERNAME"],
|
185
|
-
password: ENV["GMAIL_PASSWORD"]
|
186
|
-
}
|
187
|
-
TEXT
|
188
|
-
say_wizard gmail_configuration_text
|
189
|
-
inject_into_file 'config/environments/development.rb', gmail_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
|
190
|
-
inject_into_file 'config/environments/production.rb', gmail_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
|
191
|
-
end
|
192
|
-
### modifying environment configuration files to send email using a SendGrid account
|
193
|
-
if recipes.include? 'sendgrid'
|
194
|
-
sendgrid_configuration_text = <<-TEXT
|
195
|
-
\n
|
196
|
-
config.action_mailer.smtp_settings = {
|
197
|
-
address: "smtp.sendgrid.net",
|
198
|
-
port: 25,
|
199
|
-
domain: "example.com",
|
200
|
-
authentication: "plain",
|
201
|
-
user_name: ENV["SENDGRID_USERNAME"],
|
202
|
-
password: ENV["SENDGRID_PASSWORD"]
|
203
|
-
}
|
204
|
-
TEXT
|
205
|
-
say_wizard gmail_configuration_text
|
206
|
-
inject_into_file 'config/environments/development.rb', sendgrid_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
|
207
|
-
inject_into_file 'config/environments/production.rb', sendgrid_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
|
208
|
-
end
|
209
|
-
### modifying environment configuration files to send email using a Mandrill account
|
210
|
-
if recipes.include? 'mandrill'
|
211
|
-
mandrill_configuration_text = <<-TEXT
|
212
|
-
\n
|
213
|
-
config.action_mailer.smtp_settings = {
|
214
|
-
:address => "smtp.mandrillapp.com",
|
215
|
-
:port => 25,
|
216
|
-
:user_name => ENV["MANDRILL_USERNAME"],
|
217
|
-
:password => ENV["MANDRILL_API_KEY"]
|
218
|
-
}
|
219
|
-
TEXT
|
220
|
-
say_wizard gmail_configuration_text
|
221
|
-
inject_into_file 'config/environments/development.rb', mandrill_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
|
222
|
-
inject_into_file 'config/environments/production.rb', mandrill_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
# >--------------------------------[ Devise ]---------------------------------<
|
227
|
-
gem 'devise', '>= 2.1.2'
|
228
|
-
gem 'devise_invitable', '>= 1.0.2'
|
229
|
-
recipes << 'devise-confirmable'
|
230
|
-
recipes << 'devise-invitable'
|
231
|
-
gem 'cancan', '>= 1.6.8'
|
232
|
-
gem 'rolify', '>= 3.1.0'
|
233
|
-
recipes << 'authorization'
|
234
|
-
|
235
|
-
after_bundler do
|
236
|
-
say_wizard "Devise recipe running 'after bundler'"
|
237
|
-
# Run the Devise generator
|
238
|
-
generate 'devise:install' unless recipes.include? 'datamapper'
|
239
|
-
generate 'devise_invitable:install' if recipes.include? 'devise-invitable'
|
240
|
-
# Prevent logging of password_confirmation
|
241
|
-
gsub_file 'config/application.rb', /:password/, ':password, :password_confirmation'
|
242
|
-
if recipes.include? 'cucumber'
|
243
|
-
# Cucumber wants to test GET requests not DELETE requests for destroy_user_session_path
|
244
|
-
# (see https://github.com/RailsApps/rails3-devise-rspec-cucumber/issues/3)
|
245
|
-
gsub_file 'config/initializers/devise.rb', 'config.sign_out_via = :delete', 'config.sign_out_via = Rails.env.test? ? :get : :delete'
|
246
|
-
end
|
247
|
-
if recipes.include? 'authorization'
|
248
|
-
inject_into_file 'app/controllers/application_controller.rb', :before => 'end' do <<-RUBY
|
249
|
-
rescue_from CanCan::AccessDenied do |exception|
|
250
|
-
redirect_to root_path, :alert => exception.message
|
251
|
-
end
|
252
|
-
RUBY
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
# >--------------------------------[ AddUser ]--------------------------------<
|
258
|
-
after_bundler do
|
259
|
-
say_wizard "AddUser recipe running 'after bundler'"
|
260
|
-
if recipes.include? 'devise'
|
261
|
-
# Generate models and routes for a User
|
262
|
-
generate 'devise user'
|
263
|
-
if recipes.include? 'authorization'
|
264
|
-
# create'app/models/ability.rb'
|
265
|
-
generate 'cancan:ability'
|
266
|
-
# create 'app/models/role.rb'
|
267
|
-
# create 'config/initializers/rolify.rb'
|
268
|
-
# create 'db/migrate/...rolify_create_roles.rb'
|
269
|
-
# insert 'rolify' method in 'app/models/users.rb'
|
270
|
-
generate 'rolify:role Role User'
|
271
|
-
end
|
272
|
-
# Add a 'name' attribute to the User model
|
273
|
-
# Devise created a Users database, we'll modify it
|
274
|
-
generate 'migration AddNameToUsers name:string'
|
275
|
-
if recipes.include? 'devise-confirmable'
|
276
|
-
generate 'migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string'
|
277
|
-
end
|
278
|
-
# Devise created a Users model, we'll replace it
|
279
|
-
remove_file 'app/models/user.rb'
|
280
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/models/user.rb', 'app/models/user.rb'
|
281
|
-
# copy Haml versions of modified Devise views (plus a partial for the 'thank you' message)
|
282
|
-
remove_file 'app/views/devise/shared/_links.html.haml'
|
283
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/devise/shared/_links.html.haml', 'app/views/devise/shared/_links.html.haml'
|
284
|
-
remove_file 'app/views/devise/registrations/edit.html.haml'
|
285
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/devise/registrations/edit.html.haml', 'app/views/devise/registrations/edit.html.haml'
|
286
|
-
remove_file 'app/views/devise/registrations/new.html.haml'
|
287
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/devise/registrations/new.html.haml', 'app/views/devise/registrations/new.html.haml'
|
288
|
-
remove_file 'app/views/devise/registrations/_thankyou.html.haml'
|
289
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/devise/registrations/_thankyou.html.haml', 'app/views/devise/registrations/_thankyou.html.haml'
|
290
|
-
remove_file 'app/views/devise/confirmations/show.html.haml'
|
291
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/devise/confirmations/show.html.haml', 'app/views/devise/confirmations/show.html.haml'
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
# >-------------------------------[ HomePage ]--------------------------------<
|
296
|
-
after_bundler do
|
297
|
-
say_wizard "HomePage recipe running 'after bundler'"
|
298
|
-
# remove the default home page
|
299
|
-
remove_file 'public/index.html'
|
300
|
-
# create a home controller and view
|
301
|
-
generate(:controller, "home index")
|
302
|
-
# set up a simple home page (with placeholder content)
|
303
|
-
if recipes.include? 'haml'
|
304
|
-
remove_file 'app/views/home/index.html.haml'
|
305
|
-
create_file 'app/views/home/index.html.haml' do
|
306
|
-
<<-'HAML'
|
307
|
-
%h3 Welcome
|
308
|
-
HAML
|
309
|
-
end
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
# >------------------------------[ Migrations ]-------------------------------<
|
314
|
-
after_bundler do
|
315
|
-
generate 'migration AddOptinToUsers opt_in:boolean'
|
316
|
-
end
|
317
|
-
|
318
|
-
# >-----------------------------[ SeedDatabase ]------------------------------<
|
319
|
-
after_bundler do
|
320
|
-
say_wizard "SeedDatabase recipe running 'after bundler'"
|
321
|
-
if recipes.include? 'devise'
|
322
|
-
if recipes.include? 'devise-confirmable'
|
323
|
-
append_file 'db/seeds.rb' do <<-FILE
|
324
|
-
puts 'SETTING UP DEFAULT USER LOGIN'
|
325
|
-
user = User.create! :name => 'First User', :email => 'user@example.com', :password => 'please', :password_confirmation => 'please', :confirmed_at => Time.now.utc
|
326
|
-
puts 'New user created: ' << user.name
|
327
|
-
user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'please', :password_confirmation => 'please', :confirmed_at => Time.now.utc
|
328
|
-
puts 'New user created: ' << user2.name
|
329
|
-
FILE
|
330
|
-
end
|
331
|
-
end
|
332
|
-
if recipes.include? 'authorization'
|
333
|
-
append_file 'db/seeds.rb' do <<-FILE
|
334
|
-
user.add_role :admin
|
335
|
-
FILE
|
336
|
-
end
|
337
|
-
end
|
338
|
-
end
|
339
|
-
end
|
340
|
-
after_everything do
|
341
|
-
say_wizard "applying migrations and seeding the database"
|
342
|
-
if recipes.include? 'devise-invitable'
|
343
|
-
run 'bundle exec rake db:migrate'
|
344
|
-
generate 'devise_invitable user'
|
345
|
-
end
|
346
|
-
run 'bundle exec rake db:migrate'
|
347
|
-
run 'bundle exec rake db:test:prepare'
|
348
|
-
run 'bundle exec rake db:seed'
|
349
|
-
end
|
350
|
-
|
351
|
-
# >-------------------------------[ UsersPage ]-------------------------------<
|
352
|
-
gem 'google_visualr', '>= 2.1.2'
|
353
|
-
gem 'jquery-datatables-rails', '>= 1.10.0'
|
354
|
-
after_bundler do
|
355
|
-
say_wizard "UsersPage recipe running 'after bundler'"
|
356
|
-
#----------------------------------------------------------------------------
|
357
|
-
# Create a users controller
|
358
|
-
#----------------------------------------------------------------------------
|
359
|
-
generate(:controller, "users show index")
|
360
|
-
remove_file 'app/controllers/users_controller.rb'
|
361
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/controllers/users_controller.rb', 'app/controllers/users_controller.rb'
|
362
|
-
#----------------------------------------------------------------------------
|
363
|
-
# Limit access to the users#index page
|
364
|
-
#----------------------------------------------------------------------------
|
365
|
-
inject_into_file 'app/models/ability.rb', :after => "def initialize(user)\n" do <<-RUBY
|
366
|
-
user ||= User.new # guest user (not logged in)
|
367
|
-
if user.has_role? :admin
|
368
|
-
can :manage, :all
|
369
|
-
end
|
370
|
-
RUBY
|
371
|
-
end
|
372
|
-
#----------------------------------------------------------------------------
|
373
|
-
# Create a users index page
|
374
|
-
#----------------------------------------------------------------------------
|
375
|
-
remove_file 'app/views/users/index.html.haml'
|
376
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/users/index.html.haml', 'app/views/users/index.html.haml'
|
377
|
-
#----------------------------------------------------------------------------
|
378
|
-
# Create a users show page
|
379
|
-
#----------------------------------------------------------------------------
|
380
|
-
remove_file 'app/views/users/show.html.haml'
|
381
|
-
create_file 'app/views/users/show.html.haml' do <<-'HAML'
|
382
|
-
%p
|
383
|
-
User: #{@user.name}
|
384
|
-
%p
|
385
|
-
Email: #{@user.email if @user.email}
|
386
|
-
HAML
|
387
|
-
end
|
388
|
-
#----------------------------------------------------------------------------
|
389
|
-
# Create a home page containing links to user show pages
|
390
|
-
# (clobbers code from the home_page_users recipe)
|
391
|
-
#----------------------------------------------------------------------------
|
392
|
-
# set up the controller
|
393
|
-
remove_file 'app/controllers/home_controller.rb'
|
394
|
-
create_file 'app/controllers/home_controller.rb' do
|
395
|
-
<<-RUBY
|
396
|
-
class HomeController < ApplicationController
|
397
|
-
end
|
398
|
-
RUBY
|
399
|
-
end
|
400
|
-
# modify the home page
|
401
|
-
remove_file 'app/views/home/index.html.haml'
|
402
|
-
create_file 'app/views/home/index.html.haml' do
|
403
|
-
<<-'HAML'
|
404
|
-
%h3 Welcome
|
405
|
-
HAML
|
406
|
-
end
|
407
|
-
end
|
408
|
-
|
409
|
-
# >---------------------------------[ html5 ]---------------------------------<
|
410
|
-
gem 'bootstrap-sass', '>= 2.0.4.0'
|
411
|
-
recipes << 'bootstrap'
|
412
|
-
after_bundler do
|
413
|
-
say_wizard "HTML5 recipe running 'after bundler'"
|
414
|
-
# add a humans.txt file
|
415
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/humans.txt', 'public/humans.txt'
|
416
|
-
# install a front-end framework for HTML5 and CSS3
|
417
|
-
remove_file 'app/assets/stylesheets/application.css'
|
418
|
-
remove_file 'app/views/layouts/application.html.erb'
|
419
|
-
remove_file 'app/views/layouts/application.html.haml'
|
420
|
-
# Haml version of a complex application layout using Twitter Bootstrap
|
421
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/application.html.haml', 'app/views/layouts/application.html.haml'
|
422
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/_messages.html.haml', 'app/views/layouts/_messages.html.haml'
|
423
|
-
# complex css styles using Twitter Bootstrap
|
424
|
-
remove_file 'app/assets/stylesheets/application.css.scss'
|
425
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/assets/stylesheets/application.css.scss', 'app/assets/stylesheets/application.css.scss'
|
426
|
-
# get an appropriate navigation partial
|
427
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/authorization/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
|
428
|
-
gsub_file 'app/views/layouts/application.html.haml', /App_Name/, "#{app_name.humanize.titleize}"
|
429
|
-
gsub_file 'app/views/layouts/_navigation.html.haml', /App_Name/, "#{app_name.humanize.titleize}"
|
430
|
-
create_file 'app/assets/stylesheets/bootstrap_and_overrides.css.scss', <<-RUBY
|
431
|
-
// Set the correct sprite paths
|
432
|
-
$iconSpritePath: asset-url('glyphicons-halflings.png', image);
|
433
|
-
$iconWhiteSpritePath: asset-url('glyphicons-halflings-white.png', image);
|
434
|
-
@import "bootstrap";
|
435
|
-
body { padding-top: 60px; }
|
436
|
-
@import "bootstrap-responsive";
|
437
|
-
RUBY
|
438
|
-
end
|
439
|
-
|
440
|
-
# >------------------------------[ SimpleForm ]-------------------------------<
|
441
|
-
gem 'simple_form'
|
442
|
-
recipes << 'simple_form'
|
443
|
-
recipes << 'simple_form_bootstrap'
|
444
|
-
after_bundler do
|
445
|
-
say_wizard "Simple form recipe running 'after bundler'"
|
446
|
-
generate 'simple_form:install --bootstrap'
|
447
|
-
end
|
448
|
-
|
449
|
-
# >------------------------------[ JavaScript ]-------------------------------<
|
450
|
-
after_bundler do
|
451
|
-
remove_file 'app/assets/javascripts/application.js'
|
452
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/assets/javascripts/application.js', 'app/assets/javascripts/application.js'
|
453
|
-
remove_file 'app/assets/javascripts/users.js.coffee'
|
454
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/assets/javascripts/users.js.coffee', 'app/assets/javascripts/users.js.coffee'
|
455
|
-
end
|
456
|
-
|
457
|
-
# >------------------------------[ MailChimp ]-------------------------------<
|
458
|
-
# the 'app/models/user.rb' file contains methods to support MailChimp; remove and replace them if we don't want MailChimp
|
459
|
-
if config['mailchimp']
|
460
|
-
gem 'hominid'
|
461
|
-
else
|
462
|
-
after_bundler do
|
463
|
-
# drop the MailChimp methods and add a UserMailer
|
464
|
-
gsub_file 'app/models/user.rb', /after_create :add_user_to_mailchimp unless Rails.env.test\?/, 'after_create :send_welcome_email'
|
465
|
-
gsub_file 'app/models/user.rb', /before_destroy :remove_user_from_mailchimp unless Rails.env.test\?\n/, ''
|
466
|
-
inject_into_file 'app/models/user.rb', :after => "private\n" do
|
467
|
-
<<-RUBY
|
468
|
-
\n
|
469
|
-
def send_welcome_email
|
470
|
-
unless self.email.include?('@example.com') && Rails.env != 'test'
|
471
|
-
UserMailer.welcome_email(self).deliver
|
472
|
-
end
|
473
|
-
end
|
474
|
-
RUBY
|
475
|
-
end
|
476
|
-
generate 'mailer UserMailer'
|
477
|
-
remove_file 'spec/mailers/user_mailer_spec.rb'
|
478
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/spec/mailers/user_mailer_spec.rb', 'spec/mailers/user_mailer_spec.rb'
|
479
|
-
remove_file 'app/mailers/user_mailer.rb'
|
480
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/mailers/user_mailer.rb', 'app/mailers/user_mailer.rb'
|
481
|
-
if recipes.include? 'mandrill'
|
482
|
-
inject_into_file 'app/mailers/user_mailer.rb', :after => "mail(:to => user.email, :subject => \"Invitation Request Received\")\n" do <<-RUBY
|
483
|
-
headers['X-MC-Track'] = "opens, clicks"
|
484
|
-
headers['X-MC-GoogleAnalytics'] = "example.com"
|
485
|
-
headers['X-MC-Tags'] = "welcome"
|
486
|
-
RUBY
|
487
|
-
end
|
488
|
-
end
|
489
|
-
remove_file 'app/views/user_mailer/welcome_email.html.erb'
|
490
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/user_mailer/welcome_email.html.erb', 'app/views/user_mailer/welcome_email.html.erb'
|
491
|
-
remove_file 'app/views/user_mailer/welcome_email.text.erb'
|
492
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/user_mailer/welcome_email.text.erb', 'app/views/user_mailer/welcome_email.text.erb'
|
493
|
-
end
|
494
|
-
end
|
495
|
-
|
496
|
-
# >------------------------------[ Devise Email ]-------------------------------<
|
497
|
-
after_bundler do
|
498
|
-
remove_file 'app/views/devise/mailer/confirmation_instructions.html.erb'
|
499
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/views/devise/mailer/confirmation_instructions.html.erb', 'app/views/devise/mailer/confirmation_instructions.html.erb'
|
500
|
-
end
|
501
|
-
|
502
|
-
# >------------------------------[ Controllers ]-------------------------------<
|
503
|
-
after_bundler do
|
504
|
-
remove_file 'app/controllers/registrations_controller.rb'
|
505
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/controllers/registrations_controller.rb', 'app/controllers/registrations_controller.rb'
|
506
|
-
remove_file 'app/controllers/confirmations_controller.rb'
|
507
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/app/controllers/confirmations_controller.rb', 'app/controllers/confirmations_controller.rb'
|
508
|
-
end
|
509
|
-
|
510
|
-
# >------------------------------[ Routes ]-------------------------------<
|
511
|
-
after_bundler do
|
512
|
-
remove_file 'config/routes.rb'
|
513
|
-
get 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/config/routes.rb', 'config/routes.rb'
|
514
|
-
gsub_file 'config/routes.rb', /RailsPrelaunchSignup/, app_const_base
|
515
|
-
end
|
516
|
-
|
517
|
-
# >------------------------------[ Messages ]-------------------------------<
|
518
|
-
after_bundler do
|
519
|
-
gsub_file 'config/locales/devise.en.yml', /'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'/, "'Your invitation request has been received. You will receive an invitation when we launch.'"
|
520
|
-
gsub_file 'config/locales/devise.en.yml', /'You have to confirm your account before continuing.'/, "'Your account is not active.'"
|
521
|
-
end
|
522
|
-
|
523
|
-
# >--------------------------------[ Cleanup ]--------------------------------<
|
524
|
-
after_bundler do
|
525
|
-
say_wizard "Cleanup recipe running 'after bundler'"
|
526
|
-
# remove unnecessary files
|
527
|
-
%w{
|
528
|
-
README
|
529
|
-
doc/README_FOR_APP
|
530
|
-
public/index.html
|
531
|
-
app/assets/images/rails.png
|
532
|
-
}.each { |file| remove_file file }
|
533
|
-
# add placeholder READMEs
|
534
|
-
get "https://raw.github.com/RailsApps/rails3-application-templates/master/files/sample_readme.txt", "README"
|
535
|
-
get "https://raw.github.com/RailsApps/rails3-application-templates/master/files/sample_readme.textile", "README.textile"
|
536
|
-
gsub_file "README", /App_Name/, "#{app_name.humanize.titleize}"
|
537
|
-
gsub_file "README.textile", /App_Name/, "#{app_name.humanize.titleize}"
|
538
|
-
# remove commented lines and multiple blank lines from Gemfile
|
539
|
-
# thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb
|
540
|
-
gsub_file 'Gemfile', /#.*\n/, "\n"
|
541
|
-
gsub_file 'Gemfile', /\n^\s*\n/, "\n"
|
542
|
-
# remove commented lines and multiple blank lines from config/routes.rb
|
543
|
-
gsub_file 'config/routes.rb', / #.*\n/, "\n"
|
544
|
-
gsub_file 'config/routes.rb', /\n^\s*\n/, "\n"
|
545
|
-
end
|
546
|
-
|
547
|
-
# >--------------------------------[ Extras ]---------------------------------<
|
548
|
-
if config['jsruntime']
|
549
|
-
say_wizard "Adding 'therubyracer' JavaScript runtime gem"
|
550
|
-
# maybe it was already added by the html5 recipe for bootstrap_less?
|
551
|
-
unless recipes.include? 'jsruntime'
|
552
|
-
gem 'therubyracer', :group => :assets, :platform => :ruby
|
553
|
-
end
|
554
|
-
end
|
555
|
-
|
556
|
-
# >----------------------------------[ Git ]----------------------------------<
|
557
|
-
after_everything do
|
558
|
-
say_wizard "Git recipe running 'after everything'"
|
559
|
-
# Git should ignore some files
|
560
|
-
remove_file '.gitignore'
|
561
|
-
get "https://raw.github.com/RailsApps/rails3-application-templates/master/files/gitignore.txt", ".gitignore"
|
562
|
-
# Initialize new Git repo
|
563
|
-
git :init
|
564
|
-
git :add => '.'
|
565
|
-
git :commit => "-aqm 'new Rails app generated by Rails Apps Composer gem'"
|
566
|
-
end
|
567
|
-
|
568
|
-
__END__
|
569
|
-
|
570
|
-
name: PrelaunchSignup
|
571
|
-
description: "Generates a Prelaunch Signup App"
|
572
|
-
author: RailsApps
|
573
|
-
|
574
|
-
category: other
|
575
|
-
|
576
|
-
config:
|
577
|
-
- mailer:
|
578
|
-
type: multiple_choice
|
579
|
-
prompt: "How will you send email?"
|
580
|
-
choices: [["SMTP account", smtp], ["Gmail account", gmail], ["SendGrid account", sendgrid], ["Mandrill by MailChimp account", mandrill]]
|
581
|
-
- mailchimp:
|
582
|
-
type: boolean
|
583
|
-
prompt: Use MailChimp to send news and welcome messages?
|
584
|
-
- jsruntime:
|
585
|
-
type: boolean
|
586
|
-
prompt: Add 'therubyracer' JavaScript runtime (for Linux users without node.js)?
|