socialite 0.0.1.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +10 -0
- data/.yardopts +8 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +208 -0
- data/LICENSE +176 -0
- data/README.md +63 -0
- data/Rakefile +34 -0
- data/app/assets/images/socialite/.gitkeep +0 -0
- data/app/assets/javascripts/socialite/.gitkeep +0 -0
- data/app/assets/stylesheets/socialite/socialite.css +40 -0
- data/app/assets/stylesheets/socialite.css +7 -0
- data/app/controllers/socialite/identities_controller.rb +53 -0
- data/app/controllers/socialite/session_controller.rb +28 -0
- data/app/controllers/socialite/user_controller.rb +39 -0
- data/app/helpers/socialite/authentication_helper.rb +15 -0
- data/app/models/socialite/facebook_identity.rb +7 -0
- data/app/models/socialite/identity.rb +6 -0
- data/app/models/socialite/user.rb +42 -0
- data/app/views/socialite/identities/_identities.html.haml +14 -0
- data/app/views/socialite/session/new.html.haml +14 -0
- data/app/views/socialite/user/_form.html.haml +13 -0
- data/app/views/socialite/user/edit.html.haml +1 -0
- data/app/views/socialite/user/show.html.haml +16 -0
- data/config/initializers/simple_form.rb +90 -0
- data/config/locales/simple_form.en.yml +23 -0
- data/config/routes.rb +10 -0
- data/db/migrate/20110914215410_create_users.rb +14 -0
- data/db/migrate/20110925224222_create_identities.rb +26 -0
- data/db/migrate/20110926005551_create_facebook_identities.rb +12 -0
- data/features/authentication/facebook_signin.feature +5 -0
- data/features/authentication/twitter_signin.feature +5 -0
- data/features/identities/facebook_management.feature +14 -0
- data/features/identities/twitter_management.feature +7 -0
- data/features/registration/facebook_signup.feature +10 -0
- data/features/registration/twitter_signup.feature +0 -0
- data/features/step_definitions/authentication_steps.rb +31 -0
- data/features/step_definitions/common_steps.rb +13 -0
- data/features/step_definitions/identity_steps.rb +5 -0
- data/features/step_definitions/web_steps.rb +254 -0
- data/features/support/env.rb +58 -0
- data/features/support/hooks.rb +3 -0
- data/features/support/omniauth.rb +31 -0
- data/features/support/paths.rb +34 -0
- data/features/support/selectors.rb +39 -0
- data/lib/socialite/api_wrappers/facebook.rb +67 -0
- data/lib/socialite/api_wrappers/twitter.rb +19 -0
- data/lib/socialite/base_identity.rb +96 -0
- data/lib/socialite/controller_support.rb +136 -0
- data/lib/socialite/engine.rb +32 -0
- data/lib/socialite/service_config.rb +14 -0
- data/lib/socialite/version.rb +3 -0
- data/lib/socialite.rb +37 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/cucumber.rake +65 -0
- data/lib/tasks/socialite_tasks.rake +4 -0
- data/script/cucumber +10 -0
- data/script/rails +6 -0
- data/socialite.gemspec +39 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/home_controller.rb +11 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/home/index.html.haml +12 -0
- data/spec/dummy/app/views/home/show.html.haml +6 -0
- data/spec/dummy/app/views/layouts/application.html.erb +18 -0
- data/spec/dummy/config/application.rb +48 -0
- data/spec/dummy/config/boot.rb +20 -0
- data/spec/dummy/config/database.yml +9 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/socialite.rb +6 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +11 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/schema.rb +43 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/facebook.rb +5 -0
- data/spec/factories/identity.rb +9 -0
- data/spec/factories/twitter.rb +6 -0
- data/spec/factories/user.rb +16 -0
- data/spec/models/facebook_spec.rb +28 -0
- data/spec/models/identity_spec.rb +9 -0
- data/spec/models/user_spec.rb +27 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/support/.gitkeep +0 -0
- data/spec/support/database_loader.rb +13 -0
- data/spec/support/databases.yml +14 -0
- data/spec/support/identity_shared_example.rb +67 -0
- metadata +409 -0
@@ -0,0 +1,136 @@
|
|
1
|
+
module Socialite
|
2
|
+
module ControllerSupport
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
helper_method :current_user, :user_signed_in?, :current_user?, :default_route
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
|
11
|
+
# Set default route for redirect
|
12
|
+
#
|
13
|
+
# @param [String] the path for default redirects
|
14
|
+
# @return [String] the default path for redirect
|
15
|
+
# (see #default_route)
|
16
|
+
def default_route=(route)
|
17
|
+
@default_route = route
|
18
|
+
end
|
19
|
+
|
20
|
+
# Get default route for redirect
|
21
|
+
#
|
22
|
+
# @return [String] the default path for redirect
|
23
|
+
# (see #default_route=)
|
24
|
+
def default_route
|
25
|
+
@default_route ||= '/'
|
26
|
+
end
|
27
|
+
|
28
|
+
# Helper for supporting multiple flash messages per type
|
29
|
+
#
|
30
|
+
# @param [Symbol] the type of flash message. Common types are
|
31
|
+
# :success, :notice, :error
|
32
|
+
# @param [String] the message to attach to the flash type
|
33
|
+
# @return [Hash] all associated flash messages for this request
|
34
|
+
def flash_message(type, text)
|
35
|
+
flash[type.to_sym] ||= []
|
36
|
+
flash[type.to_sym] << text
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
# Filters
|
42
|
+
|
43
|
+
# Conditional check to see ensure a current user exists
|
44
|
+
#
|
45
|
+
# @return [Boolean]
|
46
|
+
# (see #current_user?)
|
47
|
+
def ensure_user
|
48
|
+
current_user? || deny_access('You must be logged in to perform this action.')
|
49
|
+
end
|
50
|
+
|
51
|
+
# Conditional check to see ensure there is no current user
|
52
|
+
#
|
53
|
+
# @return [Boolean]
|
54
|
+
# (see #current_user?)
|
55
|
+
def ensure_no_user
|
56
|
+
!current_user? || redirect_back_or_default
|
57
|
+
end
|
58
|
+
|
59
|
+
# Utils
|
60
|
+
|
61
|
+
# Store the location URL in the session for later use.
|
62
|
+
#
|
63
|
+
# @return [Hash] the modified session object
|
64
|
+
def store_location
|
65
|
+
session[:return_to] = request.fullpath
|
66
|
+
end
|
67
|
+
|
68
|
+
# Stores the URL for the current requested action, then redirects to
|
69
|
+
# the login page.
|
70
|
+
#
|
71
|
+
# @param [String] optional flash message to pass to the user
|
72
|
+
# @note This method sets the redirect path, but does not return false.
|
73
|
+
# Meaning you can perform actions after this method is invoked.
|
74
|
+
def deny_access(message=nil)
|
75
|
+
store_location
|
76
|
+
flash_message :notice, message if message.present?
|
77
|
+
redirect_to login_path
|
78
|
+
end
|
79
|
+
|
80
|
+
# Conditional redirect to handle an empty return_to path. If return_to
|
81
|
+
# is empty, the request is redirected to the default path
|
82
|
+
#
|
83
|
+
# @param [String] path to use as the default redirect location
|
84
|
+
# @return [Hash] the modified session hash
|
85
|
+
def redirect_back_or_default(default=nil)
|
86
|
+
default = self.default_route
|
87
|
+
redirect_to(session[:return_to] || default)
|
88
|
+
session[:return_to] = nil
|
89
|
+
end
|
90
|
+
|
91
|
+
# Fetch the User model associated with the current session.
|
92
|
+
#
|
93
|
+
# @return [User]
|
94
|
+
# (see #current_user=)
|
95
|
+
def current_user
|
96
|
+
@current_user ||= if session[:user_id]
|
97
|
+
User.find(session[:user_id])
|
98
|
+
elsif cookies[:remember_token]
|
99
|
+
User.find_by_remember_token(cookies[:remember_token])
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Assign the User model associated with the current session.
|
104
|
+
#
|
105
|
+
# @return [User]
|
106
|
+
# (see #current_user)
|
107
|
+
def current_user=(user)
|
108
|
+
user.tap do |user|
|
109
|
+
user.remember_me!
|
110
|
+
session[:user_id] = user.id
|
111
|
+
cookies[:remember_token] = user.remember_token
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Accessor method for checking if a user is currently signed in
|
116
|
+
#
|
117
|
+
# @return [Boolean]
|
118
|
+
# (see #current_user)
|
119
|
+
def user_signed_in?
|
120
|
+
!!current_user
|
121
|
+
end
|
122
|
+
alias_method :current_user?, :user_signed_in?
|
123
|
+
|
124
|
+
# Destroy the current user session, effectively logging them out upon
|
125
|
+
# the next request.
|
126
|
+
#
|
127
|
+
# @return [Hash] the modified session object
|
128
|
+
def logout!
|
129
|
+
session[:user_id] = nil
|
130
|
+
session[:return_to] = nil
|
131
|
+
@current_user = nil
|
132
|
+
cookies.delete(:remember_token)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'haml'
|
2
|
+
require 'omniauth/core'
|
3
|
+
require 'omniauth/oauth'
|
4
|
+
|
5
|
+
module Socialite
|
6
|
+
class Engine < Rails::Engine
|
7
|
+
isolate_namespace Socialite
|
8
|
+
|
9
|
+
initializer 'socialite.load_middleware', :after => :load_config_initializers do
|
10
|
+
if Socialite.service_configs[:twitter]
|
11
|
+
middleware.use OmniAuth::Strategies::Twitter,
|
12
|
+
Socialite.service_configs[:twitter].app_key,
|
13
|
+
Socialite.service_configs[:twitter].app_secret
|
14
|
+
end
|
15
|
+
|
16
|
+
if Socialite.service_configs[:facebook]
|
17
|
+
middleware.use OmniAuth::Strategies::Facebook,
|
18
|
+
Socialite.service_configs[:facebook].app_key,
|
19
|
+
Socialite.service_configs[:facebook].app_secret,
|
20
|
+
Socialite.service_configs[:facebook].options
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
ActiveSupport.on_load(:action_controller) do
|
25
|
+
include Socialite::ControllerSupport
|
26
|
+
end
|
27
|
+
|
28
|
+
ActiveSupport.on_load(:action_view) do
|
29
|
+
include Socialite::AuthenticationHelper
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module Socialite
|
4
|
+
class ServiceConfig < OpenStruct
|
5
|
+
# Set credentials and options for a given service, i.e. twitter
|
6
|
+
def initialize(app_key, app_secret, options)
|
7
|
+
super({
|
8
|
+
:app_key => app_key,
|
9
|
+
:app_secret => app_secret,
|
10
|
+
:options => options
|
11
|
+
})
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/socialite.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'haml'
|
2
|
+
require 'omniauth/core'
|
3
|
+
require 'omniauth/oauth'
|
4
|
+
|
5
|
+
module Socialite
|
6
|
+
autoload :BaseIdentity, 'socialite/base_identity'
|
7
|
+
autoload :ServiceConfig, 'socialite/service_config'
|
8
|
+
|
9
|
+
module ApiWrappers
|
10
|
+
autoload :Facebook, 'socialite/api_wrappers/facebook'
|
11
|
+
autoload :Twitter, 'socialite/api_wrappers/twitter'
|
12
|
+
end
|
13
|
+
|
14
|
+
mattr_accessor :service_configs, :root_path, :mount_prefix
|
15
|
+
@@service_configs = {}
|
16
|
+
|
17
|
+
def self.generate_token
|
18
|
+
SecureRandom.base64(15).tr('+/=lIO0', 'pqrsxyz')
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.setup(entity = nil, &block)
|
22
|
+
block.call self if block_given?
|
23
|
+
end
|
24
|
+
|
25
|
+
# config.twitter APP_KEY, APP_SECRET, :scope => ['foo', 'bar']
|
26
|
+
def self.twitter(app_key, app_secret, options = {})
|
27
|
+
@@service_configs[:twitter] = ServiceConfig.new(app_key, app_secret, options)
|
28
|
+
end
|
29
|
+
|
30
|
+
# config.facebook APP_KEY, APP_SECRET, :scope => ['foo', 'bar']
|
31
|
+
def self.facebook(app_key, app_secret, options = {})
|
32
|
+
@@service_configs[:facebook] = ServiceConfig.new(app_key, app_secret, options)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'socialite/controller_support'
|
37
|
+
require 'socialite/engine'
|
data/lib/tasks/.gitkeep
ADDED
File without changes
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
+
# files.
|
6
|
+
|
7
|
+
|
8
|
+
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
9
|
+
|
10
|
+
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
11
|
+
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'cucumber/rake/task'
|
15
|
+
|
16
|
+
namespace :cucumber do
|
17
|
+
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
|
18
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
19
|
+
t.fork = true # You may get faster startup if you set this to false
|
20
|
+
t.profile = 'default'
|
21
|
+
end
|
22
|
+
|
23
|
+
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
|
24
|
+
t.binary = vendored_cucumber_bin
|
25
|
+
t.fork = true # You may get faster startup if you set this to false
|
26
|
+
t.profile = 'wip'
|
27
|
+
end
|
28
|
+
|
29
|
+
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
|
30
|
+
t.binary = vendored_cucumber_bin
|
31
|
+
t.fork = true # You may get faster startup if you set this to false
|
32
|
+
t.profile = 'rerun'
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Run all features'
|
36
|
+
task :all => [:ok, :wip]
|
37
|
+
|
38
|
+
task :statsetup do
|
39
|
+
require 'rails/code_statistics'
|
40
|
+
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
|
41
|
+
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
desc 'Alias for cucumber:ok'
|
45
|
+
task :cucumber => 'cucumber:ok'
|
46
|
+
|
47
|
+
task :default => :cucumber
|
48
|
+
|
49
|
+
task :features => :cucumber do
|
50
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
51
|
+
end
|
52
|
+
|
53
|
+
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
|
54
|
+
task 'db:test:prepare' do
|
55
|
+
end
|
56
|
+
|
57
|
+
task :stats => 'cucumber:statsetup'
|
58
|
+
rescue LoadError
|
59
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
60
|
+
task :cucumber do
|
61
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
data/script/cucumber
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
4
|
+
if vendored_cucumber_bin
|
5
|
+
load File.expand_path(vendored_cucumber_bin)
|
6
|
+
else
|
7
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
8
|
+
require 'cucumber'
|
9
|
+
load Cucumber::BINARY
|
10
|
+
end
|
data/script/rails
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#!/usr/bin/env ruby
|
3
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_PATH = File.expand_path('../..', __FILE__)
|
6
|
+
load File.expand_path('../../spec/dummy/script/rails', __FILE__)
|
data/socialite.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require 'socialite/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'socialite'
|
8
|
+
gem.version = Socialite::VERSION
|
9
|
+
gem.platform = Gem::Platform::RUBY
|
10
|
+
gem.authors = ['Justin Smestad']
|
11
|
+
gem.email = 'justin.smestad@gmail.com'
|
12
|
+
gem.homepage = 'http://github.com/jsmestad/socialite'
|
13
|
+
gem.summary = 'Rails engine supporting multiple auth providers per user.'
|
14
|
+
gem.description = 'Rails engine supporting multiple auth providers per user.'
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split("\n")
|
17
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'rails', '~> 3.1.0'
|
21
|
+
gem.add_dependency 'sass-rails', '~> 3.1.0'
|
22
|
+
gem.add_dependency 'simple_form', '~> 1.5.2'
|
23
|
+
gem.add_dependency 'haml', '~> 3.1.2'
|
24
|
+
gem.add_dependency 'oa-core', '~> 0.3.0.rc3'
|
25
|
+
gem.add_dependency 'oa-oauth', '~> 0.3.0.rc3'
|
26
|
+
gem.add_dependency 'koala', '~> 1.2.0beta4'
|
27
|
+
gem.add_dependency 'grackle', '~> 0.1.10'
|
28
|
+
|
29
|
+
gem.add_development_dependency 'sqlite3'
|
30
|
+
gem.add_development_dependency 'yard'
|
31
|
+
gem.add_development_dependency 'rdiscount'
|
32
|
+
gem.add_development_dependency 'rspec-rails', '~> 2.6.1'
|
33
|
+
gem.add_development_dependency 'factory_girl', '~> 2.1.0'
|
34
|
+
gem.add_development_dependency 'shoulda-matchers'
|
35
|
+
gem.add_development_dependency 'cucumber-rails', '~> 1.0.6'
|
36
|
+
gem.add_development_dependency 'database_cleaner', '>= 0.6.7'
|
37
|
+
gem.add_development_dependency 'selenium-webdriver', '>= 2.4.0'
|
38
|
+
gem.add_development_dependency 'launchy', '~> 2.0.5'
|
39
|
+
end
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,9 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require jquery
|
8
|
+
//= require jquery_ujs
|
9
|
+
//= require_tree .
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
@@ -0,0 +1,12 @@
|
|
1
|
+
%h2 Unrestricted Dummy Homepage
|
2
|
+
|
3
|
+
%a{:href => '/restricted'} Go to Restricted Page
|
4
|
+
|
5
|
+
#authentication
|
6
|
+
- if user_signed_in?
|
7
|
+
= link_to 'Sign out', socialite.logout_path
|
8
|
+
- else
|
9
|
+
= link_to 'Sign in', socialite.login_path
|
10
|
+
|
11
|
+
#user
|
12
|
+
= link_to 'User Profile', socialite.user_path
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application" %>
|
6
|
+
<%= javascript_include_tag "application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<% flash.keys.each do |type| %>
|
12
|
+
<div class="flash <%= type.to_s %>"><%=h flash[type].join('<br/>') %></div>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<%= yield %>
|
16
|
+
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "active_model/railtie"
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_view/railtie"
|
7
|
+
require "action_mailer/railtie"
|
8
|
+
|
9
|
+
Bundler.require
|
10
|
+
require "socialite"
|
11
|
+
|
12
|
+
module Dummy
|
13
|
+
class Application < Rails::Application
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
|
18
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
19
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
20
|
+
|
21
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
23
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
+
|
25
|
+
# Activate observers that should always be running.
|
26
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
27
|
+
|
28
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
29
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
30
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
31
|
+
|
32
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
33
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
|
+
# config.i18n.default_locale = :de
|
35
|
+
|
36
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
37
|
+
config.encoding = "utf-8"
|
38
|
+
|
39
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
40
|
+
config.filter_parameters += [:password]
|
41
|
+
|
42
|
+
# Enable the asset pipeline
|
43
|
+
config.assets.enabled = true
|
44
|
+
|
45
|
+
# Version of your assets, change this if you want to expire all your assets
|
46
|
+
config.assets.version = '1.0'
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gemfile = File.expand_path('../../../../Gemfile', __FILE__)
|
3
|
+
|
4
|
+
if File.exist?(gemfile)
|
5
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
6
|
+
require 'bundler'
|
7
|
+
Bundler.setup
|
8
|
+
end
|
9
|
+
|
10
|
+
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
11
|
+
|
12
|
+
###
|
13
|
+
# Overiding the default boot.rb
|
14
|
+
###
|
15
|
+
# require 'rubygems'
|
16
|
+
|
17
|
+
# # Set up gems listed in the Gemfile.
|
18
|
+
# ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
19
|
+
|
20
|
+
# require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
|
25
|
+
# Do not compress assets
|
26
|
+
config.assets.compress = false
|
27
|
+
|
28
|
+
# Expands the lines which load the assets
|
29
|
+
config.assets.debug = true
|
30
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# Code is not reloaded between requests
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Full error reports are disabled and caching is turned on
|
8
|
+
config.consider_all_requests_local = false
|
9
|
+
config.action_controller.perform_caching = true
|
10
|
+
|
11
|
+
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
+
config.serve_static_assets = false
|
13
|
+
|
14
|
+
# Compress JavaScripts and CSS
|
15
|
+
config.assets.compress = true
|
16
|
+
|
17
|
+
# Don't fallback to assets pipeline if a precompiled asset is missed
|
18
|
+
config.assets.compile = false
|
19
|
+
|
20
|
+
# Generate digests for assets URLs
|
21
|
+
config.assets.digest = true
|
22
|
+
|
23
|
+
# Defaults to Rails.root.join("public/assets")
|
24
|
+
# config.assets.manifest = YOUR_PATH
|
25
|
+
|
26
|
+
# Specifies the header that your server uses for sending files
|
27
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
28
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
29
|
+
|
30
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
31
|
+
# config.force_ssl = true
|
32
|
+
|
33
|
+
# See everything in the log (default is :info)
|
34
|
+
# config.log_level = :debug
|
35
|
+
|
36
|
+
# Use a different logger for distributed setups
|
37
|
+
# config.logger = SyslogLogger.new
|
38
|
+
|
39
|
+
# Use a different cache store in production
|
40
|
+
# config.cache_store = :mem_cache_store
|
41
|
+
|
42
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
43
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
44
|
+
|
45
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
46
|
+
# config.assets.precompile += %w( search.js )
|
47
|
+
|
48
|
+
# Disable delivery errors, bad email addresses will be ignored
|
49
|
+
# config.action_mailer.raise_delivery_errors = false
|
50
|
+
|
51
|
+
# Enable threaded mode
|
52
|
+
# config.threadsafe!
|
53
|
+
|
54
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
55
|
+
# the I18n.default_locale when a translation can not be found)
|
56
|
+
config.i18n.fallbacks = true
|
57
|
+
|
58
|
+
# Send deprecation notices to registered listeners
|
59
|
+
config.active_support.deprecation = :notify
|
60
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Configure static asset server for tests with Cache-Control for performance
|
11
|
+
config.serve_static_assets = true
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
13
|
+
|
14
|
+
# Log error messages when you accidentally call methods on nil
|
15
|
+
config.whiny_nils = true
|
16
|
+
|
17
|
+
# Show full error reports and disable caching
|
18
|
+
config.consider_all_requests_local = true
|
19
|
+
config.action_controller.perform_caching = false
|
20
|
+
|
21
|
+
# Raise exceptions instead of rendering exception templates
|
22
|
+
config.action_dispatch.show_exceptions = false
|
23
|
+
|
24
|
+
# Disable request forgery protection in test environment
|
25
|
+
config.action_controller.allow_forgery_protection = false
|
26
|
+
|
27
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
28
|
+
# The :test delivery method accumulates sent emails in the
|
29
|
+
# ActionMailer::Base.deliveries array.
|
30
|
+
config.action_mailer.delivery_method = :test
|
31
|
+
|
32
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
33
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
34
|
+
# like if you have constraints or database-specific column types
|
35
|
+
# config.active_record.schema_format = :sql
|
36
|
+
|
37
|
+
# Print deprecation notices to the stderr
|
38
|
+
config.active_support.deprecation = :stderr
|
39
|
+
|
40
|
+
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
|
41
|
+
config.assets.allow_debugging = true
|
42
|
+
end
|