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/html5.rb
DELETED
@@ -1,152 +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/html5.rb
|
3
|
-
|
4
|
-
case config['css_option']
|
5
|
-
|
6
|
-
when 'foundation'
|
7
|
-
# https://github.com/zurb/foundation-rails
|
8
|
-
gem 'zurb-foundation', '>= 3.0.5'
|
9
|
-
|
10
|
-
when 'bootstrap_less'
|
11
|
-
# https://github.com/seyhunak/twitter-bootstrap-rails
|
12
|
-
# http://railscasts.com/episodes/328-twitter-bootstrap-basics
|
13
|
-
gem 'twitter-bootstrap-rails', '>= 2.0.3', :group => :assets
|
14
|
-
# please install gem 'therubyracer' to use Less
|
15
|
-
gem 'therubyracer', :group => :assets, :platform => :ruby
|
16
|
-
recipes << 'bootstrap'
|
17
|
-
recipes << 'jsruntime'
|
18
|
-
|
19
|
-
when 'bootstrap_sass'
|
20
|
-
# https://github.com/thomas-mcdonald/bootstrap-sass
|
21
|
-
# http://rubysource.com/twitter-bootstrap-less-and-sass-understanding-your-options-for-rails-3-1/
|
22
|
-
gem 'bootstrap-sass', '>= 2.0.4.0'
|
23
|
-
recipes << 'bootstrap'
|
24
|
-
|
25
|
-
end
|
26
|
-
after_bundler do
|
27
|
-
say_wizard "HTML5 recipe running 'after bundler'"
|
28
|
-
# add a humans.txt file
|
29
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/humans.txt', 'public/humans.txt'
|
30
|
-
# install a front-end framework for HTML5 and CSS3
|
31
|
-
remove_file 'app/assets/stylesheets/application.css'
|
32
|
-
remove_file 'app/views/layouts/application.html.erb'
|
33
|
-
remove_file 'app/views/layouts/application.html.haml'
|
34
|
-
unless recipes.include? 'bootstrap'
|
35
|
-
if recipes.include? 'haml'
|
36
|
-
# Haml version of a simple application layout
|
37
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/views/layouts/application.html.haml', 'app/views/layouts/application.html.haml'
|
38
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/views/layouts/_messages.html.haml', 'app/views/layouts/_messages.html.haml'
|
39
|
-
else
|
40
|
-
# ERB version of a simple application layout
|
41
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/views/layouts/application.html.erb', 'app/views/layouts/application.html.erb'
|
42
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/views/layouts/_messages.html.erb', 'app/views/layouts/_messages.html.erb'
|
43
|
-
end
|
44
|
-
# simple css styles
|
45
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/assets/stylesheets/application.css.scss', 'app/assets/stylesheets/application.css.scss'
|
46
|
-
else # for Twitter Bootstrap
|
47
|
-
if recipes.include? 'haml'
|
48
|
-
# Haml version of a complex application layout using Twitter Bootstrap
|
49
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/application.html.haml', 'app/views/layouts/application.html.haml'
|
50
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/_messages.html.haml', 'app/views/layouts/_messages.html.haml'
|
51
|
-
else
|
52
|
-
# ERB version of a complex application layout using Twitter Bootstrap
|
53
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/application.html.erb', 'app/views/layouts/application.html.erb'
|
54
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/_messages.html.erb', 'app/views/layouts/_messages.html.erb'
|
55
|
-
end
|
56
|
-
# complex css styles using Twitter Bootstrap
|
57
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/assets/stylesheets/application.css.scss', 'app/assets/stylesheets/application.css.scss'
|
58
|
-
end
|
59
|
-
# get an appropriate navigation partial
|
60
|
-
if recipes.include? 'haml'
|
61
|
-
if recipes.include? 'devise'
|
62
|
-
if recipes.include? 'authorization'
|
63
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/authorization/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
|
64
|
-
else
|
65
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
|
66
|
-
end
|
67
|
-
elsif recipes.include? 'omniauth'
|
68
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/omniauth/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
|
69
|
-
elsif recipes.include? 'subdomains'
|
70
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/subdomains/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
|
71
|
-
else
|
72
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/none/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
|
73
|
-
end
|
74
|
-
else
|
75
|
-
if recipes.include? 'devise'
|
76
|
-
if recipes.include? 'authorization'
|
77
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/authorization/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'
|
78
|
-
else
|
79
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'
|
80
|
-
end
|
81
|
-
elsif recipes.include? 'omniauth'
|
82
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/omniauth/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'
|
83
|
-
elsif recipes.include? 'subdomains'
|
84
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/subdomains/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'
|
85
|
-
else
|
86
|
-
get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/none/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'
|
87
|
-
end
|
88
|
-
end
|
89
|
-
if recipes.include? 'haml'
|
90
|
-
gsub_file 'app/views/layouts/application.html.haml', /App_Name/, "#{app_name.humanize.titleize}"
|
91
|
-
gsub_file 'app/views/layouts/_navigation.html.haml', /App_Name/, "#{app_name.humanize.titleize}"
|
92
|
-
else
|
93
|
-
gsub_file 'app/views/layouts/application.html.erb', /App_Name/, "#{app_name.humanize.titleize}"
|
94
|
-
gsub_file 'app/views/layouts/_navigation.html.erb', /App_Name/, "#{app_name.humanize.titleize}"
|
95
|
-
end
|
96
|
-
case config['css_option']
|
97
|
-
|
98
|
-
when 'bootstrap_less'
|
99
|
-
say_wizard 'installing Twitter Bootstrap HTML5 framework (less)'
|
100
|
-
generate 'bootstrap:install'
|
101
|
-
remove_file 'app/assets/stylesheets/application.css' # already created application.css.scss above
|
102
|
-
insert_into_file 'app/assets/stylesheets/bootstrap_and_overrides.css.less', "body { padding-top: 60px; }\n", :after => "@import \"twitter/bootstrap/bootstrap\";\n"
|
103
|
-
|
104
|
-
when 'bootstrap_sass'
|
105
|
-
say_wizard 'installing Twitter Bootstrap HTML5 framework (sass)'
|
106
|
-
insert_into_file 'app/assets/javascripts/application.js', "//= require bootstrap\n", :after => "jquery_ujs\n"
|
107
|
-
create_file 'app/assets/stylesheets/bootstrap_and_overrides.css.scss', <<-RUBY
|
108
|
-
// Set the correct sprite paths
|
109
|
-
$iconSpritePath: asset-url('glyphicons-halflings.png', image);
|
110
|
-
$iconWhiteSpritePath: asset-url('glyphicons-halflings-white.png', image);
|
111
|
-
@import "bootstrap";
|
112
|
-
body { padding-top: 60px; }
|
113
|
-
@import "bootstrap-responsive";
|
114
|
-
RUBY
|
115
|
-
|
116
|
-
when 'foundation'
|
117
|
-
say_wizard 'installing Zurb Foundation HTML5 framework'
|
118
|
-
insert_into_file 'app/assets/javascripts/application.js', "//= require foundation\n", :after => "jquery_ujs\n"
|
119
|
-
insert_into_file 'app/assets/stylesheets/application.css.scss', " *= require foundation\n", :after => "require_self\n"
|
120
|
-
|
121
|
-
when 'skeleton'
|
122
|
-
say_wizard 'installing Skeleton HTML5 framework'
|
123
|
-
get 'https://raw.github.com/necolas/normalize.css/master/normalize.css', 'app/assets/stylesheets/normalize.css.scss'
|
124
|
-
get 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/base.css', 'app/assets/stylesheets/base.css.scss'
|
125
|
-
get 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/layout.css', 'app/assets/stylesheets/layout.css.scss'
|
126
|
-
get 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/skeleton.css', 'app/assets/stylesheets/skeleton.css.scss'
|
127
|
-
|
128
|
-
when 'normalize'
|
129
|
-
say_wizard 'normalizing CSS for consistent styling'
|
130
|
-
get 'https://raw.github.com/necolas/normalize.css/master/normalize.css', 'app/assets/stylesheets/normalize.css.scss'
|
131
|
-
|
132
|
-
when 'nothing'
|
133
|
-
say_wizard 'no HTML5 front-end framework selected'
|
134
|
-
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|
138
|
-
|
139
|
-
__END__
|
140
|
-
|
141
|
-
name: html5
|
142
|
-
description: "Install a front-end framework for HTML5 and CSS."
|
143
|
-
author: RailsApps
|
144
|
-
|
145
|
-
category: other
|
146
|
-
tags: [utilities, configuration]
|
147
|
-
|
148
|
-
config:
|
149
|
-
- css_option:
|
150
|
-
type: multiple_choice
|
151
|
-
prompt: "Which front-end framework would you like for HTML5 and CSS?"
|
152
|
-
choices: [["None", nothing], ["Zurb Foundation", foundation], ["Twitter Bootstrap (less)", bootstrap_less], ["Twitter Bootstrap (sass)", bootstrap_sass], ["Skeleton", skeleton], ["Just normalize CSS for consistent styling", normalize]]
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# Application template recipe for the rails_apps_composer. Check for a newer version here:
|
2
|
-
# https://github.com/gmgp/rails_apps_composer/blob/master/recipes/inherited_resources.rb
|
3
|
-
|
4
|
-
if config['inherited_resources']
|
5
|
-
gem 'inherited_resources'
|
6
|
-
else
|
7
|
-
recipes.delete('inherited_resources')
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
__END__
|
12
|
-
|
13
|
-
name: InheritedResources
|
14
|
-
description: "Include inherited_resources "
|
15
|
-
author: Gmgp
|
16
|
-
|
17
|
-
category: other
|
18
|
-
tags: [utilities, configuration]
|
19
|
-
|
20
|
-
config:
|
21
|
-
- inherited_resources:
|
22
|
-
type: boolean
|
23
|
-
prompt: Would you like to use 'inherited_resources'?
|
data/recipes/less.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
gem 'less'
|
2
|
-
plugin 'more', :git => 'git://github.com/cloudhead/more.git'
|
3
|
-
|
4
|
-
__END__
|
5
|
-
|
6
|
-
name: Less CSS
|
7
|
-
description: "Utilize Less CSS for CSS generation utilizing the \"more\" plugin for Rails."
|
8
|
-
author: mbleigh
|
9
|
-
|
10
|
-
exclusive: css_replacement
|
11
|
-
category: assets
|
12
|
-
tags: [css]
|
data/recipes/mongohq.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
if config['use_heroku']
|
2
|
-
|
3
|
-
header = <<-YAML
|
4
|
-
<% if ENV['MONGOHQ_URL'] %>
|
5
|
-
<% mongohq = URI.parse(ENV['MONGOHQ_URL']) %>
|
6
|
-
mongohq:
|
7
|
-
host: <%= mongohq.host %>
|
8
|
-
port: <%= mongohq.port %>
|
9
|
-
database: <%= mongohq.path.sub '/', '' %>
|
10
|
-
username: <%= mongohq.user %>
|
11
|
-
password: <%= mongohq.password %>
|
12
|
-
<% end %>
|
13
|
-
YAML
|
14
|
-
|
15
|
-
after_everything do
|
16
|
-
say_wizard 'Adding mongohq:free addon (you can always upgrade later)'
|
17
|
-
system 'heroku addons:add mongohq:free'
|
18
|
-
end
|
19
|
-
else
|
20
|
-
mongohq = URI.parse(config['uri'])
|
21
|
-
|
22
|
-
header = <<-YAML
|
23
|
-
mongohq:
|
24
|
-
host: #{mongohq.host}
|
25
|
-
port: #{mongohq.port}
|
26
|
-
database: #{mongohq.path.sub '/',''}
|
27
|
-
username: #{mongohq.user}
|
28
|
-
password: #{mongohq.password}
|
29
|
-
YAML
|
30
|
-
end
|
31
|
-
|
32
|
-
after_bundler do
|
33
|
-
mongo_yml = "config/mongo#{'id' if recipe?('mongoid')}.yml"
|
34
|
-
|
35
|
-
prepend_file mongo_yml, header
|
36
|
-
inject_into_file mongo_yml, " <<: *mongohq\n", :after => "production:\n <<: *defaults\n"
|
37
|
-
end
|
38
|
-
|
39
|
-
__END__
|
40
|
-
|
41
|
-
name: MongoHQ
|
42
|
-
description: "Utilize MongoHQ as the production data host for your application."
|
43
|
-
author: mbleigh
|
44
|
-
|
45
|
-
requires_any: [mongo_mapper, mongoid]
|
46
|
-
run_after: [mongo_mapper, mongoid, heroku]
|
47
|
-
exclusive: mongodb_host
|
48
|
-
category: services
|
49
|
-
tags: [mongodb]
|
50
|
-
|
51
|
-
config:
|
52
|
-
- use_heroku:
|
53
|
-
type: boolean
|
54
|
-
prompt: "Use the MongoHQ Heroku addon?"
|
55
|
-
if_recipe: heroku
|
56
|
-
- uri:
|
57
|
-
type: string
|
58
|
-
prompt: "Enter your MongoHQ URI:"
|
59
|
-
unless: use_heroku
|
data/recipes/mongoid.rb
DELETED
@@ -1,38 +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/mongoid.rb
|
3
|
-
|
4
|
-
if config['mongoid']
|
5
|
-
say_wizard "REMINDER: When creating a Rails app using Mongoid..."
|
6
|
-
say_wizard "you should add the '-O' flag to 'rails new'"
|
7
|
-
gem 'mongoid', '>= 3.0.1'
|
8
|
-
else
|
9
|
-
recipes.delete('mongoid')
|
10
|
-
end
|
11
|
-
|
12
|
-
if config['mongoid']
|
13
|
-
after_bundler do
|
14
|
-
say_wizard "Mongoid recipe running 'after bundler'"
|
15
|
-
# note: the mongoid generator automatically modifies the config/application.rb file
|
16
|
-
# to remove the ActiveRecord dependency by commenting out "require active_record/railtie'"
|
17
|
-
generate 'mongoid:config'
|
18
|
-
# remove the unnecessary 'config/database.yml' file
|
19
|
-
remove_file 'config/database.yml'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
__END__
|
24
|
-
|
25
|
-
name: Mongoid
|
26
|
-
description: "Use Mongoid to connect to a MongoDB database."
|
27
|
-
author: RailsApps
|
28
|
-
|
29
|
-
category: persistence
|
30
|
-
exclusive: orm
|
31
|
-
tags: [orm, mongodb]
|
32
|
-
|
33
|
-
args: ["-O"]
|
34
|
-
|
35
|
-
config:
|
36
|
-
- mongoid:
|
37
|
-
type: boolean
|
38
|
-
prompt: Would you like to use Mongoid to connect to a MongoDB database?
|
data/recipes/mongolab.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
if config['use_heroku']
|
2
|
-
|
3
|
-
header = <<-YAML
|
4
|
-
<% if ENV['MONGOLAB_URI'] %>
|
5
|
-
<% mongolab = URI.parse(ENV['MONGOLAB_URI']) %>
|
6
|
-
mongolab:
|
7
|
-
host: <%= mongolab.host %>
|
8
|
-
port: <%= mongolab.port %>
|
9
|
-
database: <%= mongolab.path.sub '/', '' %>
|
10
|
-
username: <%= mongolab.user %>
|
11
|
-
password: <%= mongolab.password %>
|
12
|
-
<% end %>
|
13
|
-
YAML
|
14
|
-
|
15
|
-
after_everything do
|
16
|
-
say_wizard 'Adding mongolab:starter addon (you can always upgrade later)'
|
17
|
-
system 'heroku addons:add mongolab:starter'
|
18
|
-
end
|
19
|
-
else
|
20
|
-
mongolab = URI.parse(config['uri'])
|
21
|
-
|
22
|
-
header = <<-YAML
|
23
|
-
mongolab:
|
24
|
-
host: #{mongolab.host}
|
25
|
-
port: #{mongolab.port}
|
26
|
-
database: #{mongolab.path.sub '/',''}
|
27
|
-
username: #{mongolab.user}
|
28
|
-
password: #{mongolab.password}
|
29
|
-
YAML
|
30
|
-
end
|
31
|
-
|
32
|
-
after_bundler do
|
33
|
-
mongo_yml = "config/mongo#{'id' if recipe?('mongoid')}.yml"
|
34
|
-
|
35
|
-
prepend_file mongo_yml, header
|
36
|
-
inject_into_file mongo_yml, " <<: *mongolab\n", :after => "production:\n <<: *defaults\n"
|
37
|
-
end
|
38
|
-
|
39
|
-
__END__
|
40
|
-
|
41
|
-
name: mongolab (based on mongohq recipe)
|
42
|
-
description: "Utilize mongolab as the production data host for your application."
|
43
|
-
author: l4u (based on mongohq recipe by mbleigh)
|
44
|
-
|
45
|
-
requires_any: [mongo_mapper, mongoid]
|
46
|
-
run_after: [mongo_mapper, mongoid, heroku]
|
47
|
-
exclusive: mongodb_host
|
48
|
-
category: services
|
49
|
-
tags: [mongodb]
|
50
|
-
|
51
|
-
config:
|
52
|
-
- use_heroku:
|
53
|
-
type: boolean
|
54
|
-
prompt: "Use the MongoLab Heroku addon?"
|
55
|
-
if_recipe: heroku
|
56
|
-
- uri:
|
57
|
-
type: string
|
58
|
-
prompt: "Enter your MongoLab URI:"
|
59
|
-
unless: use_heroku
|
data/recipes/omniauth.rb
DELETED
@@ -1,194 +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/omniauth.rb
|
3
|
-
|
4
|
-
if config['omniauth']
|
5
|
-
gem 'omniauth', '>= 1.1.0'
|
6
|
-
# for available gems, see https://github.com/intridea/omniauth/wiki/List-of-Strategies
|
7
|
-
case config['provider']
|
8
|
-
when 'twitter'
|
9
|
-
gem 'omniauth-twitter'
|
10
|
-
when 'facebook'
|
11
|
-
gem 'omniauth-facebook'
|
12
|
-
when 'github'
|
13
|
-
gem 'omniauth-github'
|
14
|
-
when 'linkedin'
|
15
|
-
gem 'omniauth-linkedin'
|
16
|
-
when 'google-oauth2'
|
17
|
-
gem 'omniauth-google-oauth2'
|
18
|
-
when 'tumblr'
|
19
|
-
gem 'omniauth-tumblr'
|
20
|
-
end
|
21
|
-
else
|
22
|
-
recipes.delete('omniauth')
|
23
|
-
end
|
24
|
-
|
25
|
-
if config['omniauth']
|
26
|
-
after_bundler do
|
27
|
-
|
28
|
-
say_wizard "OmniAuth recipe running 'after bundler'"
|
29
|
-
|
30
|
-
# Don't use single-quote-style-heredoc: we want interpolation.
|
31
|
-
create_file 'config/initializers/omniauth.rb' do <<-RUBY
|
32
|
-
Rails.application.config.middleware.use OmniAuth::Builder do
|
33
|
-
provider :#{config['provider']}, 'KEY', 'SECRET'
|
34
|
-
end
|
35
|
-
RUBY
|
36
|
-
end
|
37
|
-
|
38
|
-
# add routes
|
39
|
-
route "match '/auth/failure' => 'sessions#failure'"
|
40
|
-
route "match '/signout' => 'sessions#destroy', :as => :signout"
|
41
|
-
route "match '/signin' => 'sessions#new', :as => :signin"
|
42
|
-
route "match '/auth/:provider/callback' => 'sessions#create'"
|
43
|
-
route "resources :users, :only => [ :show, :edit, :update ]"
|
44
|
-
|
45
|
-
# add a user model (unless another recipe did so already)
|
46
|
-
unless recipes.include? 'add_user'
|
47
|
-
generate(:model, "user provider:string uid:string name:string email:string")
|
48
|
-
gsub_file 'app/models/user.rb', /\bend\s*\Z/ do
|
49
|
-
<<-RUBY
|
50
|
-
attr_accessible :provider, :uid, :name, :email
|
51
|
-
# run 'rake db:mongoid:create_indexes' to create indexes
|
52
|
-
index({ email: 1 }, { unique: true, background: true })
|
53
|
-
end
|
54
|
-
RUBY
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# modify the user model
|
59
|
-
inject_into_file 'app/models/user.rb', :before => 'end' do <<-RUBY
|
60
|
-
|
61
|
-
def self.create_with_omniauth(auth)
|
62
|
-
create! do |user|
|
63
|
-
user.provider = auth['provider']
|
64
|
-
user.uid = auth['uid']
|
65
|
-
if auth['info']
|
66
|
-
user.name = auth['info']['name'] || ""
|
67
|
-
user.email = auth['info']['email'] || ""
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
RUBY
|
73
|
-
end
|
74
|
-
|
75
|
-
# We have to use single-quote-style-heredoc to avoid interpolation.
|
76
|
-
create_file 'app/controllers/sessions_controller.rb' do <<-'RUBY'
|
77
|
-
class SessionsController < ApplicationController
|
78
|
-
|
79
|
-
def create
|
80
|
-
auth = request.env["omniauth.auth"]
|
81
|
-
user = User.where(:provider => auth['provider'],
|
82
|
-
:uid => auth['uid']).first || User.create_with_omniauth(auth)
|
83
|
-
session[:user_id] = user.id
|
84
|
-
redirect_to root_url, :notice => 'Signed in!'
|
85
|
-
end
|
86
|
-
|
87
|
-
def destroy
|
88
|
-
reset_session
|
89
|
-
redirect_to root_url, :notice => 'Signed out!'
|
90
|
-
end
|
91
|
-
|
92
|
-
def failure
|
93
|
-
redirect_to root_url, :alert => "Authentication error: #{params[:message].humanize}"
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
RUBY
|
98
|
-
end
|
99
|
-
|
100
|
-
# Don't use single-quote-style-heredoc: we want interpolation.
|
101
|
-
inject_into_class 'app/controllers/sessions_controller.rb', 'SessionsController' do <<-RUBY
|
102
|
-
|
103
|
-
def new
|
104
|
-
redirect_to '/auth/#{config['provider']}'
|
105
|
-
end
|
106
|
-
|
107
|
-
RUBY
|
108
|
-
end
|
109
|
-
|
110
|
-
inject_into_file 'app/controllers/application_controller.rb', :before => 'end' do <<-RUBY
|
111
|
-
helper_method :current_user
|
112
|
-
helper_method :user_signed_in?
|
113
|
-
helper_method :correct_user?
|
114
|
-
|
115
|
-
private
|
116
|
-
def current_user
|
117
|
-
begin
|
118
|
-
@current_user ||= User.find(session[:user_id]) if session[:user_id]
|
119
|
-
rescue Mongoid::Errors::DocumentNotFound
|
120
|
-
nil
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def user_signed_in?
|
125
|
-
return true if current_user
|
126
|
-
end
|
127
|
-
|
128
|
-
def correct_user?
|
129
|
-
@user = User.find(params[:id])
|
130
|
-
unless current_user == @user
|
131
|
-
redirect_to root_url, :alert => "Access denied."
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def authenticate_user!
|
136
|
-
if !current_user
|
137
|
-
redirect_to root_url, :alert => 'You need to sign in for access to this page.'
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
RUBY
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
145
|
-
|
146
|
-
after_everything do
|
147
|
-
|
148
|
-
say_wizard "OmniAuth recipe running 'after everything'"
|
149
|
-
|
150
|
-
if recipes.include? 'rspec'
|
151
|
-
say_wizard "Copying RSpec files from the rails3-mongoid-omniauth examples"
|
152
|
-
begin
|
153
|
-
# copy all the RSpec specs files from the rails3-mongoid-omniauth example app
|
154
|
-
# spec_helper
|
155
|
-
remove_file 'spec/spec_helper.rb'
|
156
|
-
get 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/spec/spec_helper.rb', 'spec/spec_helper.rb'
|
157
|
-
# factories
|
158
|
-
remove_file 'spec/factories/users.rb'
|
159
|
-
get 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/spec/factories/users.rb', 'spec/factories/users.rb'
|
160
|
-
# controllers
|
161
|
-
get 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/spec/controllers/sessions_controller_spec.rb', 'spec/controllers/sessions_controller_spec.rb'
|
162
|
-
remove_file 'spec/controllers/home_controller_spec.rb'
|
163
|
-
remove_file 'spec/controllers/users_controller_spec.rb'
|
164
|
-
get 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/spec/controllers/home_controller_spec.rb', 'spec/controllers/home_controller_spec.rb'
|
165
|
-
get 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/spec/controllers/users_controller_spec.rb', 'spec/controllers/users_controller_spec.rb'
|
166
|
-
# models
|
167
|
-
remove_file 'spec/models/user_spec.rb'
|
168
|
-
get 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/spec/models/user_spec.rb', 'spec/models/user_spec.rb'
|
169
|
-
rescue OpenURI::HTTPError
|
170
|
-
say_wizard "Unable to obtain RSpec example files from the repo"
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
end
|
177
|
-
|
178
|
-
__END__
|
179
|
-
|
180
|
-
name: OmniAuth
|
181
|
-
description: "Utilize OmniAuth for authentication."
|
182
|
-
author: RailsApps
|
183
|
-
|
184
|
-
exclusive: authentication
|
185
|
-
category: authentication
|
186
|
-
|
187
|
-
config:
|
188
|
-
- omniauth:
|
189
|
-
type: boolean
|
190
|
-
prompt: Would you like to use OmniAuth for authentication?
|
191
|
-
- provider:
|
192
|
-
type: multiple_choice
|
193
|
-
prompt: "Which service provider will you use?"
|
194
|
-
choices: [["Twitter", twitter], ["Facebook", facebook], ["GitHub", github], ["LinkedIn", linkedin], ["Google-Oauth-2",google-oauth2], ["Tumblr", tumblr]]
|
data/recipes/omniauth_email.rb
DELETED
@@ -1,82 +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/omniauth_email.rb
|
3
|
-
|
4
|
-
after_bundler do
|
5
|
-
|
6
|
-
say_wizard "OmniAuthEmail recipe running 'after bundler'"
|
7
|
-
|
8
|
-
#----------------------------------------------------------------------------
|
9
|
-
# Modify a users controller
|
10
|
-
#----------------------------------------------------------------------------
|
11
|
-
inject_into_file 'app/controllers/users_controller.rb', :after => "before_filter :authenticate_user!\n" do <<-RUBY
|
12
|
-
before_filter :correct_user?
|
13
|
-
RUBY
|
14
|
-
end
|
15
|
-
|
16
|
-
inject_into_file 'app/controllers/users_controller.rb', :before => 'def show' do <<-RUBY
|
17
|
-
def edit
|
18
|
-
@user = User.find(params[:id])
|
19
|
-
end
|
20
|
-
|
21
|
-
def update
|
22
|
-
@user = User.find(params[:id])
|
23
|
-
if @user.update_attributes(params[:user])
|
24
|
-
redirect_to @user
|
25
|
-
else
|
26
|
-
render :edit
|
27
|
-
end
|
28
|
-
end
|
29
|
-
\n
|
30
|
-
RUBY
|
31
|
-
end
|
32
|
-
|
33
|
-
#----------------------------------------------------------------------------
|
34
|
-
# Create a users edit page
|
35
|
-
#----------------------------------------------------------------------------
|
36
|
-
if recipes.include? 'haml'
|
37
|
-
remove_file 'app/views/users/edit.html.haml'
|
38
|
-
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
39
|
-
# We have to use single-quote-style-heredoc to avoid interpolation.
|
40
|
-
create_file 'app/views/users/edit.html.haml' do <<-'HAML'
|
41
|
-
= form_for(@user) do |f|
|
42
|
-
= f.label :email
|
43
|
-
= f.text_field :email
|
44
|
-
%br/
|
45
|
-
= f.submit "Sign in"
|
46
|
-
HAML
|
47
|
-
end
|
48
|
-
else
|
49
|
-
create_file 'app/views/users/edit.html.erb' do <<-ERB
|
50
|
-
<%= form_for(@user) do |f| %>
|
51
|
-
<%= f.label :email %>
|
52
|
-
<%= f.text_field :email %>
|
53
|
-
<br />
|
54
|
-
<%= f.submit "Sign in" %>
|
55
|
-
<% end %>
|
56
|
-
ERB
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
#----------------------------------------------------------------------------
|
61
|
-
# Modify a Sessions controller
|
62
|
-
#----------------------------------------------------------------------------
|
63
|
-
gsub_file 'app/controllers/sessions_controller.rb', /redirect_to root_url, :notice => 'Signed in!'/ do
|
64
|
-
<<-RUBY
|
65
|
-
if user.email.blank?
|
66
|
-
redirect_to edit_user_path(user), :alert => "Please enter your email address."
|
67
|
-
else
|
68
|
-
redirect_to root_url, :notice => 'Signed in!'
|
69
|
-
end
|
70
|
-
RUBY
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
__END__
|
76
|
-
|
77
|
-
name: OmniAuthEmail
|
78
|
-
description: "Request a user's email address for an OmniAuth example app."
|
79
|
-
author: RailsApps
|
80
|
-
|
81
|
-
category: other
|
82
|
-
tags: [utilities, configuration]
|