happy_seed 0.0.11 → 0.0.12
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.
- checksums.yaml +4 -4
- data/happy_seed.rb +69 -88
- data/lib/generators/happy_seed/admin/admin_generator.rb +3 -2
- data/lib/generators/happy_seed/admin/templates/app/admin/campaigns.rb +1 -1
- data/lib/generators/happy_seed/admin/templates/app/admin/newsletter.rb +1 -1
- data/lib/generators/happy_seed/admin/templates/app/admin/user.rb +1 -0
- data/lib/generators/happy_seed/admin/templates/app/controllers/admin/stats_controller.rb +1 -1
- data/lib/generators/happy_seed/admin/templates/app/views/admin/_chart.html.haml +2 -3
- data/lib/generators/happy_seed/admin/templates/vendor/assets/javascripts/chartkick.js +0 -1
- data/lib/generators/happy_seed/base/base_generator.rb +2 -9
- data/lib/generators/happy_seed/base/templates/app/views/setup/index.html.haml +3 -0
- data/lib/generators/happy_seed/base/templates/lib/tasks/haml2erb.rake +34 -0
- data/lib/generators/happy_seed/bootstrap/bootstrap_generator.rb +7 -3
- data/lib/generators/happy_seed/bootstrap/templates/app/assets/stylesheets/application.css.scss +12 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/helpers/application_helper.rb +5 -13
- data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_flashes.html.haml +1 -5
- data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_header.html.haml +9 -15
- data/lib/generators/happy_seed/bootstrap/templates/lib/templates/haml/scaffold/_form.html.haml +3 -17
- data/lib/generators/happy_seed/devise/devise_generator.rb +11 -12
- data/lib/generators/happy_seed/devise/templates/app/views/application/_account_dropdown.html.haml +11 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/passwords/edit.html.haml +6 -19
- data/lib/generators/happy_seed/devise/templates/app/views/devise/passwords/new.html.haml +7 -14
- data/lib/generators/happy_seed/devise/templates/app/views/devise/registrations/edit.html.haml +50 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/registrations/new.html.haml +11 -20
- data/lib/generators/happy_seed/devise/templates/app/views/devise/sessions/new.html.haml +8 -25
- data/lib/generators/happy_seed/devise/templates/spec/features/forgot_password_spec.rb +1 -1
- data/lib/generators/happy_seed/facebook/facebook_generator.rb +2 -2
- data/lib/generators/happy_seed/happy_seed_generator.rb +12 -19
- data/lib/generators/happy_seed/instagram/instagram_generator.rb +1 -1
- data/lib/generators/happy_seed/jazz_hands/jazz_hands_generator.rb +3 -10
- data/lib/generators/happy_seed/omniauth/omniauth_generator.rb +14 -11
- data/lib/generators/happy_seed/omniauth/templates/app/controllers/omniauth_callbacks_controller.rb +23 -10
- data/lib/generators/happy_seed/omniauth/templates/app/controllers/registrations_controller.rb +17 -0
- data/lib/generators/happy_seed/omniauth/templates/app/models/form_user.rb +20 -0
- data/lib/generators/happy_seed/omniauth/templates/make_email_nullable.rb +7 -0
- data/lib/generators/happy_seed/omniauth/templates/spec/factories/oauth.rb +5 -0
- data/lib/generators/happy_seed/omniauth/templates/spec/features/registration_spec.rb +81 -0
- data/lib/generators/happy_seed/splash/splash_generator.rb +6 -3
- data/lib/generators/happy_seed/static/templates/Gemfile.lock +162 -0
- data/lib/generators/happy_seed/static_blog/templates/Gemfile.lock +6 -6
- data/lib/generators/happy_seed/twitter/twitter_generator.rb +1 -1
- data/lib/happy_seed/cli.rb +2 -2
- data/lib/happy_seed/version.rb +1 -1
- metadata +23 -22
- data/lib/generators/happy_seed/omniauth/templates/add_name_to_users.rb +0 -5
- data/lib/generators/happy_seed/omniauth/templates/app/controllers/users_controller.rb +0 -31
- data/lib/generators/happy_seed/omniauth/templates/app/views/users/finish_signup.html.haml +0 -26
- data/lib/generators/happy_seed/omniauth/templates/app/views/users/show.html.haml +0 -5
- data/lib/generators/happy_seed/omniauth/templates/user.rb +0 -53
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +0 -5
data/lib/generators/happy_seed/bootstrap/templates/lib/templates/haml/scaffold/_form.html.haml
CHANGED
@@ -1,19 +1,5 @@
|
|
1
|
-
= form_for @<%= singular_table_name %>, :
|
2
|
-
-if @<%= singular_table_name %>.errors.any?
|
3
|
-
.alert.alert-danger.alert-dismissable
|
4
|
-
%button.close{"aria-hidden" => "true", "data-dismiss" => "alert", :type => "button"} ×
|
5
|
-
%h4= "#{pluralize(@<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
|
6
|
-
|
7
|
-
%ul
|
8
|
-
- @<%= singular_table_name %>.errors.full_messages.each do |msg|
|
9
|
-
%li= msg
|
10
|
-
|
1
|
+
= form_for @<%= singular_table_name %>, layout: :horizontal do |f|
|
11
2
|
<% for attribute in attributes -%>
|
12
|
-
|
13
|
-
= f.label :<%= attribute.name %>, :class => 'col-sm-2 control-label'
|
14
|
-
.col-sm-10
|
15
|
-
= f.<%= attribute.field_type %> :<%= attribute.name %>, :class => 'form-control'
|
3
|
+
= f.<%= attribute.field_type %> :<%= attribute.name %>, :class => 'form-control'
|
16
4
|
<% end -%>
|
17
|
-
.
|
18
|
-
.col-sm-offset-2.col-sm-10
|
19
|
-
= f.submit :class => 'btn btn-primary'
|
5
|
+
= f.submit :class => 'btn btn-primary'
|
@@ -10,10 +10,10 @@ module HappySeed
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
gem 'devise'
|
13
|
+
gem 'devise', '~> 3.4'
|
14
14
|
|
15
15
|
Bundler.with_clean_env do
|
16
|
-
run "bundle install"
|
16
|
+
run "bundle install > /dev/null"
|
17
17
|
end
|
18
18
|
|
19
19
|
run 'rails generate devise:install'
|
@@ -22,6 +22,7 @@ module HappySeed
|
|
22
22
|
|
23
23
|
if gem_available?( "haml-rails" )
|
24
24
|
remove_file 'app/views/devise/registrations/new.html.erb'
|
25
|
+
remove_file 'app/views/devise/registrations/edit.html.erb'
|
25
26
|
remove_file 'app/views/devise/sessions/new.html.erb'
|
26
27
|
remove_file 'app/views/devise/passwords/edit.html.erb'
|
27
28
|
remove_file 'app/views/devise/passwords/new.html.erb'
|
@@ -29,6 +30,13 @@ module HappySeed
|
|
29
30
|
|
30
31
|
remove_file "spec/factories/users.rb"
|
31
32
|
|
33
|
+
begin
|
34
|
+
prepend_to_file 'spec/spec_helper.rb', "require 'devise'\n"
|
35
|
+
inject_into_file 'spec/spec_helper.rb', "\n config.include Devise::TestHelpers, type: :controller\n", :before => "\nend\n"
|
36
|
+
rescue
|
37
|
+
say_status :spec, "Unable to add devise helpers to spec_helper.rb", :red
|
38
|
+
end
|
39
|
+
|
32
40
|
directory 'app'
|
33
41
|
directory 'docs'
|
34
42
|
directory 'test'
|
@@ -43,16 +51,7 @@ module HappySeed
|
|
43
51
|
end
|
44
52
|
|
45
53
|
if File.exists?( File.join( destination_root, 'app/views/application/_header.html.haml' ) )
|
46
|
-
gsub_file 'app/views/application/_header.html.haml', "/ USER NAV",
|
47
|
-
|
48
|
-
%ul.nav.navbar-nav.navbar-right
|
49
|
-
- if user_signed_in?
|
50
|
-
%li= link_to 'Sign Out', destroy_user_session_path, :method=>:delete
|
51
|
-
- else
|
52
|
-
/ CONNECT
|
53
|
-
%li= link_to 'Sign In', new_user_session_path
|
54
|
-
%li= link_to 'Sign Up', new_user_registration_path
|
55
|
-
RUBY
|
54
|
+
gsub_file 'app/views/application/_header.html.haml', "/ USER NAV", '= render partial: "application/account_dropdown"'
|
56
55
|
else
|
57
56
|
say_status :gsub_file, "Can't find application/_header.html.haml, skipping"
|
58
57
|
end
|
data/lib/generators/happy_seed/devise/templates/app/views/application/_account_dropdown.html.haml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
%li.dropdown
|
2
|
+
%a.dropdown-toggle{ "href" => "#", "data-toggle"=>"dropdown", "role" => "button", "aria-expanded"=>"false"}
|
3
|
+
Account <span class="caret"></span>
|
4
|
+
%ul.dropdown-menu
|
5
|
+
- if user_signed_in?
|
6
|
+
= link_to 'Profile', edit_user_registration_path
|
7
|
+
= link_to 'Sign Out', destroy_user_session_path, :method=>:delete
|
8
|
+
- else
|
9
|
+
/ CONNECT
|
10
|
+
= link_to 'Sign In', new_user_session_path
|
11
|
+
= link_to 'Sign Up', new_user_registration_path
|
@@ -1,6 +1,6 @@
|
|
1
1
|
.container
|
2
2
|
.row
|
3
|
-
.
|
3
|
+
.center_panel
|
4
4
|
.panel.panel-default.only
|
5
5
|
|
6
6
|
.panel-heading
|
@@ -8,25 +8,12 @@
|
|
8
8
|
|
9
9
|
.panel-body
|
10
10
|
|
11
|
-
= form_for(resource, as: resource_name, url: password_path(resource_name), :
|
11
|
+
= form_for(resource, as: resource_name, url: password_path(resource_name), layout: :horizontal, method: 'put') do |f|
|
12
12
|
|
13
|
-
= devise_error_messages!
|
13
|
+
/ = devise_error_messages!
|
14
14
|
= f.hidden_field :reset_password_token
|
15
15
|
|
16
|
-
.
|
17
|
-
|
18
|
-
.col-lg-9= f.password_field :password, autocomplete: "off", autofocus: true, :class=>'form-control', :placeholder=>'Password'
|
16
|
+
= f.password_field :password, autocomplete: "off", autofocus: true
|
17
|
+
= f.password_field :password_confirmation, autocomplete: "off"
|
19
18
|
|
20
|
-
.form-
|
21
|
-
= f.label :password_confirmation, :class=>'control-label col-lg-3'
|
22
|
-
.col-lg-9= f.password_field :password_confirmation, autocomplete: "off", :class=>'form-control', :placeholder=>'Confirm password'
|
23
|
-
|
24
|
-
.form-group
|
25
|
-
.col-lg-9.col-lg-offset-3
|
26
|
-
= f.submit "Change my password", :class=>'btn btn-primary form-control'
|
27
|
-
|
28
|
-
.form-group
|
29
|
-
.col-lg-9.col-lg-offset-3.text-right
|
30
|
-
= link_to 'Sign in', new_user_session_path
|
31
|
-
%br
|
32
|
-
= link_to 'Sign up', new_user_registration_path
|
19
|
+
= f.submit "Change my password", :class=>'btn btn-primary form-control'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
.container
|
2
2
|
.row
|
3
|
-
.
|
3
|
+
.center_panel
|
4
4
|
.panel.panel-default.only
|
5
5
|
|
6
6
|
.panel-heading
|
@@ -8,20 +8,13 @@
|
|
8
8
|
|
9
9
|
.panel-body
|
10
10
|
|
11
|
-
= form_for(resource, as: resource_name, url: password_path(resource_name), :
|
11
|
+
= form_for(resource, as: resource_name, url: password_path(resource_name), layout: :horizontal) do |f|
|
12
12
|
|
13
|
-
= devise_error_messages!
|
13
|
+
/ = devise_error_messages!
|
14
14
|
|
15
|
-
.
|
16
|
-
= f.label :email, :class=>'control-label col-lg-3'
|
17
|
-
.col-lg-9= f.email_field :email, autofocus: true, :class=>'form-control', :placeholder=>'Email'
|
15
|
+
= f.email_field :email, autofocus: true
|
18
16
|
|
19
|
-
.
|
20
|
-
.col-lg-9.col-lg-offset-3
|
21
|
-
= f.submit "Send me reset password instructions", :class=>'btn btn-primary form-control'
|
17
|
+
= f.submit "Send me reset password instructions"
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
= link_to 'Sign in', new_user_session_path
|
26
|
-
%br
|
27
|
-
= link_to 'Sign up', new_user_registration_path
|
19
|
+
%p.text-right
|
20
|
+
= render partial: "devise/shared/links"
|
@@ -0,0 +1,50 @@
|
|
1
|
+
- @title = "Edit #{resource_name.to_s.humanize}"
|
2
|
+
.container
|
3
|
+
.row
|
4
|
+
.center_panel
|
5
|
+
.panel.panel-default.only
|
6
|
+
|
7
|
+
.panel-heading
|
8
|
+
= @title
|
9
|
+
|
10
|
+
.panel-body
|
11
|
+
|
12
|
+
= form_for resource, as: resource_name, url: registration_path(resource_name), layout: :horizontal do |f|
|
13
|
+
|
14
|
+
/ = devise_error_messages!
|
15
|
+
|
16
|
+
= f.email_field :email, autofocus: true
|
17
|
+
|
18
|
+
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
|
19
|
+
%p
|
20
|
+
Currently waiting confirmation for:
|
21
|
+
= resource.unconfirmed_email
|
22
|
+
|
23
|
+
= f.password_field :current_password
|
24
|
+
= f.password_field :password, autocomplete: "off"
|
25
|
+
= f.password_field :password_confirmation, autocomplete: "off"
|
26
|
+
|
27
|
+
= f.submit "Update"
|
28
|
+
|
29
|
+
- if devise_mapping.omniauthable?
|
30
|
+
.panel.panel-default.only
|
31
|
+
.panel-header
|
32
|
+
Connect your accounts
|
33
|
+
|
34
|
+
.panel-body
|
35
|
+
%ul
|
36
|
+
- resource_class.omniauth_providers.each do |provider|
|
37
|
+
- if resource.identities.where( :provider => provider ).first
|
38
|
+
%li= link_to "Reconnect with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider)
|
39
|
+
- else
|
40
|
+
%li= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider)
|
41
|
+
|
42
|
+
.panel.panel-default.only
|
43
|
+
|
44
|
+
.panel-heading
|
45
|
+
Cancel my account
|
46
|
+
|
47
|
+
.panel-body
|
48
|
+
%p
|
49
|
+
Unhappy?
|
50
|
+
= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete, class: "btn btn-danger"
|
data/lib/generators/happy_seed/devise/templates/app/views/devise/registrations/new.html.haml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
- @title = "Sign Up"
|
2
2
|
.container
|
3
3
|
.row
|
4
|
-
.
|
4
|
+
.center_panel
|
5
5
|
.panel.panel-default.only
|
6
6
|
|
7
7
|
.panel-heading
|
@@ -9,27 +9,18 @@
|
|
9
9
|
|
10
10
|
.panel-body
|
11
11
|
|
12
|
-
= form_for
|
12
|
+
= form_for resource, as: resource_name, url: registration_path(resource_name), layout: :horizontal do |f|
|
13
13
|
|
14
|
-
= devise_error_messages!
|
14
|
+
/ = devise_error_messages!
|
15
15
|
|
16
|
-
.
|
17
|
-
|
18
|
-
|
16
|
+
= f.email_field :email, autofocus: true
|
17
|
+
= f.password_field :password, autocomplete: "off"
|
18
|
+
= f.password_field :password_confirmation, autocomplete: "off"
|
19
19
|
|
20
|
-
.
|
21
|
-
= f.
|
22
|
-
.col-lg-9= f.password_field :password, autocomplete: "off", :class=>'form-control', :placeholder=>'Password'
|
20
|
+
- if devise_mapping.rememberable?
|
21
|
+
= f.check_box :remember_me
|
23
22
|
|
24
|
-
.
|
25
|
-
= f.label :password_confirmation, :class=>'control-label col-lg-3'
|
26
|
-
.col-lg-9= f.password_field :password_confirmation, autocomplete: "off", :class=>'form-control', :placeholder=>'Confirm password'
|
23
|
+
= f.submit "Sign Up"
|
27
24
|
|
28
|
-
|
29
|
-
|
30
|
-
= f.submit "Sign up", :class=>'btn btn-primary form-control'
|
31
|
-
|
32
|
-
.form-group
|
33
|
-
.col-lg-9.col-lg-offset-3.text-right
|
34
|
-
/ CONNECT
|
35
|
-
= link_to 'Sign in', new_user_session_path
|
25
|
+
%p.text-right
|
26
|
+
= render partial: "devise/shared/links"
|
@@ -1,39 +1,22 @@
|
|
1
1
|
- @title = "Sign In"
|
2
2
|
.container
|
3
3
|
.row
|
4
|
-
.
|
4
|
+
.center_panel
|
5
5
|
.panel.panel-default.only
|
6
|
-
|
7
6
|
.panel-heading
|
8
7
|
Sign in
|
9
8
|
|
10
9
|
.panel-body
|
11
10
|
|
12
|
-
= form_for
|
13
|
-
|
14
|
-
.form-group
|
15
|
-
= f.label :email, :class=>'control-label col-sm-3'
|
16
|
-
.col-sm-9= f.email_field :email, autofocus: true, :class=>'form-control'
|
11
|
+
= form_for resource, as: resource_name, url: session_path(resource_name), layout: :horizontal do |f|
|
17
12
|
|
18
|
-
.
|
19
|
-
|
20
|
-
.col-sm-9= f.password_field :password, autocomplete: "off", :class=>'form-control'
|
13
|
+
= f.email_field :email, autofocus: true
|
14
|
+
= f.password_field :password, autocomplete: "off"
|
21
15
|
|
22
16
|
- if devise_mapping.rememberable?
|
23
|
-
.
|
24
|
-
.col-sm-9.col-sm-offset-3
|
25
|
-
.checkbox
|
26
|
-
= f.label :remember_me do
|
27
|
-
= f.check_box :remember_me
|
28
|
-
Remember me
|
17
|
+
= f.check_box :remember_me
|
29
18
|
|
30
|
-
.form-
|
31
|
-
.col-lg-9.col-lg-offset-3
|
32
|
-
= f.submit "Sign in", :class=>'btn btn-primary form-control'
|
19
|
+
= f.submit "Sign in", :class=>'btn btn-primary form-control'
|
33
20
|
|
34
|
-
|
35
|
-
|
36
|
-
/ CONNECT
|
37
|
-
= link_to 'Sign up', new_user_registration_path
|
38
|
-
%br
|
39
|
-
= link_to 'Forgot your password?', new_user_password_path
|
21
|
+
%p.text-right
|
22
|
+
= render partial: "devise/shared/links"
|
@@ -11,12 +11,12 @@ module HappySeed
|
|
11
11
|
gem 'omniauth-facebook'
|
12
12
|
|
13
13
|
Bundler.with_clean_env do
|
14
|
-
run "bundle install"
|
14
|
+
run "bundle install > /dev/null"
|
15
15
|
end
|
16
16
|
|
17
17
|
directory 'docs'
|
18
18
|
|
19
|
-
add_omniauth :facebook, "
|
19
|
+
add_omniauth :facebook, "email"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -26,31 +26,15 @@ module HappySeed
|
|
26
26
|
RUBY
|
27
27
|
end
|
28
28
|
begin
|
29
|
-
|
29
|
+
add_env "#{provider.upcase}_APP_ID"
|
30
|
+
add_env "#{provider.upcase}_APP_SECRET"
|
30
31
|
rescue
|
31
32
|
say_status :env, "Unable to add template variables to .env", :red
|
32
33
|
end
|
33
34
|
|
34
|
-
begin
|
35
|
-
inject_into_file 'app/views/application/_header.html.haml', " %li= link_to 'sign in with #{provider}', user_omniauth_authorize_path(:#{provider})\n", after: "/ CONNECT\n"
|
36
|
-
rescue
|
37
|
-
say_status :header_links, "Unable to add links to the nav bar header", :red
|
38
|
-
end
|
39
|
-
|
40
|
-
begin
|
41
|
-
inject_into_file 'app/views/devise/sessions/new.html.haml', " = link_to 'sign in with #{provider}', user_omniauth_authorize_path(:#{provider})\n %br\n", after: "/ CONNECT\n"
|
42
|
-
rescue
|
43
|
-
say_status :sign_links, "Unable to add sign in links to app/views/devise/sessions/new.html.haml", :red
|
44
|
-
end
|
45
|
-
|
46
|
-
begin
|
47
|
-
inject_into_file 'app/views/devise/registrations/new.html.haml', " = link_to 'sign in with #{provider}', user_omniauth_authorize_path(:#{provider})\n %br\n", after: "/ CONNECT\n"
|
48
|
-
rescue
|
49
|
-
say_status :sign_up_links, "Unable to add sign in links to app/views/devise/registrations/new.html.haml"
|
50
|
-
end
|
51
|
-
|
52
35
|
inject_into_file 'app/controllers/omniauth_callbacks_controller.rb', "\n def #{provider}\n generic_callback( '#{provider}' )\n end\n", before: /\s*def generic_callback/
|
53
36
|
inject_into_file 'app/models/user.rb', :before => "\nend" do <<-"RUBY"
|
37
|
+
|
54
38
|
def #{provider}
|
55
39
|
identities.where( :provider => "#{provider}" ).first
|
56
40
|
end
|
@@ -69,6 +53,15 @@ RUBY
|
|
69
53
|
rescue
|
70
54
|
Gem.available?(name)
|
71
55
|
end
|
56
|
+
|
57
|
+
def add_env( key )
|
58
|
+
defaults_file = File.expand_path ".seed_defaults", ENV['HOME']
|
59
|
+
value = "#{key}=\n"
|
60
|
+
if File.exists? defaults_file
|
61
|
+
value = File.readlines( defaults_file ).grep( /#{key}=/ ).first || value
|
62
|
+
end
|
63
|
+
append_to_file ".env", value
|
64
|
+
end
|
72
65
|
end
|
73
66
|
end
|
74
67
|
end
|
@@ -5,26 +5,19 @@ module HappySeed
|
|
5
5
|
|
6
6
|
def install_jazz_hands
|
7
7
|
|
8
|
-
gem 'jazz_hands', :github => 'nixme/jazz_hands', :branch => 'bring-your-own-debugger', :groups => [:development, :test]
|
8
|
+
# gem 'jazz_hands', :github => 'nixme/jazz_hands', :branch => 'bring-your-own-debugger', :groups => [:development, :test]
|
9
|
+
gem 'jazz_hands', :github => 'danrabinowitz/jazz_hands', :branch => 'use-newer-version-of-pry', :groups => [:development, :test]
|
9
10
|
|
10
11
|
ruby_major_version = RUBY_VERSION.split('.')[0]
|
11
12
|
|
12
|
-
if ruby_major_version == '1'
|
13
|
-
gem 'debugger', :groups => [:development, :test]
|
14
|
-
else
|
15
|
-
gem 'byebug', :groups => [:development, :test]
|
16
|
-
end
|
17
|
-
|
18
13
|
inside 'config/initializers' do
|
19
14
|
copy_file 'jazz_hands.rb'
|
20
15
|
end
|
21
16
|
|
22
17
|
Bundler.with_clean_env do
|
23
|
-
run "bundle install"
|
18
|
+
run "bundle install > /dev/null"
|
24
19
|
end
|
25
|
-
|
26
20
|
end
|
27
|
-
|
28
21
|
end
|
29
22
|
end
|
30
23
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module HappySeed
|
2
2
|
module Generators
|
3
3
|
class OmniauthGenerator < Rails::Generators::Base
|
4
|
+
include Rails::Generators::Migration
|
4
5
|
source_root File.expand_path('../templates', __FILE__)
|
5
6
|
|
6
7
|
def install_omniauth
|
@@ -9,6 +10,8 @@ module HappySeed
|
|
9
10
|
# return
|
10
11
|
# end
|
11
12
|
|
13
|
+
migration_template("make_email_nullable.rb", "db/migrate/make_email_nullable.rb" )
|
14
|
+
|
12
15
|
unless gem_available?( "devise" )
|
13
16
|
puts "The omniauth generator requires devise"
|
14
17
|
|
@@ -22,7 +25,7 @@ module HappySeed
|
|
22
25
|
gem 'omniauth'
|
23
26
|
|
24
27
|
Bundler.with_clean_env do
|
25
|
-
run "bundle install"
|
28
|
+
run "bundle install > /dev/null"
|
26
29
|
end
|
27
30
|
|
28
31
|
generate 'model identity user:references provider:string accesstoken:string uid:string name:string email:string nickname:string image:string phone:string urls:string'
|
@@ -30,23 +33,19 @@ module HappySeed
|
|
30
33
|
remove_file 'spec/models/identity_spec.rb'
|
31
34
|
directory 'app'
|
32
35
|
directory 'spec'
|
33
|
-
route "match '/profile/:id/finish_signup' => 'users#finish_signup', via: [:get, :patch], :as => :finish_signup"
|
34
|
-
route "get '/account' => 'users#show', as: 'user'"
|
36
|
+
# route "match '/profile/:id/finish_signup' => 'users#finish_signup', via: [:get, :patch], :as => :finish_signup"
|
37
|
+
# route "get '/account' => 'users#show', as: 'user'"
|
35
38
|
|
36
39
|
begin
|
37
40
|
gsub_file "app/models/user.rb", "devise :", "devise :omniauthable, :"
|
38
|
-
|
41
|
+
gsub_file "app/models/user.rb", ", :validatable", ""
|
42
|
+
inject_into_class "app/models/user.rb", "User", " has_many :identities, dependent: :destroy\n"
|
43
|
+
# insert_into_file "app/models/user.rb", File.read( find_in_source_paths( "user.rb" ) ), :before => "\nend\n"
|
39
44
|
rescue
|
40
45
|
say_status :user_model, "Unable to add omniauthable to app/models/users.rb", :red
|
41
46
|
end
|
42
47
|
|
43
|
-
|
44
|
-
insert_into_file "app/views/application/_header.html.haml", " %li= link_to 'Account', user_path\n", after: " - if user_signed_in?\n"
|
45
|
-
rescue
|
46
|
-
say_status :header_links, "Unable to add user accounts links to the nav bar", :red
|
47
|
-
end
|
48
|
-
|
49
|
-
gsub_file 'config/routes.rb', "devise_for :users\n", "devise_for :users, :controllers => { omniauth_callbacks: 'omniauth_callbacks' }\n"
|
48
|
+
gsub_file 'config/routes.rb', "devise_for :users\n", "devise_for :users, class_name: 'FormUser', :controllers => { omniauth_callbacks: 'omniauth_callbacks', registrations: 'registrations' }\n"
|
50
49
|
|
51
50
|
directory "docs"
|
52
51
|
end
|
@@ -59,6 +58,10 @@ module HappySeed
|
|
59
58
|
rescue
|
60
59
|
Gem.available?(name)
|
61
60
|
end
|
61
|
+
|
62
|
+
def self.next_migration_number(dir)
|
63
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
64
|
+
end
|
62
65
|
end
|
63
66
|
end
|
64
67
|
end
|