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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/happy_seed.rb +69 -88
  3. data/lib/generators/happy_seed/admin/admin_generator.rb +3 -2
  4. data/lib/generators/happy_seed/admin/templates/app/admin/campaigns.rb +1 -1
  5. data/lib/generators/happy_seed/admin/templates/app/admin/newsletter.rb +1 -1
  6. data/lib/generators/happy_seed/admin/templates/app/admin/user.rb +1 -0
  7. data/lib/generators/happy_seed/admin/templates/app/controllers/admin/stats_controller.rb +1 -1
  8. data/lib/generators/happy_seed/admin/templates/app/views/admin/_chart.html.haml +2 -3
  9. data/lib/generators/happy_seed/admin/templates/vendor/assets/javascripts/chartkick.js +0 -1
  10. data/lib/generators/happy_seed/base/base_generator.rb +2 -9
  11. data/lib/generators/happy_seed/base/templates/app/views/setup/index.html.haml +3 -0
  12. data/lib/generators/happy_seed/base/templates/lib/tasks/haml2erb.rake +34 -0
  13. data/lib/generators/happy_seed/bootstrap/bootstrap_generator.rb +7 -3
  14. data/lib/generators/happy_seed/bootstrap/templates/app/assets/stylesheets/application.css.scss +12 -0
  15. data/lib/generators/happy_seed/bootstrap/templates/app/helpers/application_helper.rb +5 -13
  16. data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_flashes.html.haml +1 -5
  17. data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_header.html.haml +9 -15
  18. data/lib/generators/happy_seed/bootstrap/templates/lib/templates/haml/scaffold/_form.html.haml +3 -17
  19. data/lib/generators/happy_seed/devise/devise_generator.rb +11 -12
  20. data/lib/generators/happy_seed/devise/templates/app/views/application/_account_dropdown.html.haml +11 -0
  21. data/lib/generators/happy_seed/devise/templates/app/views/devise/passwords/edit.html.haml +6 -19
  22. data/lib/generators/happy_seed/devise/templates/app/views/devise/passwords/new.html.haml +7 -14
  23. data/lib/generators/happy_seed/devise/templates/app/views/devise/registrations/edit.html.haml +50 -0
  24. data/lib/generators/happy_seed/devise/templates/app/views/devise/registrations/new.html.haml +11 -20
  25. data/lib/generators/happy_seed/devise/templates/app/views/devise/sessions/new.html.haml +8 -25
  26. data/lib/generators/happy_seed/devise/templates/spec/features/forgot_password_spec.rb +1 -1
  27. data/lib/generators/happy_seed/facebook/facebook_generator.rb +2 -2
  28. data/lib/generators/happy_seed/happy_seed_generator.rb +12 -19
  29. data/lib/generators/happy_seed/instagram/instagram_generator.rb +1 -1
  30. data/lib/generators/happy_seed/jazz_hands/jazz_hands_generator.rb +3 -10
  31. data/lib/generators/happy_seed/omniauth/omniauth_generator.rb +14 -11
  32. data/lib/generators/happy_seed/omniauth/templates/app/controllers/omniauth_callbacks_controller.rb +23 -10
  33. data/lib/generators/happy_seed/omniauth/templates/app/controllers/registrations_controller.rb +17 -0
  34. data/lib/generators/happy_seed/omniauth/templates/app/models/form_user.rb +20 -0
  35. data/lib/generators/happy_seed/omniauth/templates/make_email_nullable.rb +7 -0
  36. data/lib/generators/happy_seed/omniauth/templates/spec/factories/oauth.rb +5 -0
  37. data/lib/generators/happy_seed/omniauth/templates/spec/features/registration_spec.rb +81 -0
  38. data/lib/generators/happy_seed/splash/splash_generator.rb +6 -3
  39. data/lib/generators/happy_seed/static/templates/Gemfile.lock +162 -0
  40. data/lib/generators/happy_seed/static_blog/templates/Gemfile.lock +6 -6
  41. data/lib/generators/happy_seed/twitter/twitter_generator.rb +1 -1
  42. data/lib/happy_seed/cli.rb +2 -2
  43. data/lib/happy_seed/version.rb +1 -1
  44. metadata +23 -22
  45. data/lib/generators/happy_seed/omniauth/templates/add_name_to_users.rb +0 -5
  46. data/lib/generators/happy_seed/omniauth/templates/app/controllers/users_controller.rb +0 -31
  47. data/lib/generators/happy_seed/omniauth/templates/app/views/users/finish_signup.html.haml +0 -26
  48. data/lib/generators/happy_seed/omniauth/templates/app/views/users/show.html.haml +0 -5
  49. data/lib/generators/happy_seed/omniauth/templates/user.rb +0 -53
  50. data/test/dummy/db/test.sqlite3 +0 -0
  51. data/test/dummy/log/test.log +0 -5
