thyone_creator 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/thyone +7 -0
- data/lib/rails_wizard/command.rb +116 -0
- data/lib/rails_wizard/config.rb +88 -0
- data/lib/rails_wizard/recipe.rb +106 -0
- data/lib/rails_wizard/recipes.rb +38 -0
- data/lib/rails_wizard/template.rb +73 -0
- data/lib/rails_wizard.rb +10 -0
- data/recipes/action_mailer.rb +123 -0
- data/recipes/active_admin.rb +44 -0
- data/recipes/activerecord.rb +37 -0
- data/recipes/add_user.rb +129 -0
- data/recipes/airbrake.rb +34 -0
- data/recipes/backbone.rb +23 -0
- data/recipes/capybara.rb +34 -0
- data/recipes/cleanup.rb +40 -0
- data/recipes/cloudfiles.rb +36 -0
- data/recipes/compass.rb +46 -0
- data/recipes/compass_960.rb +48 -0
- data/recipes/cucumber.rb +75 -0
- data/recipes/datamapper.rb +111 -0
- data/recipes/devise.rb +114 -0
- data/recipes/extras.rb +80 -0
- data/recipes/git.rb +40 -0
- data/recipes/guard.rb +99 -0
- data/recipes/haml.rb +23 -0
- data/recipes/heroku.rb +62 -0
- data/recipes/home_page.rb +58 -0
- data/recipes/home_page_users.rb +47 -0
- data/recipes/html5.rb +153 -0
- data/recipes/inherited_resources.rb +23 -0
- data/recipes/less.rb +12 -0
- data/recipes/mongohq.rb +59 -0
- data/recipes/mongoid.rb +39 -0
- data/recipes/mongolab.rb +59 -0
- data/recipes/omniauth.rb +192 -0
- data/recipes/omniauth_email.rb +82 -0
- data/recipes/paperclip.rb +79 -0
- data/recipes/rails_admin.rb +21 -0
- data/recipes/redis.rb +23 -0
- data/recipes/responders.rb +10 -0
- data/recipes/resque.rb +25 -0
- data/recipes/rspec.rb +133 -0
- data/recipes/sass.rb +25 -0
- data/recipes/seed_database.rb +76 -0
- data/recipes/settingslogic.rb +43 -0
- data/recipes/simple_form.rb +54 -0
- data/recipes/slim.rb +46 -0
- data/recipes/static_page.rb +43 -0
- data/recipes/subdomains.rb +121 -0
- data/recipes/users_page.rb +165 -0
- data/spec/rails_wizard/config_spec.rb +108 -0
- data/spec/rails_wizard/recipe_spec.rb +81 -0
- data/spec/rails_wizard/recipes/sanity_spec.rb +30 -0
- data/spec/rails_wizard/recipes_spec.rb +24 -0
- data/spec/rails_wizard/template_spec.rb +78 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/rails_directory.rb +17 -0
- data/spec/support/template_runner.rb +28 -0
- data/templates/helpers.erb +45 -0
- data/templates/layout.erb +83 -0
- data/templates/recipe.erb +10 -0
- data/version.rb +3 -0
- metadata +251 -0
data/recipes/devise.rb
ADDED
@@ -0,0 +1,114 @@
|
|
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/devise.rb
|
3
|
+
|
4
|
+
case config['devise']
|
5
|
+
when 'no'
|
6
|
+
recipes.delete('devise')
|
7
|
+
say_wizard "Devise recipe skipped."
|
8
|
+
when 'standard'
|
9
|
+
gem 'devise', '>= 2.1.0'
|
10
|
+
when 'confirmable'
|
11
|
+
gem 'devise', '>= 2.1.0'
|
12
|
+
recipes << 'devise-confirmable'
|
13
|
+
when 'invitable'
|
14
|
+
gem 'devise', '>= 2.1.0'
|
15
|
+
gem 'devise_invitable', '>= 1.0.1'
|
16
|
+
recipes << 'devise-confirmable'
|
17
|
+
recipes << 'devise-invitable'
|
18
|
+
else
|
19
|
+
recipes.delete('devise')
|
20
|
+
say_wizard "Devise recipe skipped."
|
21
|
+
end
|
22
|
+
|
23
|
+
if config['authorization']
|
24
|
+
gem 'cancan', '>= 1.6.7'
|
25
|
+
gem 'rolify', '>= 3.1.0'
|
26
|
+
recipes << 'authorization'
|
27
|
+
end
|
28
|
+
|
29
|
+
if recipes.include? 'devise'
|
30
|
+
after_bundler do
|
31
|
+
|
32
|
+
say_wizard "Devise recipe running 'after bundler'"
|
33
|
+
|
34
|
+
# Run the Devise generator
|
35
|
+
generate 'devise:install' unless recipes.include? 'datamapper'
|
36
|
+
generate 'devise_invitable:install' if recipes.include? 'devise-invitable'
|
37
|
+
|
38
|
+
if recipes.include? 'mongo_mapper'
|
39
|
+
gem 'mm-devise'
|
40
|
+
gsub_file 'config/initializers/devise.rb', 'devise/orm/', 'devise/orm/mongo_mapper_active_model'
|
41
|
+
generate 'mongo_mapper:devise User'
|
42
|
+
elsif recipes.include? 'mongoid'
|
43
|
+
# Nothing to do (Devise changes its initializer automatically when Mongoid is detected)
|
44
|
+
# gsub_file 'config/initializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongoid'
|
45
|
+
end
|
46
|
+
|
47
|
+
# Prevent logging of password_confirmation
|
48
|
+
gsub_file 'config/application.rb', /:password/, ':password, :password_confirmation'
|
49
|
+
|
50
|
+
if recipes.include? 'cucumber'
|
51
|
+
# Cucumber wants to test GET requests not DELETE requests for destroy_user_session_path
|
52
|
+
# (see https://github.com/RailsApps/rails3-devise-rspec-cucumber/issues/3)
|
53
|
+
gsub_file 'config/initializers/devise.rb', 'config.sign_out_via = :delete', 'config.sign_out_via = Rails.env.test? ? :get : :delete'
|
54
|
+
end
|
55
|
+
|
56
|
+
if config['authorization']
|
57
|
+
inject_into_file 'app/controllers/application_controller.rb', :before => 'end' do <<-RUBY
|
58
|
+
rescue_from CanCan::AccessDenied do |exception|
|
59
|
+
redirect_to root_path, :alert => exception.message
|
60
|
+
end
|
61
|
+
RUBY
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
after_everything do
|
68
|
+
|
69
|
+
say_wizard "Devise recipe running 'after everything'"
|
70
|
+
|
71
|
+
if recipes.include? 'rspec'
|
72
|
+
say_wizard "Copying RSpec files from the rails3-devise-rspec-cucumber examples"
|
73
|
+
begin
|
74
|
+
# copy all the RSpec specs files from the rails3-devise-rspec-cucumber example app
|
75
|
+
remove_file 'spec/factories/users.rb'
|
76
|
+
get 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/spec/factories/users.rb', 'spec/factories/users.rb'
|
77
|
+
gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at" if recipes.include? 'devise-confirmable'
|
78
|
+
remove_file 'spec/controllers/home_controller_spec.rb'
|
79
|
+
remove_file 'spec/controllers/users_controller_spec.rb'
|
80
|
+
get 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/spec/controllers/home_controller_spec.rb', 'spec/controllers/home_controller_spec.rb'
|
81
|
+
get 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/spec/controllers/users_controller_spec.rb', 'spec/controllers/users_controller_spec.rb'
|
82
|
+
remove_file 'spec/models/user_spec.rb'
|
83
|
+
get 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/spec/models/user_spec.rb', 'spec/models/user_spec.rb'
|
84
|
+
rescue OpenURI::HTTPError
|
85
|
+
say_wizard "Unable to obtain RSpec example files from the repo"
|
86
|
+
end
|
87
|
+
remove_file 'spec/views/home/index.html.erb_spec.rb'
|
88
|
+
remove_file 'spec/views/home/index.html.haml_spec.rb'
|
89
|
+
remove_file 'spec/views/users/show.html.erb_spec.rb'
|
90
|
+
remove_file 'spec/views/users/show.html.haml_spec.rb'
|
91
|
+
remove_file 'spec/helpers/home_helper_spec.rb'
|
92
|
+
remove_file 'spec/helpers/users_helper_spec.rb'
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
__END__
|
99
|
+
|
100
|
+
name: Devise
|
101
|
+
description: Utilize Devise for authentication, automatically configured for your selected ORM.
|
102
|
+
author: RailsApps
|
103
|
+
|
104
|
+
category: authentication
|
105
|
+
exclusive: authentication
|
106
|
+
|
107
|
+
config:
|
108
|
+
- devise:
|
109
|
+
type: multiple_choice
|
110
|
+
prompt: Would you like to use Devise for authentication?
|
111
|
+
choices: [["No", no], ["Devise with default modules", standard], ["Devise with Confirmable module", confirmable], ["Devise with Confirmable and Invitable modules", invitable]]
|
112
|
+
- authorization:
|
113
|
+
type: boolean
|
114
|
+
prompt: Would you like to manage authorization with CanCan & Rolify?
|
data/recipes/extras.rb
ADDED
@@ -0,0 +1,80 @@
|
|
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/extras.rb
|
3
|
+
|
4
|
+
if config['footnotes']
|
5
|
+
say_wizard "Adding 'rails-footnotes'"
|
6
|
+
gem 'rails-footnotes', '>= 3.7', :group => :development
|
7
|
+
after_bundler do
|
8
|
+
generate 'rails_footnotes:install'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
if config['ban_spiders']
|
13
|
+
say_wizard "Banning spiders by modifying 'public/robots.txt'"
|
14
|
+
after_bundler do
|
15
|
+
# ban spiders from your site by changing robots.txt
|
16
|
+
gsub_file 'public/robots.txt', /# User-Agent/, 'User-Agent'
|
17
|
+
gsub_file 'public/robots.txt', /# Disallow/, 'Disallow'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if config['paginate']
|
22
|
+
say_wizard "Adding 'kaminari'"
|
23
|
+
gem 'kaminari', '>= 0.13.0'
|
24
|
+
after_bundler do
|
25
|
+
generate 'kaminari:config'
|
26
|
+
get "https://raw.github.com/gist/2863989/f1ff348df24072d4b24c874f6ef0f537510c0a41/kaminari.zh-CN.yml", 'config/locales/kaminari.zh-CN.yml'
|
27
|
+
end
|
28
|
+
recipes << 'paginate'
|
29
|
+
end
|
30
|
+
|
31
|
+
if config['jsruntime']
|
32
|
+
say_wizard "Adding 'therubyracer' JavaScript runtime gem"
|
33
|
+
# maybe it was already added by the html5 recipe for bootstrap_less?
|
34
|
+
unless recipes.include? 'jsruntime'
|
35
|
+
gem 'therubyracer', :group => :assets, :platform => :ruby
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
if config['i18n']
|
40
|
+
say_wizard "Setting default i18n locales"
|
41
|
+
gem 'rails-i18n'
|
42
|
+
|
43
|
+
inject_into_file 'config/application.rb', :before => '# config.i18n.default_locale' do <<-RUBY
|
44
|
+
config.i18n.locale = 'zh-CN'
|
45
|
+
config.i18n.default_locale = 'zh-CN'
|
46
|
+
RUBY
|
47
|
+
end
|
48
|
+
|
49
|
+
inject_into_file 'config/application.rb', :before => '# config.time_zone' do <<-RUBY
|
50
|
+
config.time_zone = 'Beijing'
|
51
|
+
RUBY
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
__END__
|
57
|
+
|
58
|
+
name: Extras
|
59
|
+
description: "Various extras including 'ban_spiders' and 'rails-footnotes'."
|
60
|
+
author: RailsApps
|
61
|
+
|
62
|
+
category: other
|
63
|
+
tags: [utilities, configuration]
|
64
|
+
|
65
|
+
config:
|
66
|
+
- footnotes:
|
67
|
+
type: boolean
|
68
|
+
prompt: Would you like to use 'rails-footnotes' (it's SLOW!)?
|
69
|
+
- ban_spiders:
|
70
|
+
type: boolean
|
71
|
+
prompt: Would you like to set a robots.txt file to ban spiders?
|
72
|
+
- paginate:
|
73
|
+
type: boolean
|
74
|
+
prompt: Would you like to add 'kaminari' for pagination?
|
75
|
+
- jsruntime:
|
76
|
+
type: boolean
|
77
|
+
prompt: Add 'therubyracer' JavaScript runtime (for Linux users without node.js)?
|
78
|
+
- i18n:
|
79
|
+
type: boolean
|
80
|
+
prompt: Set project default i18n locales to zh-CN?
|
data/recipes/git.rb
ADDED
@@ -0,0 +1,40 @@
|
|
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/git.rb
|
3
|
+
|
4
|
+
after_everything do
|
5
|
+
|
6
|
+
say_wizard "Git recipe running 'after everything'"
|
7
|
+
|
8
|
+
# Git should ignore some files
|
9
|
+
remove_file '.gitignore'
|
10
|
+
get "https://raw.github.com/RailsApps/rails3-application-templates/master/files/gitignore.txt", ".gitignore"
|
11
|
+
|
12
|
+
if recipes.include? 'omniauth'
|
13
|
+
append_file '.gitignore' do <<-TXT
|
14
|
+
|
15
|
+
# keep OmniAuth service provider secrets out of the Git repo
|
16
|
+
config/initializers/omniauth.rb
|
17
|
+
TXT
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Initialize new Git repo
|
22
|
+
git :init
|
23
|
+
git :add => '.'
|
24
|
+
git :commit => "-aqm 'new Rails app generated by Rails Apps Composer gem'"
|
25
|
+
# Create a git branch
|
26
|
+
git :checkout => ' -b working_branch'
|
27
|
+
git :add => '.'
|
28
|
+
git :commit => "-m 'Initial commit of working_branch'"
|
29
|
+
git :checkout => 'master'
|
30
|
+
end
|
31
|
+
|
32
|
+
__END__
|
33
|
+
|
34
|
+
name: Git
|
35
|
+
description: "Set up Git and commit the initial repository."
|
36
|
+
author: RailsApps
|
37
|
+
|
38
|
+
exclusive: scm
|
39
|
+
category: other
|
40
|
+
tags: [scm]
|
data/recipes/guard.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
case config['guard']
|
2
|
+
when 'no'
|
3
|
+
recipes.delete('guard')
|
4
|
+
say_wizard "Guard recipe skipped."
|
5
|
+
when 'standard'
|
6
|
+
# do nothing
|
7
|
+
when 'LiveReload'
|
8
|
+
recipes << 'guard-LiveReload'
|
9
|
+
else
|
10
|
+
recipes.delete('guard')
|
11
|
+
say_wizard "Guard recipe skipped."
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
if recipes.include? 'guard'
|
16
|
+
gem 'guard', '>= 0.6.2', :group => :development
|
17
|
+
|
18
|
+
prepend_file 'Gemfile' do <<-RUBY
|
19
|
+
require 'rbconfig'
|
20
|
+
HOST_OS = RbConfig::CONFIG['host_os']
|
21
|
+
|
22
|
+
RUBY
|
23
|
+
end
|
24
|
+
|
25
|
+
append_file 'Gemfile' do <<-RUBY
|
26
|
+
# need newline here!
|
27
|
+
case HOST_OS
|
28
|
+
when /darwin/i
|
29
|
+
gem 'rb-fsevent', :group => :development
|
30
|
+
gem 'growl', :group => :development
|
31
|
+
when /linux/i
|
32
|
+
gem 'libnotify', :group => :development
|
33
|
+
gem 'rb-inotify', :group => :development
|
34
|
+
when /mswin|windows/i
|
35
|
+
gem 'rb-fchange', :group => :development
|
36
|
+
gem 'win32console', :group => :development
|
37
|
+
gem 'rb-notifu', :group => :development
|
38
|
+
end
|
39
|
+
RUBY
|
40
|
+
end
|
41
|
+
|
42
|
+
def guards
|
43
|
+
@guards ||= []
|
44
|
+
end
|
45
|
+
|
46
|
+
def guard(name, version = nil)
|
47
|
+
args = []
|
48
|
+
if version
|
49
|
+
args << version
|
50
|
+
end
|
51
|
+
args << { :group => :development }
|
52
|
+
gem "guard-#{name}", *args
|
53
|
+
guards << name
|
54
|
+
end
|
55
|
+
|
56
|
+
guard 'bundler', '>= 0.1.3'
|
57
|
+
|
58
|
+
unless recipes.include? 'pow'
|
59
|
+
guard 'rails', '>= 0.0.3'
|
60
|
+
end
|
61
|
+
|
62
|
+
if recipes.include? 'guard-LiveReload'
|
63
|
+
guard 'livereload', '>= 0.3.0'
|
64
|
+
end
|
65
|
+
|
66
|
+
if recipes.include? 'rspec'
|
67
|
+
guard 'rspec', '>= 0.4.3'
|
68
|
+
end
|
69
|
+
|
70
|
+
if recipes.include? 'cucumber'
|
71
|
+
guard 'cucumber', '>= 0.6.1'
|
72
|
+
end
|
73
|
+
|
74
|
+
after_bundler do
|
75
|
+
run 'guard init'
|
76
|
+
guards.each do |name|
|
77
|
+
run "guard init #{name}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
else
|
82
|
+
recipes.delete 'guard'
|
83
|
+
end
|
84
|
+
|
85
|
+
__END__
|
86
|
+
|
87
|
+
name: guard
|
88
|
+
description: "Automate your workflow with Guard"
|
89
|
+
author: ashley_woodard
|
90
|
+
|
91
|
+
run_after: [rspec, cucumber]
|
92
|
+
category: other
|
93
|
+
tags: [dev]
|
94
|
+
|
95
|
+
config:
|
96
|
+
- guard:
|
97
|
+
type: multiple_choice
|
98
|
+
prompt: Would you like to use Guard to automate your workflow?
|
99
|
+
choices: [["No", no], ["Guard default configuration", standard], ["Guard with LiveReload", LiveReload]]
|
data/recipes/haml.rb
ADDED
@@ -0,0 +1,23 @@
|
|
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/haml.rb
|
3
|
+
|
4
|
+
if config['haml']
|
5
|
+
gem 'haml', '>= 3.1.6'
|
6
|
+
gem 'haml-rails', '>= 0.3.4', :group => :development
|
7
|
+
else
|
8
|
+
recipes.delete('haml')
|
9
|
+
end
|
10
|
+
|
11
|
+
__END__
|
12
|
+
|
13
|
+
name: HAML
|
14
|
+
description: "Utilize Haml instead of ERB."
|
15
|
+
author: RailsApps
|
16
|
+
|
17
|
+
category: templating
|
18
|
+
exclusive: templating
|
19
|
+
|
20
|
+
config:
|
21
|
+
- haml:
|
22
|
+
type: boolean
|
23
|
+
prompt: Would you like to use Haml instead of ERB?
|
data/recipes/heroku.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
heroku_name = app_name.gsub('_','')
|
2
|
+
|
3
|
+
gem 'heroku', group: :development
|
4
|
+
|
5
|
+
after_everything do
|
6
|
+
if config['create']
|
7
|
+
say_wizard "Creating Heroku app '#{heroku_name}.heroku.com'"
|
8
|
+
# system "heroku apps:destroy --app #{heroku_name} --confirm #{heroku_name}"
|
9
|
+
|
10
|
+
while !system("heroku create #{heroku_name}")
|
11
|
+
heroku_name = ask_wizard("What do you want to call your app? ")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
if config['staging']
|
16
|
+
staging_name = "#{heroku_name}-staging"
|
17
|
+
say_wizard "Creating staging Heroku app '#{staging_name}.heroku.com'"
|
18
|
+
while !system("heroku create #{staging_name}")
|
19
|
+
staging_name = ask_wizard("What do you want to call your staging app?")
|
20
|
+
end
|
21
|
+
git :remote => "rm heroku"
|
22
|
+
git :remote => "add production git@heroku.com:#{heroku_name}.git"
|
23
|
+
git :remote => "add staging git@heroku.com:#{staging_name}.git"
|
24
|
+
say_wizard "Created branches 'production' and 'staging' for Heroku deploy."
|
25
|
+
end
|
26
|
+
|
27
|
+
unless config['domain'].blank?
|
28
|
+
run "heroku addons:add custom_domains"
|
29
|
+
run "heroku domains:add #{config['domain']}"
|
30
|
+
end
|
31
|
+
|
32
|
+
git :push => "#{config['staging'] ? 'staging' : 'heroku'} master" if config['deploy']
|
33
|
+
end
|
34
|
+
|
35
|
+
__END__
|
36
|
+
|
37
|
+
name: Heroku
|
38
|
+
description: Create Heroku application and instantly deploy.
|
39
|
+
author: mbleigh
|
40
|
+
|
41
|
+
requires: [git]
|
42
|
+
run_after: [git]
|
43
|
+
exclusive: deployment
|
44
|
+
category: deployment
|
45
|
+
tags: [provider]
|
46
|
+
|
47
|
+
config:
|
48
|
+
- create:
|
49
|
+
prompt: "Automatically create appname.heroku.com?"
|
50
|
+
type: boolean
|
51
|
+
- staging:
|
52
|
+
prompt: "Create staging app? (appname-staging.heroku.com)"
|
53
|
+
type: boolean
|
54
|
+
if: create
|
55
|
+
- domain:
|
56
|
+
prompt: "Specify custom domain (or leave blank):"
|
57
|
+
type: string
|
58
|
+
if: create
|
59
|
+
- deploy:
|
60
|
+
prompt: "Deploy immediately?"
|
61
|
+
type: boolean
|
62
|
+
if: create
|
@@ -0,0 +1,58 @@
|
|
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/home_page.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
say_wizard "HomePage recipe running 'after bundler'"
|
7
|
+
|
8
|
+
# remove the default home page
|
9
|
+
remove_file 'public/index.html'
|
10
|
+
|
11
|
+
# create a home controller and view
|
12
|
+
generate(:controller, "home index")
|
13
|
+
|
14
|
+
# set up a simple home page (with placeholder content)
|
15
|
+
if recipes.include? 'haml'
|
16
|
+
remove_file 'app/views/home/index.html.haml'
|
17
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
18
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
19
|
+
create_file 'app/views/home/index.html.haml' do
|
20
|
+
<<-'HAML'
|
21
|
+
%h3 Home
|
22
|
+
HAML
|
23
|
+
end
|
24
|
+
elsif recipes.include? 'slim'
|
25
|
+
# skip
|
26
|
+
else
|
27
|
+
remove_file 'app/views/home/index.html.erb'
|
28
|
+
create_file 'app/views/home/index.html.erb' do
|
29
|
+
<<-ERB
|
30
|
+
<h3>Home</h3>
|
31
|
+
ERB
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# set routes
|
36
|
+
gsub_file 'config/routes.rb', /get \"home\/index\"/, 'root :to => "home#index"'
|
37
|
+
|
38
|
+
if recipes.include? 'devise'
|
39
|
+
inject_into_file 'config/routes.rb', :before => " root :to" do
|
40
|
+
<<-RUBY
|
41
|
+
authenticated :user do
|
42
|
+
root :to => 'home#index'
|
43
|
+
end
|
44
|
+
\n
|
45
|
+
RUBY
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
__END__
|
52
|
+
|
53
|
+
name: HomePage
|
54
|
+
description: "Create a simple home page (creates a home controller and view)."
|
55
|
+
author: RailsApps
|
56
|
+
|
57
|
+
category: other
|
58
|
+
tags: [utilities, configuration]
|
@@ -0,0 +1,47 @@
|
|
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/home_page_users.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
say_wizard "HomePageUsers recipe running 'after bundler'"
|
7
|
+
|
8
|
+
# Modify the home controller
|
9
|
+
gsub_file 'app/controllers/home_controller.rb', /def index/ do
|
10
|
+
<<-RUBY
|
11
|
+
def index
|
12
|
+
@users = User.all
|
13
|
+
RUBY
|
14
|
+
end
|
15
|
+
|
16
|
+
# Replace the home page
|
17
|
+
if recipes.include? 'haml'
|
18
|
+
remove_file 'app/views/home/index.html.haml'
|
19
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
20
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
21
|
+
create_file 'app/views/home/index.html.haml' do
|
22
|
+
<<-'HAML'
|
23
|
+
%h3 Home
|
24
|
+
- @users.each do |user|
|
25
|
+
%p User: #{user.name}
|
26
|
+
HAML
|
27
|
+
end
|
28
|
+
else
|
29
|
+
append_file 'app/views/home/index.html.erb' do <<-ERB
|
30
|
+
<h3>Home</h3>
|
31
|
+
<% @users.each do |user| %>
|
32
|
+
<p>User: <%= user.name %></p>
|
33
|
+
<% end %>
|
34
|
+
ERB
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
__END__
|
41
|
+
|
42
|
+
name: HomePageUsers
|
43
|
+
description: "Display a list of users on the home page."
|
44
|
+
author: RailsApps
|
45
|
+
|
46
|
+
category: other
|
47
|
+
tags: [utilities, configuration]
|