happy_seed 0.0.2 → 0.0.3
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 +5 -0
- data/lib/generators/happy_seed/devise/devise_generator.rb +4 -0
- data/lib/generators/happy_seed/devise/templates/docs/README.03.devise.rdoc +1 -0
- data/lib/generators/happy_seed/devise/templates/test/mailers/previews/devise_preview.rb +13 -0
- data/lib/generators/happy_seed/facebook/facebook_generator.rb +7 -34
- data/lib/generators/happy_seed/foreman/templates/app/views/setup/index.html.haml +10 -5
- data/lib/generators/happy_seed/happy_seed_generator.rb +46 -0
- data/lib/generators/happy_seed/instagram/instagram_generator.rb +24 -0
- data/lib/generators/happy_seed/instagram/templates/docs/README.05.instagram.rdoc +25 -0
- data/lib/generators/happy_seed/omniauth/omniauth_generator.rb +2 -10
- data/lib/generators/happy_seed/omniauth/templates/app/controllers/omniauth_callbacks_controller.rb +9 -17
- data/lib/generators/happy_seed/omniauth/templates/app/models/identity.rb +7 -0
- data/lib/generators/happy_seed/omniauth/templates/user.rb +1 -1
- data/lib/generators/happy_seed/twitter/twitter_generator.rb +6 -33
- data/lib/happy_seed/version.rb +1 -1
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1579e2f69715b0bd19065cf3edf4e9c0a5bf7cd
|
4
|
+
data.tar.gz: 719b96e3c0503aedb854c2a1e13c7a2fafbe46bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 247c7d4f76ad06725ab4adc57d939fd85276acbdaa12aa65ef97ef4aceb2253aa7b363710cf0fd6ffbfb9f3638b976378b39868f0d1245b1745d44341f66bd78
|
7
|
+
data.tar.gz: 749c20258801a4c31575db54a85b14bb38c012f27b684a6807cb6ea76b85a287aa79ecb62cc63649b655146affca7b54e9d47706165d65a06866ea66eea06cc2
|
data/happy_seed.rb
CHANGED
@@ -44,6 +44,11 @@ if all_in || yes?( "Would you like to install devise?" )
|
|
44
44
|
generate "happy_seed:facebook"
|
45
45
|
packages << "facebook"
|
46
46
|
end
|
47
|
+
|
48
|
+
if all_in || yes?( "Would you like to install instagram?" )
|
49
|
+
generate "happy_seed:instagram"
|
50
|
+
packages << "instagram"
|
51
|
+
end
|
47
52
|
end
|
48
53
|
|
49
54
|
if all_in || yes?( "Would you like to install active admin?" )
|
@@ -22,6 +22,10 @@ module HappySeed
|
|
22
22
|
directory 'app'
|
23
23
|
directory 'docs'
|
24
24
|
|
25
|
+
application(nil, env: "development") do
|
26
|
+
"config.action_mailer.default_url_options = { host: 'localhost:3000' }"
|
27
|
+
end
|
28
|
+
|
25
29
|
gsub_file 'app/views/application/_header.html.haml', "/ USER NAV", <<-'RUBY'
|
26
30
|
%ul.nav.navbar-nav.navbar-right
|
27
31
|
- if user_signed_in?
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class DevisePreview < ActionMailer::Preview
|
2
|
+
def confirmation_instructions
|
3
|
+
Devise::Mailer.confirmation_instructions(User.first, "tokentokentoken")
|
4
|
+
end
|
5
|
+
|
6
|
+
def reset_password_instructions
|
7
|
+
Devise::Mailer.reset_password_instructions(User.first, "tokentokentoken")
|
8
|
+
end
|
9
|
+
|
10
|
+
def unlock_instructions
|
11
|
+
Devise::Mailer.unlock_instructions(User.first, "tokentokentoken")
|
12
|
+
end
|
13
|
+
end
|
@@ -1,22 +1,12 @@
|
|
1
|
+
require 'generators/happy_seed/happy_seed_generator'
|
2
|
+
|
1
3
|
module HappySeed
|
2
4
|
module Generators
|
3
|
-
class FacebookGenerator <
|
5
|
+
class FacebookGenerator < HappySeedGenerator
|
4
6
|
source_root File.expand_path('../templates', __FILE__)
|
5
7
|
|
6
|
-
def
|
7
|
-
|
8
|
-
puts "The facebook generator requires devise"
|
9
|
-
|
10
|
-
if yes?( "Run happy_seed:devise now?" )
|
11
|
-
generate "happy_seed:devise"
|
12
|
-
else
|
13
|
-
exit
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
unless File.exists? 'app/models/identity.rb'
|
18
|
-
generate "happy_seed:omniauth"
|
19
|
-
end
|
8
|
+
def install_facebook
|
9
|
+
require_omniauth
|
20
10
|
|
21
11
|
gem 'omniauth-facebook'
|
22
12
|
|
@@ -24,27 +14,10 @@ module HappySeed
|
|
24
14
|
run "bundle install"
|
25
15
|
end
|
26
16
|
|
27
|
-
inject_into_file 'config/initializers/devise.rb', after: "==> OmniAuth\n" do <<-'RUBY'
|
28
|
-
config.omniauth :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'], scope: 'offline_access,read_insights,manage_pages'
|
29
|
-
RUBY
|
30
|
-
end
|
31
|
-
|
32
|
-
append_to_file ".env", "FACEBOOK_APP_ID=\nFACEBOOK_APP_SECRET=\n"
|
33
|
-
inject_into_file 'app/views/application/_header.html.haml', " %li= link_to 'sign in with facebook', user_omniauth_authorize_path(:facebook)\n", after: "/ CONNECT\n"
|
34
|
-
inject_into_file 'app/views/devise/sessions/new.html.haml', " = link_to 'sign in with facebook', user_omniauth_authorize_path(:facebook)\n %br\n", after: "/ CONNECT\n"
|
35
|
-
inject_into_file 'app/views/devise/registrations/new.html.haml', " = link_to 'sign in with facebook', user_omniauth_authorize_path(:facebook)\n %br\n", after: "/ CONNECT\n"
|
36
|
-
|
37
17
|
directory 'docs'
|
38
|
-
end
|
39
18
|
|
40
|
-
|
41
|
-
|
42
|
-
Gem::Specification.find_by_name(name)
|
43
|
-
rescue Gem::LoadError
|
44
|
-
false
|
45
|
-
rescue
|
46
|
-
Gem.available?(name)
|
47
|
-
end
|
19
|
+
add_omniauth :facebook, "offline_access,read_insights,manage_pages"
|
20
|
+
end
|
48
21
|
end
|
49
22
|
end
|
50
23
|
end
|
@@ -10,12 +10,17 @@
|
|
10
10
|
.row
|
11
11
|
.col-sm-2
|
12
12
|
.panel
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
.panel-header
|
14
|
+
Nav
|
15
|
+
.panel-body
|
16
|
+
%ul.affix
|
17
17
|
%li
|
18
|
-
%a{ href: "
|
18
|
+
%a{ href: "/rails/mailers"}Mailer Previews
|
19
|
+
%li
|
20
|
+
%a{ href: "#env" }Environment Variables
|
21
|
+
- @docs.each do |f|
|
22
|
+
%li
|
23
|
+
%a{ href: "##{f[:name]}"}= f[:name]
|
19
24
|
.col-sm-10
|
20
25
|
/ Environment Variables
|
21
26
|
%h3
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module HappySeed
|
2
|
+
module Generators
|
3
|
+
class HappySeedGenerator < Rails::Generators::Base
|
4
|
+
protected
|
5
|
+
def require_omniauth
|
6
|
+
unless gem_available?( "devise" )
|
7
|
+
puts "The omniauth generator requires devise"
|
8
|
+
|
9
|
+
if yes?( "Run happy_seed:devise now?" )
|
10
|
+
generate "happy_seed:devise"
|
11
|
+
else
|
12
|
+
exit
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
unless File.exists? 'app/models/identity.rb'
|
17
|
+
generate "happy_seed:omniauth"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_omniauth( provider, scope = nil )
|
22
|
+
scopeline = nil
|
23
|
+
scopeline = ", scope: \"#{scope}\"" if scope
|
24
|
+
inject_into_file 'config/initializers/devise.rb', after: "==> OmniAuth\n" do <<-"RUBY"
|
25
|
+
config.omniauth :#{provider}, ENV['#{provider.upcase}_APP_ID'], ENV['#{provider.upcase}_APP_SECRET']#{scopeline}
|
26
|
+
RUBY
|
27
|
+
end
|
28
|
+
append_to_file ".env", "#{provider.upcase}_APP_ID=\n#{provider.upcase}_APP_SECRET=\n"
|
29
|
+
|
30
|
+
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"
|
31
|
+
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"
|
32
|
+
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"
|
33
|
+
inject_into_file 'app/controllers/omniauth_callbacks_controller.rb', "\n def #{provider}\n generic_callback( '#{provider}' )\n end\n", before: /\s*def generic_callback/
|
34
|
+
end
|
35
|
+
|
36
|
+
def gem_available?(name)
|
37
|
+
Gem::Specification.find_by_name(name)
|
38
|
+
rescue Gem::LoadError
|
39
|
+
false
|
40
|
+
rescue
|
41
|
+
Gem.available?(name)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'generators/happy_seed/happy_seed_generator'
|
2
|
+
|
3
|
+
module HappySeed
|
4
|
+
module Generators
|
5
|
+
class InstagramGenerator < HappySeedGenerator
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
def install_instagram
|
9
|
+
require_omniauth
|
10
|
+
|
11
|
+
gem 'omniauth-instagram'
|
12
|
+
gem 'instagram'
|
13
|
+
|
14
|
+
Bundler.with_clean_env do
|
15
|
+
run "bundle install"
|
16
|
+
end
|
17
|
+
|
18
|
+
directory "docs"
|
19
|
+
|
20
|
+
add_omniauth :instagram
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
HappySeed Instagram Install
|
2
|
+
====================
|
3
|
+
|
4
|
+
### What does this do?
|
5
|
+
|
6
|
+
The happy_seed:instagram depends upon happy_seed:omniauth and
|
7
|
+
|
8
|
+
* Installs instagram authentication
|
9
|
+
* Installs instagram gem
|
10
|
+
* Installs links in the nav bar and use signup/signin pages
|
11
|
+
|
12
|
+
### Why do you want this?
|
13
|
+
|
14
|
+
If you want to have the user connect via instagram, this is the one line command for it.
|
15
|
+
|
16
|
+
### Environment Variables
|
17
|
+
|
18
|
+
```
|
19
|
+
INSTAGRAM_APP_ID=
|
20
|
+
INSTAGRAM_APP_SECRET=
|
21
|
+
```
|
22
|
+
|
23
|
+
### What needs to be done?
|
24
|
+
|
25
|
+
na
|
@@ -25,16 +25,7 @@ module HappySeed
|
|
25
25
|
run "bundle install"
|
26
26
|
end
|
27
27
|
|
28
|
-
generate '
|
29
|
-
|
30
|
-
puts Rails.root
|
31
|
-
|
32
|
-
migration_file = (Dir.glob( File.join( Rails.root, "db/migrate/*add_name_to_users.rb" ) ).first || "").gsub( /.*db\/migrate/, "db/migrate" )
|
33
|
-
remove_file migration_file
|
34
|
-
|
35
|
-
copy_file "add_name_to_users.rb", migration_file
|
36
|
-
|
37
|
-
generate 'model identity user:references provider:string uid:string'
|
28
|
+
generate 'model identity user:references provider:string uid:string name:string email:string nickname:string image:string phone:string urls:string'
|
38
29
|
remove_file 'app/models/identity.rb'
|
39
30
|
directory 'app'
|
40
31
|
route "match '/profile/:id/finish_signup' => 'users#finish_signup', via: [:get, :patch], :as => :finish_signup"
|
@@ -42,6 +33,7 @@ module HappySeed
|
|
42
33
|
|
43
34
|
gsub_file "app/models/user.rb", "devise :", "devise :omniauthable, :"
|
44
35
|
insert_into_file "app/models/user.rb", File.read( find_in_source_paths( "user.rb" ) ), :before => "\nend\n"
|
36
|
+
insert_into_file "app/views/application/_header.html.haml", " %li= link_to 'Account', user_path\n", after: " - if user_signed_in?\n"
|
45
37
|
gsub_file 'config/routes.rb', "devise_for :users\n", "devise_for :users, :controllers => { omniauth_callbacks: 'omniauth_callbacks' }\n"
|
46
38
|
directory "docs"
|
47
39
|
end
|
data/lib/generators/happy_seed/omniauth/templates/app/controllers/omniauth_callbacks_controller.rb
CHANGED
@@ -1,22 +1,14 @@
|
|
1
1
|
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
2
|
-
def
|
3
|
-
|
4
|
-
def #{provider}
|
5
|
-
@user = User.find_for_oauth(env["omniauth.auth"], current_user)
|
2
|
+
def generic_callback( provider )
|
3
|
+
@user = User.find_for_oauth(env["omniauth.auth"], current_user)
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
[:twitter, :facebook, :linked_in].each do |provider|
|
19
|
-
provides_callback_for provider
|
5
|
+
if @user.persisted?
|
6
|
+
sign_in_and_redirect @user, event: :authentication
|
7
|
+
set_flash_message(:notice, :success, kind: provider.capitalize) if is_navigational_format?
|
8
|
+
else
|
9
|
+
session["devise.#{provider}_data"] = env["omniauth.auth"]
|
10
|
+
redirect_to new_user_registration_url
|
11
|
+
end
|
20
12
|
end
|
21
13
|
|
22
14
|
def after_sign_in_path_for(resource)
|
@@ -6,6 +6,13 @@ class Identity < ActiveRecord::Base
|
|
6
6
|
def self.find_for_oauth(auth)
|
7
7
|
identity = find_by(provider: auth.provider, uid: auth.uid)
|
8
8
|
identity = create(uid: auth.uid, provider: auth.provider) if identity.nil?
|
9
|
+
identity.name = auth.info.name
|
10
|
+
identity.email = auth.info.email
|
11
|
+
identity.nickname = auth.info.nickname
|
12
|
+
identity.image = auth.info.image
|
13
|
+
identity.phone = auth.info.phone
|
14
|
+
identity.urls = auth.info.urls
|
15
|
+
identity.save
|
9
16
|
identity
|
10
17
|
end
|
11
18
|
end
|
@@ -30,7 +30,7 @@
|
|
30
30
|
# Create the user if it's a new registration
|
31
31
|
if user.nil?
|
32
32
|
user = User.new(
|
33
|
-
name: auth.extra.raw_info.name,
|
33
|
+
# name: auth.extra.raw_info.name,
|
34
34
|
#username: auth.info.nickname || auth.uid,
|
35
35
|
email: email ? email : "#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com",
|
36
36
|
password: Devise.friendly_token[0,20]
|
@@ -1,22 +1,12 @@
|
|
1
|
+
require 'generators/happy_seed/happy_seed_generator'
|
2
|
+
|
1
3
|
module HappySeed
|
2
4
|
module Generators
|
3
|
-
class TwitterGenerator <
|
5
|
+
class TwitterGenerator < HappySeedGenerator
|
4
6
|
source_root File.expand_path('../templates', __FILE__)
|
5
7
|
|
6
|
-
def
|
7
|
-
|
8
|
-
puts "The twitter generator requires devise"
|
9
|
-
|
10
|
-
if yes?( "Run happy_seed:devise now?" )
|
11
|
-
generate "happy_seed:devise"
|
12
|
-
else
|
13
|
-
exit
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
unless File.exists? 'app/models/identity.rb'
|
18
|
-
generate "happy_seed:omniauth"
|
19
|
-
end
|
8
|
+
def install_twitter
|
9
|
+
require_omniauth
|
20
10
|
|
21
11
|
gem 'omniauth-twitter'
|
22
12
|
|
@@ -24,27 +14,10 @@ module HappySeed
|
|
24
14
|
run "bundle install"
|
25
15
|
end
|
26
16
|
|
27
|
-
|
28
|
-
config.omniauth :twitter, ENV['TWITTER_APP_ID'], ENV['TWITTER_APP_SECRET']
|
29
|
-
RUBY
|
30
|
-
end
|
31
|
-
append_to_file ".env", "TWITTER_APP_ID=\nTWITTER_APP_SECRET=\n"
|
32
|
-
|
33
|
-
inject_into_file 'app/views/application/_header.html.haml', " %li= link_to 'sign in with twitter', user_omniauth_authorize_path(:twitter)\n", after: "/ CONNECT\n"
|
34
|
-
inject_into_file 'app/views/devise/sessions/new.html.haml', " = link_to 'sign in with twitter', user_omniauth_authorize_path(:twitter)\n %br\n", after: "/ CONNECT\n"
|
35
|
-
inject_into_file 'app/views/devise/registrations/new.html.haml', " = link_to 'sign in with twitter', user_omniauth_authorize_path(:twitter)\n %br\n", after: "/ CONNECT\n"
|
17
|
+
add_omniauth :twitter
|
36
18
|
|
37
19
|
directory "docs"
|
38
20
|
end
|
39
|
-
|
40
|
-
private
|
41
|
-
def gem_available?(name)
|
42
|
-
Gem::Specification.find_by_name(name)
|
43
|
-
rescue Gem::LoadError
|
44
|
-
false
|
45
|
-
rescue
|
46
|
-
Gem.available?(name)
|
47
|
-
end
|
48
21
|
end
|
49
22
|
end
|
50
23
|
end
|
data/lib/happy_seed/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: happy_seed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Schenk
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/generators/happy_seed/devise/templates/app/views/devise/registrations/new.html.haml
|
91
91
|
- lib/generators/happy_seed/devise/templates/app/views/devise/sessions/new.html.haml
|
92
92
|
- lib/generators/happy_seed/devise/templates/docs/README.03.devise.rdoc
|
93
|
+
- lib/generators/happy_seed/devise/templates/test/mailers/previews/devise_preview.rb
|
93
94
|
- lib/generators/happy_seed/facebook/facebook_generator.rb
|
94
95
|
- lib/generators/happy_seed/facebook/templates/docs/README.06.facebook.rdoc
|
95
96
|
- lib/generators/happy_seed/foreman/foreman_generator.rb
|
@@ -101,6 +102,9 @@ files:
|
|
101
102
|
- lib/generators/happy_seed/foreman/templates/application_controller.rb
|
102
103
|
- lib/generators/happy_seed/foreman/templates/config/unicorn.rb
|
103
104
|
- lib/generators/happy_seed/foreman/templates/docs/README.00.base.rdoc
|
105
|
+
- lib/generators/happy_seed/happy_seed_generator.rb
|
106
|
+
- lib/generators/happy_seed/instagram/instagram_generator.rb
|
107
|
+
- lib/generators/happy_seed/instagram/templates/docs/README.05.instagram.rdoc
|
104
108
|
- lib/generators/happy_seed/omniauth/omniauth_generator.rb
|
105
109
|
- lib/generators/happy_seed/omniauth/templates/add_name_to_users.rb
|
106
110
|
- lib/generators/happy_seed/omniauth/templates/app/controllers/omniauth_callbacks_controller.rb
|