@@ -1,8 +1,30 @@
1
1
  class OmniauthCallbacksController < Devise::OmniauthCallbacksController
2
+ def instagram
3
+ generic_callback( 'instagram' )
4
+ end
5
+ def facebook
6
+ generic_callback( 'facebook' )
7
+ end
8
+
9
+
2
10
  def generic_callback( provider )
3
- @user = User.find_for_oauth(env["omniauth.auth"], current_user)
11
+ @identity = Identity.find_for_oauth env["omniauth.auth"]
12
+
13
+ @user = @identity.user || current_user
14
+ if @user.nil?
15
+ @user = User.create( email: @identity.email || "" )
16
+ @identity.update_attribute( :user_id, @user.id )
17
+ end
18
+
19
+ if @user.email.blank? && @identity.email
20
+ @user.update_attribute( :email, @identity.email)
21
+ end
4
22
 
5
23
  if @user.persisted?
24
+ @identity.update_attribute( :user_id, @user.id )
25
+ # This is because we've created the user manually, and Device expects a
26
+ # FormUser class (with the validations)
27
+ @user = FormUser.find @user.id
6
28
  sign_in_and_redirect @user, event: :authentication
7
29
  set_flash_message(:notice, :success, kind: provider.capitalize) if is_navigational_format?
8
30
  else
@@ -10,13 +32,4 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
10
32
  redirect_to new_user_registration_url
11
33
  end
12
34
  end
13
-
14
- def after_sign_in_path_for(resource)
15
- if resource.email_verified?
16
- root_url
17
- # super resource
18
- else
19
- finish_signup_path(resource)
20
- end
21
- end
22
35
  end
@@ -0,0 +1,17 @@
1
+ class RegistrationsController < Devise::RegistrationsController
2
+ def update_resource(resource, params)
3
+ if resource.encrypted_password.blank? # || params[:password].blank?
4
+ resource.email = params[:email] if params[:email]
5
+ if !params[:password].blank? && params[:password] == params[:password_confirmation]
6
+ logger.info "Updating password"
7
+ resource.password = params[:password]
8
+ resource.save
9
+ end
10
+ if resource.valid?
11
+ resource.update_without_password(params)
12
+ end
13
+ else
14
+ resource.update_with_password(params)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ class FormUser < User
2
+ attr_accessor :current_password
3
+
4
+ validates_presence_of :email, if: :email_required?
5
+ validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
6
+ validates_format_of :email, with: Devise.email_regexp, allow_blank: true, if: :email_changed?
7
+
8
+ validates_presence_of :password, if: :password_required?
9
+ validates_confirmation_of :password, if: :password_required?
10
+ validates_length_of :password, within: Devise.password_length, allow_blank: true
11
+
12
+ def password_required?
13
+ return false if email.blank?
14
+ !persisted? || !password.nil? || !password_confirmation.nil?
15
+ end
16
+
17
+ def email_required?
18
+ true
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ class MakeEmailNullable < ActiveRecord::Migration
2
+ def change
3
+ change_column_null :users, :email, true
4
+ remove_index :users, :email
5
+ add_index :users, :email
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :oauth_user, :class => 'User' do
3
+
4
+ end
5
+ end
@@ -0,0 +1,81 @@
1
+ require 'rails_helper'
2
+
3
+ feature "Registrations", :type => :feature do
4
+ include Warden::Test::Helpers
5
+
6
+ after{ Warden.test_reset! }
7
+
8
+ def login_with( symbol )
9
+ @user = create symbol
10
+ login_as @user, scope: :user
11
+ end
12
+
13
+ it "should require you to be logged in" do
14
+ visit edit_user_registration_path
15
+
16
+ expect( page.body ).to include( "You need to sign in or sign up before continuing." )
17
+ end
18
+
19
+ it "should let you change add an email address without a password if you don't already have one" do
20
+ login_with :oauth_user
21
+
22
+ visit edit_user_registration_path
23
+
24
+ expect( page.body ).to_not include( "You need to sign in or sign up before continuing." )
25
+
26
+ within "#edit_user" do
27
+ fill_in "user[email]", with: "email@example.com"
28
+ end
29
+
30
+ click_button "Update"
31
+
32
+ expect( page.body ).to include( "Your account has been updated successfully")
33
+ end
34
+
35
+ it "should require your current password if you have one set" do
36
+ login_with :user
37
+
38
+ visit edit_user_registration_path
39
+
40
+ expect( page.body ).to_not include( "You need to sign in or sign up before continuing." )
41
+
42
+ within "#edit_user" do
43
+ fill_in "user[email]", with: "email@example.com"
44
+ end
45
+
46
+ click_button "Update"
47
+
48
+ expect( page.body ).to_not include( "Your account has been updated successfully")
49
+ end
50
+
51
+ it "should let you set your password initially" do
52
+ login_with :oauth_user
53
+
54
+ visit edit_user_registration_path
55
+
56
+ within "#edit_user" do
57
+ fill_in "user[email]", with: "email@example.com"
58
+ fill_in "user[password]", with: "password"
59
+ fill_in "user[password_confirmation]", with: "password"
60
+ end
61
+
62
+ click_button "Update"
63
+
64
+ expect( page.body ).to include( "Your account has been updated successfully")
65
+
66
+ logout
67
+
68
+ visit edit_user_registration_path
69
+
70
+ expect( page.body ).to include( "You need to sign in or sign up before continuing." )
71
+
72
+ within "#new_user" do
73
+ fill_in "user[email]", with: "email@example.com"
74
+ fill_in "user[password]", with: "password"
75
+ end
76
+
77
+ click_button "Sign in"
78
+
79
+ expect( page.body ).to include( "Signed in successfully." )
80
+ end
81
+ end
@@ -1,6 +1,8 @@
1
+ require 'generators/happy_seed/happy_seed_generator'
2
+
1
3
  module HappySeed
