gunnertechnology 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README +0 -0
- data/Rakefile +2 -0
- data/gunnertechnology.gemspec +28 -0
- data/lib/generators/project/USAGE +8 -0
- data/lib/generators/project/project_generator.rb +61 -0
- data/lib/generators/project/templates/app/controllers/authentications_controller.rb +85 -0
- data/lib/generators/project/templates/app/models/authentication.rb +17 -0
- data/lib/generators/project/templates/app/views/layouts/application.html.erb +77 -0
- data/lib/generators/project/templates/app/views/shared/_facebook_init.html.erb +12 -0
- data/lib/generators/project/templates/app/views/shared/_flash_messages.html.erb +7 -0
- data/lib/generators/project/templates/app/views/shared/_footer.html.erb +15 -0
- data/lib/generators/project/templates/app/views/shared/_google_analytics.html.erb +11 -0
- data/lib/generators/project/templates/app/views/shared/_header.html.erb +23 -0
- data/lib/generators/project/templates/config/facebook_config.yml +29 -0
- data/lib/generators/project/templates/config/google_analytics_config.yml +8 -0
- data/lib/generators/project/templates/config/initializers/load_facebook_config.rb +2 -0
- data/lib/generators/project/templates/config/initializers/load_google_analytics_config.rb +2 -0
- data/lib/generators/project/templates/config/initializers/load_seo_config.rb +2 -0
- data/lib/generators/project/templates/config/initializers/omniauth.rb +91 -0
- data/lib/generators/project/templates/config/providers.yml +27 -0
- data/lib/generators/project/templates/config/seo_config.yml +8 -0
- data/lib/generators/project/templates/db/create_authentications.rb +21 -0
- data/lib/generators/project/templates/public/javascripts/libs/PIE.htc +73 -0
- data/lib/generators/project/templates/public/javascripts/libs/colorpicker.js +484 -0
- data/lib/generators/project/templates/public/javascripts/libs/dd_belatedpng.js +13 -0
- data/lib/generators/project/templates/public/javascripts/libs/eye.js +34 -0
- data/lib/generators/project/templates/public/javascripts/libs/head.js +8 -0
- data/lib/generators/project/templates/public/javascripts/libs/jquery.validationEngine-en.js +130 -0
- data/lib/generators/project/templates/public/javascripts/libs/jquery.validationEngine-es.js +124 -0
- data/lib/generators/project/templates/public/javascripts/libs/jquery.validationEngine-fr.js +119 -0
- data/lib/generators/project/templates/public/javascripts/libs/jquery.validationEngine-it.js +103 -0
- data/lib/generators/project/templates/public/javascripts/libs/jquery.validationEngine-pt.js +125 -0
- data/lib/generators/project/templates/public/javascripts/libs/jquery.validationEngine-ro.js +126 -0
- data/lib/generators/project/templates/public/javascripts/libs/jquery.validationEngine.js +1137 -0
- data/lib/generators/project/templates/public/javascripts/libs/layout.js +67 -0
- data/lib/generators/project/templates/public/javascripts/libs/modernizr-1.6.min.js +30 -0
- data/lib/generators/project/templates/public/javascripts/libs/utils.js +252 -0
- data/lib/generators/project/templates/public/javascripts/mylibs/.gitignore +3 -0
- data/lib/generators/project/templates/public/javascripts/plugins.js +38 -0
- data/lib/generators/project/templates/public/javascripts/profiling/config.js +59 -0
- data/lib/generators/project/templates/public/javascripts/profiling/yahoo-profiling.min.js +39 -0
- data/lib/generators/project/templates/public/javascripts/script.js +46 -0
- data/lib/generators/project/templates/public/stylesheets/grids/1008_24_10_10.css +201 -0
- data/lib/generators/project/templates/public/stylesheets/grids/fluid.css +320 -0
- data/lib/generators/project/templates/public/stylesheets/handheld.css +8 -0
- data/lib/generators/project/templates/public/stylesheets/profiling/yahoo-profiling.css +7 -0
- data/lib/generators/project/templates/public/stylesheets/reset.css +53 -0
- data/lib/generators/project/templates/public/stylesheets/text.css +84 -0
- data/lib/generators/project/templates/public/stylesheets/validationEngine.jquery.css +142 -0
- data/lib/generators/project/templates/public/swfs/charts.swf +0 -0
- data/lib/gunnertechnology/version.rb +3 -0
- data/lib/gunnertechnology.rb +47 -0
- metadata +206 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "gunnertechnology/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "gunnertechnology"
|
7
|
+
s.version = Gunnertechnology::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Cody Swann"]
|
10
|
+
s.email = ["developers@gunnertech.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{GT Functionality Packaged as a Gem for Easy Reuse}
|
13
|
+
s.description = %q{The Gunner Technology gem contains much of the functionality we use from Rails project to Rails Project}
|
14
|
+
|
15
|
+
s.rubyforge_project = "gunnertechnology"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency('rails', '~>3.0')
|
23
|
+
s.add_dependency("jquery-rails", "~>0.2.6")
|
24
|
+
s.add_dependency("devise", "~>1.1.5")
|
25
|
+
s.add_dependency("omniauth", "~>0.1.6")
|
26
|
+
s.add_dependency("simple_form", "~>1.3.0")
|
27
|
+
s.add_development_dependency("nifty-generators", "~>0.4.2")
|
28
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class ProjectGenerator < Rails::Generators::NamedBase
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
argument :layout_name, :type => :string, :default => "application"
|
4
|
+
argument :devise_model_name, :type => :string, :default => "User"
|
5
|
+
|
6
|
+
def generate_layout
|
7
|
+
template "app/views/layouts/application.html.erb", "app/views/layouts/#{file_name}.html.erb"
|
8
|
+
directory "public/javascripts", "public/javascripts"
|
9
|
+
directory "public/stylesheets", "public/stylesheets"
|
10
|
+
directory "public/swfs", "public/swfs"
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate_facebook_config
|
14
|
+
copy_file "config/facebook_config.yml", "config/facebook_config.yml"
|
15
|
+
copy_file "config/initializers/load_facebook_config.rb", "config/initializers/facebook_config.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate_google_analytics_config
|
19
|
+
copy_file "config/google_analytics_config.yml", "config/facebook_config.yml"
|
20
|
+
copy_file "config/initializers/load_google_analytics_config.rb", "config/initializers/load_google_analytics_config.rb"
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_seo_config
|
24
|
+
copy_file "config/seo_config.yml", "config/seo_config.yml"
|
25
|
+
copy_file "config/initializers/load_seo.rb", "config/initializers/load_seo_config.rb"
|
26
|
+
end
|
27
|
+
|
28
|
+
def generate_providers_config
|
29
|
+
copy_file "config/providers.yml", "config/providers.yml"
|
30
|
+
copy_file "config/initializers/omniauth.rb", "config/initializers/omniauth.rb"
|
31
|
+
end
|
32
|
+
|
33
|
+
def generate_jquery
|
34
|
+
generate("jquery:install")
|
35
|
+
end
|
36
|
+
|
37
|
+
def generate_simple_form
|
38
|
+
generate("simple_form:install")
|
39
|
+
end
|
40
|
+
|
41
|
+
def generate_devise
|
42
|
+
generate("devise:install")
|
43
|
+
generate("devise",devise_model_name)
|
44
|
+
end
|
45
|
+
|
46
|
+
def generate_authentication
|
47
|
+
# model
|
48
|
+
template "app/models/authentication.rb", "app/models/authentication.rb"
|
49
|
+
# controller
|
50
|
+
template "app/controllers/authentications_controller.rb", "app/controllers/authentications_controller.rb"
|
51
|
+
# migration
|
52
|
+
migration_template "create_authentications.rb", "db/migrate/add_foo_to_bar.rb"
|
53
|
+
# route
|
54
|
+
route("match '/auth/:provider/callback' => 'authentications#create'")
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
def file_name
|
59
|
+
layout_name.underscore
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
class AuthenticationsController < ApplicationController
|
2
|
+
|
3
|
+
def index
|
4
|
+
@authentications = current_user.authentications if current_user
|
5
|
+
end
|
6
|
+
|
7
|
+
def build_omniauth(faux_ominauth)
|
8
|
+
pieces = faux_ominauth.split("~~~")
|
9
|
+
{
|
10
|
+
'provider' => pieces[0],
|
11
|
+
'uid' => pieces[1],
|
12
|
+
'credentials' => {
|
13
|
+
'token' => pieces[2],
|
14
|
+
'secret' => pieces[3],
|
15
|
+
},
|
16
|
+
'user_info' => {
|
17
|
+
'nickname' => pieces[4]
|
18
|
+
}
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def create
|
23
|
+
omniauth = params[:faux_ominauth].nil? ? request.env["omniauth.auth"] : build_omniauth(params[:faux_ominauth])
|
24
|
+
if omniauth
|
25
|
+
# THIS IS A MESS. WE CAN'T CARRY PARAMETERS THROUGH TO THE NETWORK, SO WE HAVE TO SET A SESSION VARIABLE. BUT, WE HAVE TO IGNORE THAT SESSION VARIABLE IF THE USER
|
26
|
+
# IS TRYING TO CONNECT FACEBOOOK FROM THEIR RETAILER PAGE. BUT IF ARE TRYING TO CONNECT TO A FACEBOOK PAGE, WE NEED TO HONOR THE SESSION VARIABLE
|
27
|
+
type = omniauth['provider'] == 'facebook' && params[:faux_ominauth].nil? ? 'User' : (params[:auth_type] || session[:auth_type] || 'User')
|
28
|
+
uid = (omniauth['uid']||omniauth['extra']['access_token'].params['member_id'])
|
29
|
+
authentication = Authentication.find_by_provider_and_authenticationable_type_and_uid(omniauth['provider'], type, uid)
|
30
|
+
|
31
|
+
if type == 'Retailer'
|
32
|
+
retailer_id = params[:auth_type_id] || session[:retailer_id]
|
33
|
+
session[:auth_type] = nil
|
34
|
+
session[:retailer_id] = nil
|
35
|
+
if !retailer_id
|
36
|
+
redirect_to root_url
|
37
|
+
end
|
38
|
+
|
39
|
+
retailer = Retailer.find(retailer_id)
|
40
|
+
if authentication
|
41
|
+
flash[:notice] = "You already added that account"
|
42
|
+
else
|
43
|
+
retailer.authentications.create!(:nickname => omniauth['user_info']['nickname'], :provider => omniauth['provider'], :uid => uid, :token => omniauth['credentials']['token'], :secret => omniauth['credentials']['secret'])
|
44
|
+
end
|
45
|
+
redirect_to edit_retailer_url(retailer)
|
46
|
+
else
|
47
|
+
if authentication
|
48
|
+
flash[:notice] = "Signed in successfully."
|
49
|
+
sign_in_and_redirect(:user, authentication.authenticationable)
|
50
|
+
elsif current_user
|
51
|
+
current_user.authentications.create!(:nickname => omniauth['user_info']['nickname'], :provider => omniauth['provider'], :uid => uid, :token => omniauth['credentials']['token'], :secret => omniauth['credentials']['secret'])
|
52
|
+
flash[:notice] = "Authentication successful."
|
53
|
+
|
54
|
+
if retailer_id = session[:retailer_id]
|
55
|
+
session[:auth_type] = nil
|
56
|
+
session[:retailer_id] = nil
|
57
|
+
|
58
|
+
redirect_to edit_retailer_url(retailer_id)
|
59
|
+
else
|
60
|
+
redirect_to authentications_url
|
61
|
+
end
|
62
|
+
else
|
63
|
+
user = User.new
|
64
|
+
user.apply_omniauth(omniauth,params[:user])
|
65
|
+
if user.save
|
66
|
+
flash[:notice] = "Signed in successfully."
|
67
|
+
sign_in_and_redirect(:user, user)
|
68
|
+
else
|
69
|
+
session[:omniauth] = omniauth.except('extra')
|
70
|
+
redirect_to new_user_registration_url
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
else
|
75
|
+
redirect_to root_url
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def destroy
|
80
|
+
@authentication = current_user.authentications.find(params[:id])
|
81
|
+
@authentication.destroy
|
82
|
+
flash[:notice] = "Successfully destroyed authentication."
|
83
|
+
redirect_to authentications_url
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Authentication < ActiveRecord::Base
|
2
|
+
PROVIDER_CONFIG = YAML.load_file("#{::Rails.root.to_s}/config/providers.yml")[::Rails.env]
|
3
|
+
|
4
|
+
belongs_to :authenticationable, :polymorphic => true
|
5
|
+
|
6
|
+
validates :provider, :presence => true, :length => 1..64
|
7
|
+
validates :nickname, :presence => true, :length => 1..64
|
8
|
+
validates :uid, :presence => true, :length => 1..128
|
9
|
+
validates :token, :length => 0..128, :allow_blank => true
|
10
|
+
validates :secret, :length => 0..128, :allow_blank => true
|
11
|
+
|
12
|
+
for p in PROVIDER_CONFIG['providers']
|
13
|
+
scope p['name'].to_sym, where(:provider => p['name'])
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_accessible :authenticationable_id, :authenticationable_type, :provider, :uid, :token, :secret, :nickname
|
17
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<!--[if lt IE 7 ]> <html xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml" lang="en" class="no-js ie6<%%= use_fluid_layout? ? ' fluid' : '' %%> "> <![endif]-->
|
3
|
+
<!--[if IE 7 ]> <html xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml" lang="en" class="no-js ie7<%%= use_fluid_layout? ? ' fluid' : '' %%>"> <![endif]-->
|
4
|
+
<!--[if IE 8 ]> <html xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml" lang="en" class="no-js ie8<%%= use_fluid_layout? ? ' fluid' : '' %%>"> <![endif]-->
|
5
|
+
<!--[if IE 9 ]> <html xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml" lang="en" class="no-js ie9<%%= use_fluid_layout? ? ' fluid' : '' %%>"> <![endif]-->
|
6
|
+
<!--[if (gt IE 9)|!(IE)]><!--> <html xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml" lang="en" class="no-js<%%= use_fluid_layout? ? ' fluid' : '' %%>"> <!--<![endif]-->
|
7
|
+
<head>
|
8
|
+
<title><%%= content_for?(:title) ? "#{content_for(:title)} - #{SEO_CONFIG[:title]}" : t(:site_title) %%></title>
|
9
|
+
<%%= stylesheet_link_tag :defaults %%>
|
10
|
+
<%%= javascript_include_tag "libs/head.js" %%>
|
11
|
+
<script>
|
12
|
+
head.js(<%%= raw (javascript_include_tag(:defaults)+content_for(:javascripts)).scan(/<script .*src=(['"][^'"]+['"]).*> *<\/script>/).join(",") %%>);
|
13
|
+
</script>
|
14
|
+
<%%= csrf_meta_tag %%>
|
15
|
+
|
16
|
+
<%%= favicon_link_tag %%>
|
17
|
+
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
18
|
+
|
19
|
+
<meta charset="utf-8" />
|
20
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
21
|
+
<%%= yield(:meta) %%>
|
22
|
+
<script>
|
23
|
+
head.ready(function() {
|
24
|
+
(function($){
|
25
|
+
$(function(){
|
26
|
+
<%%= content_for(:javascripts).gsub(/<script[^>]*>/,"").gsub(/<\/script>/,"") %%>
|
27
|
+
});
|
28
|
+
}(jQuery));
|
29
|
+
});
|
30
|
+
</script>
|
31
|
+
<style>
|
32
|
+
html.fluid .container_24 {
|
33
|
+
max-width:<%%= content_for?(:max_width) ? content_for(:max_width) : '1300' %%>px;
|
34
|
+
min-width:<%%= content_for?(:min_width) ? content_for(:min_width) : '1008' %%>px;
|
35
|
+
}
|
36
|
+
</style>
|
37
|
+
<%%= yield(:stylesheets) %%>
|
38
|
+
<%%= yield(:head) %%>
|
39
|
+
<%% if content_for?(:opengraph) %%>
|
40
|
+
<%%= yield(:opengraph) %%>
|
41
|
+
<%% else %%>
|
42
|
+
<meta property="og:title" content="<%%= FACEBOOK_CONFIG[:opengraph]['title'] %%>"/>
|
43
|
+
<meta property="og:type" content="<%%= FACEBOOK_CONFIG[:opengraph]['type'] %%>"/>
|
44
|
+
<meta property="og:url" content="<%%= FACEBOOK_CONFIG[:opengraph]['url'] %%>"/>
|
45
|
+
<meta property="og:image" content="<%%= FACEBOOK_CONFIG[:opengraph]['image'] %%>"/>
|
46
|
+
<meta property="og:site_name" content="<%%= FACEBOOK_CONFIG[:opengraph]['site_name'] %%>"/>
|
47
|
+
<meta property="fb:admins" content="<%%= FACEBOOK_CONFIG[:admins].join(",") %%>"/>
|
48
|
+
<meta property="og:description" content="<%%= FACEBOOK_CONFIG[:opengraph]['description'] %%>"/>
|
49
|
+
<%% end %%>
|
50
|
+
<%%= render :partial => "shared/google_analytics" %%>
|
51
|
+
</head>
|
52
|
+
<body class="<%%= controller.controller_name %%> <%%= "#{controller.controller_name}-#{controller.action_name}" %%> <%%= content_for(:body_classes) %%>">
|
53
|
+
<%%= render :partial => "shared/facebook_init" %%>
|
54
|
+
<div id="container" class="container_24">
|
55
|
+
<%%= render :partial => "shared/header" %%>
|
56
|
+
|
57
|
+
<section id="main" class="grid_24 clearfix">
|
58
|
+
<%%= render :partial => "shared/flash_messages" %%>
|
59
|
+
<%% if content_for?(:complex_page_title) %%>
|
60
|
+
<%%= yield :complex_page_title %%>
|
61
|
+
<%% elsif content_for?(:page_title) %%>
|
62
|
+
<h1>
|
63
|
+
<%%= yield :page_title %%>
|
64
|
+
</h1>
|
65
|
+
<%% end %%>
|
66
|
+
<article class="<%%= content_for?(:article_classes) ? content_for(:article_classes) : 'grid_23 alpha omega' %%>">
|
67
|
+
<%%= yield %%>
|
68
|
+
</article>
|
69
|
+
<%%= yield :sidebar %%>
|
70
|
+
</section>
|
71
|
+
|
72
|
+
<%%= render :partial => "shared/footer" %%>
|
73
|
+
</div>
|
74
|
+
|
75
|
+
<%%= yield :bottom %%>
|
76
|
+
</body>
|
77
|
+
</html>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div id="fb-root"></div>
|
2
|
+
<script>
|
3
|
+
window.fbAsyncInit = function() {
|
4
|
+
FB.init({appId: '<%= FACEBOOK_CONFIG[:app_id] %>', status: true, cookie: true, xfbml: true});
|
5
|
+
};
|
6
|
+
(function() {
|
7
|
+
var e = document.createElement('script'); e.async = true;
|
8
|
+
e.src = document.location.protocol +
|
9
|
+
'//connect.facebook.net/en_US/all.js';
|
10
|
+
document.getElementById('fb-root').appendChild(e);
|
11
|
+
}());
|
12
|
+
</script>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<footer class="clearfix grid_24">
|
2
|
+
<small>
|
3
|
+
<%= t(:copyright) %> © <%= t(:company_name) %> <%= t(:all_rights_reserved)%>.
|
4
|
+
</small>
|
5
|
+
|
6
|
+
<nav>
|
7
|
+
<ul>
|
8
|
+
<li><%= link_to(t(:about_us) ,page_path(:about)) %> <span class="separator"> | </span></li>
|
9
|
+
<li><%= link_to(t(:contact_us) ,page_path(:contact)) %> <span class="separator"> | </span></li>
|
10
|
+
<li><%= link_to(t(:privacy_policy) ,page_path(:privacy)) %> <span class="separator"> | </span></li>
|
11
|
+
<li><%= link_to(t(:terms_of_service) ,page_path(:tos)) %></li>
|
12
|
+
</ul>
|
13
|
+
</nav>
|
14
|
+
|
15
|
+
</footer>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<script>
|
2
|
+
var _gaq = _gaq || [];
|
3
|
+
_gaq.push(['_setAccount', '<%= GOOGLE_ANALYTICS_CONFIG[:profile_id] %>']);
|
4
|
+
_gaq.push(['_trackPageview']);
|
5
|
+
|
6
|
+
(function() {
|
7
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
8
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
9
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
10
|
+
})();
|
11
|
+
</script>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<div class="spacer"></div>
|
2
|
+
<div class="spacer"></div>
|
3
|
+
<header class="clearfix grid_24">
|
4
|
+
<%= link_to("Home", root_url, :id => 'masthead', :class => 'ir') %>
|
5
|
+
|
6
|
+
<nav class="clearfix">
|
7
|
+
<ul>
|
8
|
+
<% if user_signed_in? %>
|
9
|
+
<li>Welcome <%= current_user.login %><span class="separator"></span></li>
|
10
|
+
<li><%= link_to t(:support), page_path('support') %><span class="separator"> | </span></li>
|
11
|
+
<li><%= link_to t(:profile), "" %><span class="separator"> | </span></li>
|
12
|
+
<li><%= link_to t(:settings), "" %><span class="separator"> | </span></li>
|
13
|
+
<li><%= link_to t(:sign_out), destroy_user_session_path %></li>
|
14
|
+
<% else %>
|
15
|
+
<li><%= link_to t(:about_us), page_path('about') %><span class="separator"> | </span></li>
|
16
|
+
<li><%= link_to t(:sign_in), new_user_session_path %><span class="separator"> | </span></li>
|
17
|
+
<li><%= link_to t(:contact_us), page_path('contact') %></li>
|
18
|
+
<% end %>
|
19
|
+
</ul>
|
20
|
+
</nav>
|
21
|
+
|
22
|
+
<%= link_to t(:consumer_app_teaser), page_path('consumer'), :class => "teaser" %>
|
23
|
+
</header>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
development:
|
2
|
+
appId: 6d3de4638a3339264d30c11f4bb9f173
|
3
|
+
admins:
|
4
|
+
- 2020864
|
5
|
+
opengraph:
|
6
|
+
title: Circle Street
|
7
|
+
type: company
|
8
|
+
url: http://dev.circlestreet.com
|
9
|
+
image: http://ia.media-imdb.com/rock.jpg
|
10
|
+
site_name: Circle Street
|
11
|
+
description: Promotions are the hottest content on the web. Circle Street's mission is to provide a better set of tools for merchants to easily publish promotions to larger and more targeted audiences. Circle Street's smart publishing platform allows merchants to powerfully and efficiently distribute their promotions
|
12
|
+
|
13
|
+
test:
|
14
|
+
appId: 6d3de4638a3339264d30c11f4bb9f173
|
15
|
+
admins:
|
16
|
+
- 2020864
|
17
|
+
opengraph:
|
18
|
+
title: Circle Street
|
19
|
+
type: company
|
20
|
+
url: http://dev.circlestreet.com
|
21
|
+
|
22
|
+
production:
|
23
|
+
appId: 6d3de4638a3339264d30c11f4bb9f173
|
24
|
+
admins:
|
25
|
+
- 2020864
|
26
|
+
opengraph:
|
27
|
+
title: Circle Street
|
28
|
+
type: company
|
29
|
+
url: http://dev.circlestreet.com
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module OmniAuth
|
2
|
+
module Strategies
|
3
|
+
#
|
4
|
+
# Authenticate to Flickr
|
5
|
+
#
|
6
|
+
# @example Basic Usage
|
7
|
+
#
|
8
|
+
# use OmniAuth::Strategies::Flickr, 'API Key', 'Secret Key', :scope => 'read'
|
9
|
+
class Flickr
|
10
|
+
include OmniAuth::Strategy
|
11
|
+
attr_accessor :api_key, :secret_key, :options
|
12
|
+
|
13
|
+
# error catching, based on OAuth2 callback
|
14
|
+
class CallbackError < StandardError
|
15
|
+
attr_accessor :error, :error_reason
|
16
|
+
def initialize(error, error_reason)
|
17
|
+
self.error = error
|
18
|
+
self.error_reason = error_reason
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# @param [Rack Application] app standard middleware application parameter
|
23
|
+
# @param [String] api_key the application id as [registered on Flickr](http://www.flickr.com/services/apps/)
|
24
|
+
# @param [String] secret_key the application secret as [registered on Flickr](http://www.flickr.com/services/apps/)
|
25
|
+
# @option options ['read','write','delete] :scope ('read') the scope of your authorization request; must be `read` or 'write' or 'delete'
|
26
|
+
def initialize(app, api_key, secret_key, options = {})
|
27
|
+
super(app, :flickr)
|
28
|
+
@api_key = api_key
|
29
|
+
@secret_key = secret_key
|
30
|
+
@options = {:scope => 'read'}.merge(options)
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def request_phase
|
36
|
+
params = { :api_key => api_key, :perms => options[:scope] }
|
37
|
+
params[:api_sig] = flickr_sign(params)
|
38
|
+
query_string = params.collect{ |key,value| "#{key}=#{Rack::Utils.escape(value)}" }.join('&')
|
39
|
+
redirect "http://flickr.com/services/auth/?#{query_string}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def callback_phase
|
43
|
+
params = { :api_key => api_key, :method => 'flickr.auth.getToken', :frob => request.params['frob'], :format => 'json', :nojsoncallback => '1' }
|
44
|
+
params[:api_sig] = flickr_sign(params)
|
45
|
+
|
46
|
+
response = RestClient.get('http://api.flickr.com/services/rest/', { :params => params })
|
47
|
+
auth = MultiJson.decode(response.to_s)
|
48
|
+
raise CallbackError.new(auth['code'],auth['message']) if auth['stat'] == 'fail'
|
49
|
+
|
50
|
+
@user = auth['auth']['user']
|
51
|
+
@access_token = auth['auth']['token']['_content']
|
52
|
+
|
53
|
+
super
|
54
|
+
rescue CallbackError => e
|
55
|
+
fail!(:invalid_response, e)
|
56
|
+
end
|
57
|
+
|
58
|
+
def auth_hash
|
59
|
+
OmniAuth::Utils.deep_merge(super, {
|
60
|
+
'uid' => @user['nsid'],
|
61
|
+
'credentials' => { 'token' => @access_token },
|
62
|
+
'user_info' => @user,
|
63
|
+
'extra' => { 'user_hash' => @user }
|
64
|
+
})
|
65
|
+
end
|
66
|
+
|
67
|
+
def flickr_sign(params)
|
68
|
+
Digest::MD5.hexdigest(secret_key + params.sort{|a,b| a[0].to_s <=> b[0].to_s }.flatten.join)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
module ProvidersConfig
|
76
|
+
end
|
77
|
+
|
78
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
79
|
+
PROVIDER_CONFIG = YAML.load_file("#{::Rails.root.to_s}/config/providers.yml")[::Rails.env]
|
80
|
+
for p in PROVIDER_CONFIG['providers']
|
81
|
+
if p['options']
|
82
|
+
provider p['name'], p['key'], p['secret'], :scope => p['options']
|
83
|
+
else
|
84
|
+
provider p['name'], p['key'], p['secret']
|
85
|
+
end
|
86
|
+
ProvidersConfig.const_set(p['name'].classify.upcase,{
|
87
|
+
:key => p['key'],
|
88
|
+
:secret => p['secret']
|
89
|
+
})
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
providers:
|
3
|
+
- name: twitter
|
4
|
+
key: qLDNyJWYR4uwgVlQ1Z3A
|
5
|
+
secret: EZlvNgye1feUDvF9Mn6XyNgYfILBEfIe17K5xKZyBs
|
6
|
+
- name: facebook
|
7
|
+
key: 180930071946269 #aka app_id
|
8
|
+
secret: bb7ba4d6aca52226489e1e1a18d8904c
|
9
|
+
options: 'email,offline_access,manage_pages'
|
10
|
+
- name: foursquare
|
11
|
+
key: DCHFL0OJXFAGNMFX4Q0LT0P55K4E4L41EOTKESLVJS5SC1GT
|
12
|
+
secret: 0ELT3AJYEXKEV1TEZSNRV4M4KDMUTDVUMMD5UJPM2QD1WK1B
|
13
|
+
- name: flickr
|
14
|
+
key: 598bcfd26c5091db5b68713f5126dc26
|
15
|
+
secret: 7cc1ace805d88475
|
16
|
+
- name: meetup
|
17
|
+
key: 776E306E6B28327449134646BBF89807
|
18
|
+
secret: 4CB887C5918F48F3ADE8E0E931F74B70
|
19
|
+
|
20
|
+
development:
|
21
|
+
<<: *defaults
|
22
|
+
|
23
|
+
test:
|
24
|
+
<<: *defaults
|
25
|
+
|
26
|
+
production:
|
27
|
+
<<: *defaults
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateAuthentications < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :authentications do |t|
|
4
|
+
t.references :authenticationable, :polymorphic => true
|
5
|
+
t.string :provider, :null => false, :limit => 64
|
6
|
+
t.string :uid, :null => false, :limit => 128
|
7
|
+
t.string :nickname, :limit => 64, :null => false
|
8
|
+
t.string :token, :limit => 128
|
9
|
+
t.string :secret, :limit => 128
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index :authentications, [:authenticationable_id, :authenticationable_type], :name => "index_authentications_on_a_id_a_type"
|
14
|
+
add_index :authentications, :provider
|
15
|
+
add_index :authentications, [:provider, :authenticationable_type, :uid], :name => "index_authentications_on_p_a_type_uid"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.down
|
19
|
+
drop_table :authentications
|
20
|
+
end
|
21
|
+
end
|