Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull request creating Meetup OmniAuth Rails Example App #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions recipes/controllers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
filename = 'app/controllers/sessions_controller.rb'
copy_from_repo filename, :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
gsub_file filename, /twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter'
if prefer :collect_user_email, false
gsub_file filename, /^\s*if user.email.blank\?$.*?^\s*end$\n/m do
<<-RUBY
redirect_to root_url, :notice => 'Signed in!'
RUBY
end
end
if prefer :authorization, 'cancan'
inject_into_file filename, " user.add_role :admin if User.count == 1 # make the first user an admin\n", :after => "session[:user_id] = user.id\n"
end
Expand Down
1 change: 1 addition & 0 deletions recipes/gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
gem 'omniauth-linkedin' if prefer :omniauth_provider, 'linkedin'
gem 'omniauth-google-oauth2' if prefer :omniauth_provider, 'google_oauth2'
gem 'omniauth-tumblr' if prefer :omniauth_provider, 'tumblr'
gem 'omniauth-meetup' if prefer :omniauth_provider, 'meetup'

## Authorization
if prefer :authorization, 'cancan'
Expand Down
10 changes: 10 additions & 0 deletions recipes/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,19 @@
gsub_file 'app/models/user.rb', /class User/, 'class User < ActiveRecord::Base'
gsub_file 'app/models/user.rb', /^\s*include Mongoid::Document\n/, ''
gsub_file 'app/models/user.rb', /^\s*field.*\n/, ''
else
if prefer :collect_user_email, false
gsub_file 'app/models/user.rb', /^\s*field :email, type: String\n/, ''
end
end
if (prefer :collect_user_email, false) || !(prefer :orm, 'mongoid')
gsub_file 'app/models/user.rb', /^\s*# run 'rake db:mongoid:create_indexes' to create indexes\n/, ''
gsub_file 'app/models/user.rb', /^\s*index\(\{ email: 1 \}, \{ unique: true, background: true \}\)\n/, ''
end
if prefer :collect_user_email, false
gsub_file 'app/models/user.rb', /^(\s*attr_accessible :provider, :uid, :name), :email(\n)/, '\\1\\2'
gsub_file 'app/models/user.rb', /^\s*user\.email =.*\n/, ''
end
end
### SUBDOMAINS ###
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app'
Expand Down
22 changes: 21 additions & 1 deletion recipes/railsapps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
["rails3-devise-rspec-cucumber", "rails3-devise-rspec-cucumber"],
["rails3-mongoid-devise", "rails3-mongoid-devise"],
["rails3-mongoid-omniauth", "rails3-mongoid-omniauth"],
["rails3-subdomains", "rails3-subdomains"]] unless prefs.has_key? :railsapps
["rails3-subdomains", "rails3-subdomains"],
["rails3-mongoid-omniauth-meetup", "rails3-mongoid-omniauth-meetup"],
] unless prefs.has_key? :railsapps

case prefs[:railsapps]
when 'saas'
Expand Down Expand Up @@ -161,6 +163,24 @@
prefs[:quiet_assets] = true
prefs[:local_env_file] = true
prefs[:better_errors] = true
when 'rails3-mongoid-omniauth-meetup'
prefs[:git] = true
prefs[:database] = 'mongodb'
prefs[:orm] = 'mongoid'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'none'
prefs[:email] = 'none'
prefs[:authentication] = 'omniauth'
prefs[:omniauth_provider] = 'meetup'
prefs[:authorization] = 'none'
prefs[:starter_app] = 'users_app'
prefs[:form_builder] = 'none'
prefs[:quiet_assets] = true
prefs[:local_env_file] = true
prefs[:better_errors] = true
prefs[:collect_user_email] = false
when 'rails3-subdomains'
prefs[:git] = true
prefs[:database] = 'mongodb'
Expand Down
6 changes: 4 additions & 2 deletions recipes/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@
["Devise with Confirmable and Invitable modules","invitable"]] unless prefs.has_key? :devise_modules
end
when 'omniauth'
prefs[:omniauth_provider] = multiple_choice "OmniAuth provider?", [["Facebook", "facebook"], ["Twitter", "twitter"], ["GitHub", "github"],
["LinkedIn", "linkedin"], ["Google-Oauth-2", "google_oauth2"], ["Tumblr", "tumblr"]] unless prefs.has_key? :omniauth_provider
prefs[:omniauth_provider] = multiple_choice "OmniAuth provider?", [
["Facebook", "facebook"], ["Twitter", "twitter"], ["GitHub", "github"], ["LinkedIn", "linkedin"],
["Google-Oauth-2", "google_oauth2"], ["Tumblr", "tumblr"], ["Meetup", "meetup"],
] unless prefs.has_key? :omniauth_provider
end
prefs[:authorization] = multiple_choice "Authorization?", [["None", "none"], ["CanCan with Rolify", "cancan"]] unless prefs.has_key? :authorization
end
Expand Down
10 changes: 10 additions & 0 deletions recipes/testing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,17 @@
say_wizard "copying RSpec files from the rails3-mongoid-omniauth examples"
repo = 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
copy_from_repo 'spec/factories/users.rb', :repo => repo
gsub_file 'spec/factories/users.rb',
/twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter'
copy_from_repo 'spec/controllers/sessions_controller_spec.rb', :repo => repo
gsub_file 'spec/controllers/sessions_controller_spec.rb',
/twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter'
if prefer :collect_user_email, false
gsub_file 'spec/controllers/sessions_controller_spec.rb',
/^(\s*it "redirects )new (users )with blank email to fill in their email(" do\n)/, '\\1\\2back to root_url\\3'
gsub_file 'spec/controllers/sessions_controller_spec.rb',
/^\s*page.should have_content\('Please enter your email address'\)$.*?^\s*visit '\/signin'$\n/m, ''
end
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
Expand Down
10 changes: 10 additions & 0 deletions recipes/views.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,19 @@
end
## SHOW
copy_from_repo 'app/views/users/show.html.erb'
if prefer :collect_user_email, false
unless (prefer :templates, 'haml') || (prefer :templates, 'slim')
gsub_file 'app/views/users/show.html.erb', /^\s*<p>Email:.*\n/, ''
end
end
copy_from_repo 'app/views/users/show-subdomains_app.html.erb', :prefs => 'subdomains_app'
## EDIT
copy_from_repo 'app/views/users/edit-omniauth.html.erb', :prefs => 'omniauth'
if prefer :collect_user_email, false
unless (prefer :templates, 'haml') || (prefer :templates, 'slim')
gsub_file 'app/views/users/edit.html.erb', /^\s*<%= f\.label :email.*?^\s*<br \/>$\n/m, ''
end
end
end
### PROFILES ###
copy_from_repo 'app/views/profiles/show-subdomains_app.html.erb', :prefs => 'subdomains_app'
Expand Down