2
4
  module Generators
3
- class SplashGenerator < Rails::Generators::Base
5
+ class SplashGenerator < HappySeedGenerator
4
6
  source_root File.expand_path('../templates', __FILE__)
5
7
 
6
8
  def install_landing_page
@@ -17,7 +19,7 @@ module HappySeed
17
19
  gem 'gibbon'
18
20
 
19
21
  Bundler.with_clean_env do
20
- run "bundle install"
22
+ run "bundle install > /dev/null"
21
23
  end
22
24
 
23
25
  remove_file 'public/index.html'
@@ -34,7 +36,8 @@ module HappySeed
34
36
  append_to_file "config/initializers/assets.rb", "Rails.application.config.assets.precompile += %w( splash.css scrollReveal.js )\n"
35
37
 
36
38
  begin
37
- append_to_file ".env", "MAILCHIMP_API_KEY=\nMAILCHIMP_SPLASH_SIGNUP_LIST_ID=\n"
39
+ add_env "MAILCHIMP_API_KEY"
40
+ add_env "MAILCHIMP_SPLASH_SIGNUP_LIST_ID"
38
41
  rescue
39
42
  say_status :env, "Unable to add template .env files", :red
40
43
  end
@@ -0,0 +1,162 @@
1
+ GIT
2
+ remote: git://github.com/happyfuncode/middleman-meta-tags.git
3
+ revision: fd6d03f84216def82b684693aefb234af6534980
4
+ branch: develop
5
+ specs:
6
+ middleman-meta-tags (0.0.1)
7
+ middleman-core (>= 3.0.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (4.1.7)
13
+ i18n (~> 0.6, >= 0.6.9)
14
+ json (~> 1.7, >= 1.7.7)
15
+ minitest (~> 5.1)
16
+ thread_safe (~> 0.1)
17
+ tzinfo (~> 1.1)
18
+ bootstrap-navbar (2.2.2)
19
+ gem_config (~> 0.3)
20
+ bootstrap-sass (3.3.1.0)
21
+ sass (~> 3.2)
22
+ builder (3.2.2)
23
+ celluloid (0.16.0)
24
+ timers (~> 4.0.0)
25
+ chunky_png (1.3.3)
26
+ coffee-script (2.3.0)
27
+ coffee-script-source
28
+ execjs
29
+ coffee-script-source (1.8.0)
30
+ compass (1.0.1)
31
+ chunky_png (~> 1.2)
32
+ compass-core (~> 1.0.1)
33
+ compass-import-once (~> 1.0.5)
34
+ rb-fsevent (>= 0.9.3)
35
+ rb-inotify (>= 0.9)
36
+ sass (>= 3.3.13, < 3.5)
37
+ compass-core (1.0.1)
38
+ multi_json (~> 1.0)
39
+ sass (>= 3.3.0, < 3.5)
40
+ compass-import-once (1.0.5)
41
+ sass (>= 3.2, < 3.5)
42
+ em-websocket (0.5.1)
43
+ eventmachine (>= 0.12.9)
44
+ http_parser.rb (~> 0.6.0)
45
+ erubis (2.7.0)
46
+ eventmachine (1.0.3)
47
+ execjs (2.2.2)
48
+ ffi (1.9.6)
49
+ gem_config (0.3.1)
50
+ haml (4.0.5)
51
+ tilt
52
+ hike (1.2.3)
53
+ hitimes (1.2.2)
54
+ hooks (0.4.0)
55
+ uber (~> 0.0.4)
56
+ http_parser.rb (0.6.0)
57
+ i18n (0.6.11)
58
+ jquery-middleman (3.0.4)
59
+ thor (>= 0.14, < 2.0)
60
+ json (1.8.1)
61
+ kramdown (1.5.0)
62
+ listen (2.8.0)
63
+ celluloid (>= 0.15.2)
64
+ rb-fsevent (>= 0.9.3)
65
+ rb-inotify (>= 0.9)
66
+ middleman (3.3.7)
67
+ coffee-script (~> 2.2)
68
+ compass (>= 1.0.0, < 2.0.0)
69
+ compass-import-once (= 1.0.5)
70
+ execjs (~> 2.0)
71
+ haml (>= 4.0.5)
72
+ kramdown (~> 1.2)
73
+ middleman-core (= 3.3.7)
74
+ middleman-sprockets (>= 3.1.2)
75
+ sass (>= 3.4.0, < 4.0)
76
+ uglifier (~> 2.5)
77
+ middleman-bootstrap-navbar (2.0.0)
78
+ bootstrap-navbar (~> 2.0)
79
+ middleman-core (>= 3.0)
80
+ middleman-core (3.3.7)
81
+ activesupport (~> 4.1.0)
82
+ bundler (~> 1.1)
83
+ erubis
84
+ hooks (~> 0.3)
85
+ i18n (~> 0.6.9)
86
+ listen (>= 2.7.9, < 3.0)
87
+ padrino-helpers (~> 0.12.3)
88
+ rack (>= 1.4.5, < 2.0)
89
+ rack-test (~> 0.6.2)
90
+ thor (>= 0.15.2, < 2.0)
91
+ tilt (~> 1.4.1, < 2.0)
92
+ middleman-deploy (0.3.0)
93
+ middleman-core (>= 3.2)
94
+ net-sftp
95
+ ptools
96
+ middleman-livereload (3.1.1)
97
+ em-websocket (>= 0.2.0)
98
+ middleman-core (>= 3.0.2)
99
+ multi_json (~> 1.0)
100
+ rack-livereload
101
+ middleman-sprockets (3.3.10)
102
+ middleman-core (~> 3.3)
103
+ sprockets (~> 2.12.1)
104
+ sprockets-helpers (~> 1.1.0)
105
+ sprockets-sass (~> 1.2.0)
106
+ minitest (5.4.3)
107
+ multi_json (1.10.1)
108
+ net-sftp (2.1.2)
109
+ net-ssh (>= 2.6.5)
110
+ net-ssh (2.9.1)
111
+ padrino-helpers (0.12.4)
112
+ i18n (~> 0.6, >= 0.6.7)
113
+ padrino-support (= 0.12.4)
114
+ tilt (~> 1.4.1)
115
+ padrino-support (0.12.4)
116
+ activesupport (>= 3.1)
117
+ ptools (1.2.6)
118
+ rack (1.5.2)
119
+ rack-livereload (0.3.15)
120
+ rack
121
+ rack-test (0.6.2)
122
+ rack (>= 1.0)
123
+ rb-fsevent (0.9.4)
124
+ rb-inotify (0.9.5)
125
+ ffi (>= 0.5.0)
126
+ sass (3.4.8)
127
+ sprockets (2.12.3)
128
+ hike (~> 1.2)
129
+ multi_json (~> 1.0)
130
+ rack (~> 1.0)
131
+ tilt (~> 1.1, != 1.3.0)
132
+ sprockets-helpers (1.1.0)
133
+ sprockets (~> 2.0)
134
+ sprockets-sass (1.2.0)
135
+ sprockets (~> 2.0)
136
+ tilt (~> 1.1)
137
+ thor (0.19.1)
138
+ thread_safe (0.3.4)
139
+ tilt (1.4.1)
140
+ timers (4.0.1)
141
+ hitimes
142
+ tzinfo (1.2.2)
143
+ thread_safe (~> 0.1)
144
+ uber (0.0.11)
145
+ uglifier (2.5.3)
146
+ execjs (>= 0.3.0)
147
+ json (>= 1.8.0)
148
+
149
+ PLATFORMS
150
+ ruby
151
+
152
+ DEPENDENCIES
153
+ bootstrap-sass
154
+ builder (~> 3.0)
155
+ jquery-middleman
156
+ middleman (~> 3.3.7)
157
+ middleman-bootstrap-navbar
158
+ middleman-deploy
159
+ middleman-livereload (~> 3.1.0)
160
+ middleman-meta-tags!
161
+ tzinfo-data
162
+ wdm (~> 0.1.0)
@@ -40,7 +40,7 @@ GEM
40
40
  execjs (2.2.2)
41
41
  ffi (1.9.6)
42
42
  gem_config (0.3.1)
43
- haml (4.0.5)
43
+ haml (4.0.6)
44
44
  tilt
45
45
  hike (1.2.3)
46
46
  hitimes (1.2.2)
@@ -52,7 +52,7 @@ GEM
52
52
  thor (>= 0.14, < 2.0)
53
53
  json (1.8.1)
54
54
  kramdown (1.5.0)
55
- listen (2.8.2)
55
+ listen (2.8.3)
56
56
  celluloid (>= 0.15.2)
57
57
  rb-fsevent (>= 0.9.3)
58
58
  rb-inotify (>= 0.9)
@@ -67,7 +67,7 @@ GEM
67
67
  middleman-sprockets (>= 3.1.2)
68
68
  sass (>= 3.4.0, < 4.0)
69
69
  uglifier (~> 2.5)
70
- middleman-autometatags (0.0.1)
70
+ middleman-autometatags (0.0.2)
71
71
  middleman-core (>= 3.0.0)
72
72
  middleman-blog (3.5.3)
73
73
  addressable (~> 2.3.5)
@@ -105,7 +105,7 @@ GEM
105
105
  sprockets (~> 2.12.1)
106
106
  sprockets-helpers (~> 1.1.0)
107
107
  sprockets-sass (~> 1.2.0)
108
- minitest (5.4.3)
108
+ minitest (5.5.0)
109
109
  multi_json (1.10.1)
110
110
  net-sftp (2.1.2)
111
111
  net-ssh (>= 2.6.5)
@@ -116,7 +116,7 @@ GEM
116
116
  tilt (~> 1.4.1)
117
117
  padrino-support (0.12.4)
118
118
  activesupport (>= 3.1)
119
- ptools (1.2.6)
119
+ ptools (1.3.2)
120
120
  rack (1.5.2)
121
121
  rack-livereload (0.3.15)
122
122
  rack
@@ -144,7 +144,7 @@ GEM
144
144
  tzinfo (1.2.2)
145
145
  thread_safe (~> 0.1)
146
146
  uber (0.0.11)
147
- uglifier (2.5.3)
147
+ uglifier (2.6.0)
148
148
  execjs (>= 0.3.0)
149
149
  json (>= 1.8.0)
150
150
 
@@ -12,7 +12,7 @@ module HappySeed
12
12
  gem 'twitter'
13
13
 
14
14
  Bundler.with_clean_env do
15
- run "bundle install"
15
+ run "bundle install > /dev/null"
16
16
  end
17
17
 
18
18
  add_omniauth :twitter
@@ -5,7 +5,7 @@ module HappySeed
5
5
  desc "rails APPNAME", "Generate a new rails application"
6
6
  def rails( *args )
7
7
  file = gem_file_path( "happy_seed.rb")
8
- system( "rails new -m #{file} #{args.join( " " )}" )
8
+ system( "rails new -m #{file} #{args.join( " " )} --skip-turbolinks" )
9
9
  end
10
10
 
11
11
  desc "plugin NAME", "Generate a new rails plugin"
@@ -29,7 +29,7 @@ module HappySeed
29
29
 
30
30
  desc "static_blog NAME", "Generate a new middleman static blog project"
31
31
  def static_blog( name )
32
- require 'generators/happy_seed/static/static_blog_generator'
32
+ require 'generators/happy_seed/static_blog/static_blog_generator'
33
33
  HappySeed::Generators::StaticBlogGenerator.start
34
34
  end
35
35