From 00352d5ecaf0f6e5a76ddaaf0ce460d7a479aed3 Mon Sep 17 00:00:00 2001 From: Matt Nguyen Date: Tue, 1 Oct 2013 21:50:17 -0700 Subject: [PATCH 01/13] Use js env vars Conflicts: app/views/layouts/application.html.haml --- .../controllers/playlist_new_ctrl.js.coffee | 2 +- app/assets/javascripts/services.js.coffee | 10 +++++----- app/views/layouts/application.html.haml | 12 +++++++++++- app/views/partials/_footer.html.haml | 4 ++-- config/environments/development.rb | 8 ++++++++ config/environments/production.rb | 12 ++++++++++-- 6 files changed, 37 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/controllers/playlist_new_ctrl.js.coffee b/app/assets/javascripts/controllers/playlist_new_ctrl.js.coffee index 6119488..6964cc5 100644 --- a/app/assets/javascripts/controllers/playlist_new_ctrl.js.coffee +++ b/app/assets/javascripts/controllers/playlist_new_ctrl.js.coffee @@ -45,7 +45,7 @@ ocarina.controller 'PlaylistNewCtrl', ['$rootScope', '$scope', '$location', 'Fac $location.path("/playlists/#{res.data.id}") $scope.currentUser.playlists.push(res.data) message = "I just created a playlist for this event on PlayedBy.me. Go to the site now or at the party to add songs you want to hear!" - link = "http://localhost:4400/playlists/#{res.data.id}" + link = "http://#{Playedbyme.env.domain}/playlists/#{res.data.id}" name = "#{fbEvent.name}'s playlist" # TODO uncomment this when we can prompt user to post # Facebook.postOnEvent(fbEvent.id, message, link, name) diff --git a/app/assets/javascripts/services.js.coffee b/app/assets/javascripts/services.js.coffee index f98647a..5eddc25 100644 --- a/app/assets/javascripts/services.js.coffee +++ b/app/assets/javascripts/services.js.coffee @@ -1,11 +1,11 @@ # API URL -@apiURL = "" +@apiURL = Playedbyme.env.apiURL ocarinaServices = angular.module('ocarinaServices', []) ocarinaServices.factory 'Pusher', -> if Pusher? - pusher = new Pusher("e9eb3f912d37215f7804") + pusher = new Pusher(Playedbyme.env.pusherKey) else # if pusher doesn't load subscribe: -> @@ -235,8 +235,8 @@ ocarinaServices.factory 'Player', ['Audio', (Audio) -> ] ocarinaServices.factory 'Facebook', ['$http', ($http) -> - api_url = "http://facebook.com" - app_id = '227387824081363' + api_url = "http://facebook.com" + app_id = Playedbyme.env.facebookAppId Facebook = (data) -> angular.extend(this, data) @@ -253,7 +253,7 @@ ocarinaServices.factory 'Facebook', ['$http', ($http) -> Facebook.sendDialog = (playlist_id) -> FB.ui method: "send" - link: "http://played-by-me.herokuapp.com/playlists/#{playlist_id}" + link: "http://#{Playedbyme.env.domain}/playlists/#{playlist_id}" Facebook.getUsersFavoriteArtists = (id, callback) -> FB.api "/#{id}/music", (res) -> diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 2323da9..585cb16 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -7,7 +7,17 @@ %title= content_for?(:title) ? yield(:title) : "Playedby.me" = stylesheet_link_tag "application", media: "all" = csrf_meta_tags + :javascript + var Playedbyme = { + env: { + apiURL: "#{Rails.configuration.api_url}", + domain: "#{Rails.configuration.domain}", + facebookAppId: "#{Rails.configuration.facebook_app_id}", + pusherKey: "#{Rails.configuration.pusher_key}" + } + }; + (function(d) { var id, js, ref; js = void 0; @@ -23,7 +33,6 @@ return ref.parentNode.insertBefore(js, ref); })(document); - %body.ng-cloak{ ng_controller: 'UserCtrl' } .logged-out{ ocarina_if: "!auth.loggedIn", ng_include:"'/partials/logged_out'" } .logged-in{ ocarina_if: "auth.loggedIn && currentUser.email" } @@ -37,6 +46,7 @@ = javascript_include_tag "http://js.pusher.com/2.1/pusher.min.js" = javascript_include_tag "http://connect.soundcloud.com/sdk.js" = javascript_include_tag "application" + :javascript SC.initialize({ client_id: "3d6e76640c62f42c02cb78d2c53d0db9" diff --git a/app/views/partials/_footer.html.haml b/app/views/partials/_footer.html.haml index 29f8f8a..2dc4eac 100644 --- a/app/views/partials/_footer.html.haml +++ b/app/views/partials/_footer.html.haml @@ -6,5 +6,5 @@ %a{ng_href: "", target: "_blank" } Our Blog %a{ng_href: "/contact" } Contact %a{ng_href: "/about" } About Us - %a.legal{ng_href: "//localhost:4400/partials/legal/tos", target: "_blank" } Terms - %a.legal{ng_href: "//localhost:4400/partials/legal/privacy", target: "_blank" } Privacy + %a.legal{ng_href: "//#{Rails.configuration.domain}/partials/legal/tos", target: "_blank" } Terms + %a.legal{ng_href: "//#{Rails.configuration.domain}/partials/legal/privacy", target: "_blank" } Privacy diff --git a/config/environments/development.rb b/config/environments/development.rb index 0b368ce..cc12fdb 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -32,9 +32,17 @@ config.smtp_password = ENV['SMTP_PASSWORD'] || 'jarpadarp' # API URLs + config.api_url = ENV['API_URL'] || 'http://localhost:4400' config.web_url = ENV['WEB_URL'] || 'http://localhost:4400' config.mobile_web_url = ENV['MOBILE_WEB_URL'] || 'http://localhost:8000' + # API ID/Secret Keys + config.facebook_app_id = ENV['FACEBOOK_APP_ID'] || raise_for('FACEBOOK_APP_ID') + config.pusher_key = ENV['PUSHER_KEY'] || raise_for('PUSHER_APP_ID') + + # Other + config.domain = ENV['DOMAIN'] || 'localhost:4400' + ## # CORS support config.middleware.insert_before "ActionDispatch::Static", "Rack::Cors", :debug => true, :logger => Rails.logger do diff --git a/config/environments/production.rb b/config/environments/production.rb index b777e2f..493d6ad 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -81,22 +81,30 @@ def raise_for(str) # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new - # + # Email Options config.smtp_user_name = ENV['SMTP_USER_NAME'] || raise_for('SMTP_USER_NAME') config.smtp_password = ENV['SMTP_PASSWORD'] || raise_for('SMTP_PASSWORD') # API URLs + config.api_url = ENV['API_URL'] || raise_for('API_URL') config.web_url = ENV['WEB_URL'] || raise_for('WEB_URL') config.mobile_web_url = ENV['MOBILE_WEB_URL'] || raise_for('MOBILE_WEB_URL') + # API ID/Secret Keys + config.facebook_app_id = ENV['FACEBOOK_APP_ID'] || raise_for('FACEBOOK_APP_ID') + config.pusher_key = ENV['PUSHER_KEY'] || raise_for('PUSHER_APP_ID') + + # Other + config.domain = ENV['DOMAIN'] || raise_for('DOMAIN') + ## # CORS support config.middleware.insert_before "ActionDispatch::Static", "Rack::Cors" do allow do origins Rails.configuration.mobile_web_url - resource '/api/*', + resource '/api/*', headers: :any, methods: [:get, :post] end From 8c49f0ad00f0c9d12743a9dc6fe5649df3477dec Mon Sep 17 00:00:00 2001 From: Matt Nguyen Date: Sun, 13 Oct 2013 09:38:04 -0700 Subject: [PATCH 02/13] Accept api responses for requests made from subdomain --- config/environments/development.rb | 2 +- config/environments/production.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index cc12fdb..d6e5f4b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -47,7 +47,7 @@ # CORS support config.middleware.insert_before "ActionDispatch::Static", "Rack::Cors", :debug => true, :logger => Rails.logger do allow do - origins Rails.configuration.mobile_web_url + origins Rails.configuration.mobile_web_url, Rails.configuration.api_url resource '/api/*', headers: :any, diff --git a/config/environments/production.rb b/config/environments/production.rb index 493d6ad..b600c43 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -102,7 +102,7 @@ def raise_for(str) # CORS support config.middleware.insert_before "ActionDispatch::Static", "Rack::Cors" do allow do - origins Rails.configuration.mobile_web_url + origins Rails.configuration.mobile_web_url, /http:\/\/((yc|techstars).)?playedby.me/ resource '/api/*', headers: :any, From ae28e71514300775be5bc12615ae4a98368c31be Mon Sep 17 00:00:00 2001 From: Matt Nguyen Date: Sun, 13 Oct 2013 09:56:49 -0700 Subject: [PATCH 03/13] Replace url and fb id with env vars --- app/assets/javascripts/services.js.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/services.js.coffee b/app/assets/javascripts/services.js.coffee index 5eddc25..3ff4577 100644 --- a/app/assets/javascripts/services.js.coffee +++ b/app/assets/javascripts/services.js.coffee @@ -62,8 +62,8 @@ ocarinaServices.factory 'Authentication', ['$http', ($http) -> window.fbAsyncInit = -> FB.init - appId: "160916744087752" - channelUrl: "//localhost:4400/channel.html" + appId: "#{Playedbyme.env.facebookAppId}" + channelUrl: "//#{Playedbyme.env.domain}/channel.html" status: true # check login status cookie: true # enable cookies to allow the server to access the session xfbml: true # parse XFBML @@ -82,7 +82,7 @@ ocarinaServices.factory 'Authentication', ['$http', ($http) -> access_token: auth.accessToken $.get "#{apiURL}/api/users/authenticate.json", authParams, (data) -> Authentication.setCookie("user_id", data.id, 1) - window.location.replace "http://localhost:4400?user_id=#{data.id}" + window.location.replace "http://#{Playedbyme.env.domain}?user_id=#{data.id}" else if res.status is "not_authorized" # if user logged in but hasn't authed app else From 1ad40fbf5f57c45ad6aac4dcd468a94000adcc4d Mon Sep 17 00:00:00 2001 From: Matt Nguyen Date: Tue, 1 Oct 2013 21:50:17 -0700 Subject: [PATCH 04/13] Use js env vars Conflicts: app/views/layouts/application.html.haml --- app/assets/javascripts/services.js.coffee | 38 +++-------------------- app/views/layouts/application.html.haml | 12 ++++++- config/environments/development.rb | 8 +++++ config/environments/production.rb | 12 +++++-- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/app/assets/javascripts/services.js.coffee b/app/assets/javascripts/services.js.coffee index f98647a..0d899fc 100644 --- a/app/assets/javascripts/services.js.coffee +++ b/app/assets/javascripts/services.js.coffee @@ -1,11 +1,11 @@ # API URL -@apiURL = "" +@apiURL = Playedbyme.env.apiURL ocarinaServices = angular.module('ocarinaServices', []) ocarinaServices.factory 'Pusher', -> if Pusher? - pusher = new Pusher("e9eb3f912d37215f7804") + pusher = new Pusher(Playedbyme.env.pusherKey) else # if pusher doesn't load subscribe: -> @@ -60,34 +60,6 @@ ocarinaServices.factory 'Authentication', ['$http', ($http) -> Authentication.deferDropbox = (user_id) -> $http.post "/defer_dropbox_connect", user_id: user_id - window.fbAsyncInit = -> - FB.init - appId: "160916744087752" - channelUrl: "//localhost:4400/channel.html" - status: true # check login status - cookie: true # enable cookies to allow the server to access the session - xfbml: true # parse XFBML - - FB.Event.subscribe "auth.authResponseChange", (res) -> - if res.status is "connected" - return if Authentication.getCookie("user_id") - auth = res.authResponse - FB.api '/me?fields=picture,first_name,last_name,email', (res) -> - authParams = - id: res.id - first_name: res.first_name - last_name: res.last_name - email: res.email - image: res.picture.data.url - access_token: auth.accessToken - $.get "#{apiURL}/api/users/authenticate.json", authParams, (data) -> - Authentication.setCookie("user_id", data.id, 1) - window.location.replace "http://localhost:4400?user_id=#{data.id}" - else if res.status is "not_authorized" - # if user logged in but hasn't authed app - else - # if user logged out - Authentication ] @@ -235,8 +207,8 @@ ocarinaServices.factory 'Player', ['Audio', (Audio) -> ] ocarinaServices.factory 'Facebook', ['$http', ($http) -> - api_url = "http://facebook.com" - app_id = '227387824081363' + api_url = "http://facebook.com" + app_id = Playedbyme.env.facebookAppId Facebook = (data) -> angular.extend(this, data) @@ -253,7 +225,7 @@ ocarinaServices.factory 'Facebook', ['$http', ($http) -> Facebook.sendDialog = (playlist_id) -> FB.ui method: "send" - link: "http://played-by-me.herokuapp.com/playlists/#{playlist_id}" + link: "http://#{Playedbyme.env.domain}/playlists/#{playlist_id}" Facebook.getUsersFavoriteArtists = (id, callback) -> FB.api "/#{id}/music", (res) -> diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 2323da9..585cb16 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -7,7 +7,17 @@ %title= content_for?(:title) ? yield(:title) : "Playedby.me" = stylesheet_link_tag "application", media: "all" = csrf_meta_tags + :javascript + var Playedbyme = { + env: { + apiURL: "#{Rails.configuration.api_url}", + domain: "#{Rails.configuration.domain}", + facebookAppId: "#{Rails.configuration.facebook_app_id}", + pusherKey: "#{Rails.configuration.pusher_key}" + } + }; + (function(d) { var id, js, ref; js = void 0; @@ -23,7 +33,6 @@ return ref.parentNode.insertBefore(js, ref); })(document); - %body.ng-cloak{ ng_controller: 'UserCtrl' } .logged-out{ ocarina_if: "!auth.loggedIn", ng_include:"'/partials/logged_out'" } .logged-in{ ocarina_if: "auth.loggedIn && currentUser.email" } @@ -37,6 +46,7 @@ = javascript_include_tag "http://js.pusher.com/2.1/pusher.min.js" = javascript_include_tag "http://connect.soundcloud.com/sdk.js" = javascript_include_tag "application" + :javascript SC.initialize({ client_id: "3d6e76640c62f42c02cb78d2c53d0db9" diff --git a/config/environments/development.rb b/config/environments/development.rb index 0b368ce..cc12fdb 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -32,9 +32,17 @@ config.smtp_password = ENV['SMTP_PASSWORD'] || 'jarpadarp' # API URLs + config.api_url = ENV['API_URL'] || 'http://localhost:4400' config.web_url = ENV['WEB_URL'] || 'http://localhost:4400' config.mobile_web_url = ENV['MOBILE_WEB_URL'] || 'http://localhost:8000' + # API ID/Secret Keys + config.facebook_app_id = ENV['FACEBOOK_APP_ID'] || raise_for('FACEBOOK_APP_ID') + config.pusher_key = ENV['PUSHER_KEY'] || raise_for('PUSHER_APP_ID') + + # Other + config.domain = ENV['DOMAIN'] || 'localhost:4400' + ## # CORS support config.middleware.insert_before "ActionDispatch::Static", "Rack::Cors", :debug => true, :logger => Rails.logger do diff --git a/config/environments/production.rb b/config/environments/production.rb index b777e2f..493d6ad 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -81,22 +81,30 @@ def raise_for(str) # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new - # + # Email Options config.smtp_user_name = ENV['SMTP_USER_NAME'] || raise_for('SMTP_USER_NAME') config.smtp_password = ENV['SMTP_PASSWORD'] || raise_for('SMTP_PASSWORD') # API URLs + config.api_url = ENV['API_URL'] || raise_for('API_URL') config.web_url = ENV['WEB_URL'] || raise_for('WEB_URL') config.mobile_web_url = ENV['MOBILE_WEB_URL'] || raise_for('MOBILE_WEB_URL') + # API ID/Secret Keys + config.facebook_app_id = ENV['FACEBOOK_APP_ID'] || raise_for('FACEBOOK_APP_ID') + config.pusher_key = ENV['PUSHER_KEY'] || raise_for('PUSHER_APP_ID') + + # Other + config.domain = ENV['DOMAIN'] || raise_for('DOMAIN') + ## # CORS support config.middleware.insert_before "ActionDispatch::Static", "Rack::Cors" do allow do origins Rails.configuration.mobile_web_url - resource '/api/*', + resource '/api/*', headers: :any, methods: [:get, :post] end From b90dc5feaa66c1316210b0ec86fa265f394d7c80 Mon Sep 17 00:00:00 2001 From: Matt Nguyen Date: Tue, 1 Oct 2013 21:50:17 -0700 Subject: [PATCH 05/13] Use js env vars Conflicts: app/views/layouts/application.html.haml --- .../javascripts/controllers/playlist_new_ctrl.js.coffee | 2 +- app/views/partials/_footer.html.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/controllers/playlist_new_ctrl.js.coffee b/app/assets/javascripts/controllers/playlist_new_ctrl.js.coffee index 6119488..6964cc5 100644 --- a/app/assets/javascripts/controllers/playlist_new_ctrl.js.coffee +++ b/app/assets/javascripts/controllers/playlist_new_ctrl.js.coffee @@ -45,7 +45,7 @@ ocarina.controller 'PlaylistNewCtrl', ['$rootScope', '$scope', '$location', 'Fac $location.path("/playlists/#{res.data.id}") $scope.currentUser.playlists.push(res.data) message = "I just created a playlist for this event on PlayedBy.me. Go to the site now or at the party to add songs you want to hear!" - link = "http://localhost:4400/playlists/#{res.data.id}" + link = "http://#{Playedbyme.env.domain}/playlists/#{res.data.id}" name = "#{fbEvent.name}'s playlist" # TODO uncomment this when we can prompt user to post # Facebook.postOnEvent(fbEvent.id, message, link, name) diff --git a/app/views/partials/_footer.html.haml b/app/views/partials/_footer.html.haml index 29f8f8a..2dc4eac 100644 --- a/app/views/partials/_footer.html.haml +++ b/app/views/partials/_footer.html.haml @@ -6,5 +6,5 @@ %a{ng_href: "", target: "_blank" } Our Blog %a{ng_href: "/contact" } Contact %a{ng_href: "/about" } About Us - %a.legal{ng_href: "//localhost:4400/partials/legal/tos", target: "_blank" } Terms - %a.legal{ng_href: "//localhost:4400/partials/legal/privacy", target: "_blank" } Privacy + %a.legal{ng_href: "//#{Rails.configuration.domain}/partials/legal/tos", target: "_blank" } Terms + %a.legal{ng_href: "//#{Rails.configuration.domain}/partials/legal/privacy", target: "_blank" } Privacy From 4aba87e736715029b5c0d45cbdf112e00a1a9064 Mon Sep 17 00:00:00 2001 From: Matt Nguyen Date: Sun, 13 Oct 2013 09:38:04 -0700 Subject: [PATCH 06/13] Accept api responses for requests made from subdomain --- config/environments/development.rb | 2 +- config/environments/production.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index cc12fdb..d6e5f4b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -47,7 +47,7 @@ # CORS support config.middleware.insert_before "ActionDispatch::Static", "Rack::Cors", :debug => true, :logger => Rails.logger do allow do - origins Rails.configuration.mobile_web_url + origins Rails.configuration.mobile_web_url, Rails.configuration.api_url resource '/api/*', headers: :any, diff --git a/config/environments/production.rb b/config/environments/production.rb index 493d6ad..b600c43 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -102,7 +102,7 @@ def raise_for(str) # CORS support config.middleware.insert_before "ActionDispatch::Static", "Rack::Cors" do allow do - origins Rails.configuration.mobile_web_url + origins Rails.configuration.mobile_web_url, /http:\/\/((yc|techstars).)?playedby.me/ resource '/api/*', headers: :any, From 29859886c055d7c660678088990ba7bcd3557493 Mon Sep 17 00:00:00 2001 From: Basil Siddiqui Date: Sun, 13 Oct 2013 15:18:11 -0400 Subject: [PATCH 07/13] refactored to make fb login work --- app/assets/javascripts/application.js.coffee | 1 + app/assets/javascripts/facebook.js.coffee | 49 +++++++++++++++++++- app/views/layouts/application.html.haml | 15 ------ 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index 2c5dcae..52c247e 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -1,3 +1,4 @@ +#= require facebook #= require jquery #= require twitter/bootstrap #= require angular diff --git a/app/assets/javascripts/facebook.js.coffee b/app/assets/javascripts/facebook.js.coffee index 7d44135..eef68fa 100644 --- a/app/assets/javascripts/facebook.js.coffee +++ b/app/assets/javascripts/facebook.js.coffee @@ -1,3 +1,50 @@ +setCookie = (c_name, value, exdays) -> + exdate = new Date() + exdate.setDate exdate.getDate() + exdays + c_value = escape(value) + ((if (not (exdays?)) then "" else "; expires=" + exdate.toUTCString())) + document.cookie = c_name + "=" + c_value + +getCookie = (c_name) -> + c_value = document.cookie + c_start = c_value.indexOf(" " + c_name + "=") + c_start = c_value.indexOf(c_name + "=") if c_start is -1 + if c_start is -1 + c_value = null + else + c_start = c_value.indexOf("=", c_start) + 1 + c_end = c_value.indexOf(";", c_start) + c_end = c_value.length if c_end is -1 + c_value = unescape(c_value.substring(c_start, c_end)) + c_value + +window.fbAsyncInit = -> + FB.init + appId: "#{Playedbyme.env.facebookAppId}" + channelUrl: "//#{Playedbyme.env.domain}/channel.html" + status: true # check login status + cookie: true # enable cookies to allow the server to access the session + xfbml: true # parse XFBML + + FB.Event.subscribe "auth.authResponseChange", (res) -> + if res.status is "connected" + return if getCookie("user_id") + auth = res.authResponse + FB.api '/me?fields=picture,first_name,last_name,email', (res) -> + authParams = + id: res.id + first_name: res.first_name + last_name: res.last_name + email: res.email + image: res.picture.data.url + access_token: auth.accessToken + $.get "#{apiURL}/api/users/authenticate.json", authParams, (data) -> + setCookie("user_id", data.id, 1) + window.location.replace "http://#{Playedbyme.env.domain}?user_id=#{data.id}" + else if res.status is "not_authorized" + # if user logged in but hasn't authed app + else + # if user logged out + # load the SDK asynchronously ((d) -> js = undefined @@ -9,4 +56,4 @@ js.async = true js.src = "//connect.facebook.net/en_US/all.js" ref.parentNode.insertBefore js, ref -) document +) document, false diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 585cb16..63a5db7 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -18,21 +18,6 @@ } }; - (function(d) { - var id, js, ref; - js = void 0; - id = "facebook-jssdk"; - ref = d.getElementsByTagName("script")[0]; - if (d.getElementById(id)) { - return; - } - js = d.createElement("script"); - js.id = id; - js.async = true; - js.src = "//connect.facebook.net/en_US/all.js"; - return ref.parentNode.insertBefore(js, ref); - })(document); - %body.ng-cloak{ ng_controller: 'UserCtrl' } .logged-out{ ocarina_if: "!auth.loggedIn", ng_include:"'/partials/logged_out'" } .logged-in{ ocarina_if: "auth.loggedIn && currentUser.email" } From 718550cee32536c558355202fa0cb830804aa8f6 Mon Sep 17 00:00:00 2001 From: Basil Siddiqui Date: Sun, 13 Oct 2013 15:24:38 -0400 Subject: [PATCH 08/13] log initialize --- app/assets/javascripts/facebook.js.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/facebook.js.coffee b/app/assets/javascripts/facebook.js.coffee index eef68fa..0930be0 100644 --- a/app/assets/javascripts/facebook.js.coffee +++ b/app/assets/javascripts/facebook.js.coffee @@ -18,6 +18,7 @@ getCookie = (c_name) -> c_value window.fbAsyncInit = -> + console.log "app initialized" FB.init appId: "#{Playedbyme.env.facebookAppId}" channelUrl: "//#{Playedbyme.env.domain}/channel.html" From 4f8755ee20480630476f5266a3bd9c523d1799a4 Mon Sep 17 00:00:00 2001 From: Basil Siddiqui Date: Sun, 13 Oct 2013 15:39:03 -0400 Subject: [PATCH 09/13] hardcode fbid --- app/views/layouts/application.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 63a5db7..653a09b 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -13,7 +13,7 @@ env: { apiURL: "#{Rails.configuration.api_url}", domain: "#{Rails.configuration.domain}", - facebookAppId: "#{Rails.configuration.facebook_app_id}", + facebookAppId: "227387824081363", pusherKey: "#{Rails.configuration.pusher_key}" } }; From f962eb27bc4821a3aae4ecfe14dd0af146ac12a1 Mon Sep 17 00:00:00 2001 From: Matt Nguyen Date: Sun, 13 Oct 2013 13:00:46 -0700 Subject: [PATCH 10/13] Hardcode origin urls for CORS --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index b600c43..fd9965b 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -102,7 +102,7 @@ def raise_for(str) # CORS support config.middleware.insert_before "ActionDispatch::Static", "Rack::Cors" do allow do - origins Rails.configuration.mobile_web_url, /http:\/\/((yc|techstars).)?playedby.me/ + origins Rails.configuration.mobile_web_url, "http://techstars.playedby.me", "http://yc.playedby.me" resource '/api/*', headers: :any, From 7f326db22589bd35d3748a21fe9c8e6d1015eed4 Mon Sep 17 00:00:00 2001 From: Basil Siddiqui Date: Sun, 13 Oct 2013 16:21:13 -0400 Subject: [PATCH 11/13] change app id --- app/views/layouts/application.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 653a09b..5ecbcc1 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -13,7 +13,7 @@ env: { apiURL: "#{Rails.configuration.api_url}", domain: "#{Rails.configuration.domain}", - facebookAppId: "227387824081363", + facebookAppId: "160916744087752", pusherKey: "#{Rails.configuration.pusher_key}" } }; From cb9dabf725c3d9316e4ee0aefe135c91811fe190 Mon Sep 17 00:00:00 2001 From: Basil Siddiqui Date: Sun, 13 Oct 2013 16:27:47 -0400 Subject: [PATCH 12/13] changed some vars --- app/views/layouts/application.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 5ecbcc1..c149ca1 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -11,8 +11,8 @@ :javascript var Playedbyme = { env: { - apiURL: "#{Rails.configuration.api_url}", - domain: "#{Rails.configuration.domain}", + apiURL: "", + domain: "techstars.playedby.me", facebookAppId: "160916744087752", pusherKey: "#{Rails.configuration.pusher_key}" } From bc155b193c8adc07b90951df4a3c85a41cfc5ae9 Mon Sep 17 00:00:00 2001 From: Basil Siddiqui Date: Mon, 14 Oct 2013 00:45:11 -0400 Subject: [PATCH 13/13] dynamic domain --- app/assets/javascripts/facebook.js.coffee | 2 +- app/views/layouts/application.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/facebook.js.coffee b/app/assets/javascripts/facebook.js.coffee index 0930be0..7f03fe8 100644 --- a/app/assets/javascripts/facebook.js.coffee +++ b/app/assets/javascripts/facebook.js.coffee @@ -40,7 +40,7 @@ window.fbAsyncInit = -> access_token: auth.accessToken $.get "#{apiURL}/api/users/authenticate.json", authParams, (data) -> setCookie("user_id", data.id, 1) - window.location.replace "http://#{Playedbyme.env.domain}?user_id=#{data.id}" + window.location.replace "#{Playedbyme.env.domain}?user_id=#{data.id}" else if res.status is "not_authorized" # if user logged in but hasn't authed app else diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index c149ca1..04530ce 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -12,7 +12,7 @@ var Playedbyme = { env: { apiURL: "", - domain: "techstars.playedby.me", + domain: window.location.origin, facebookAppId: "160916744087752", pusherKey: "#{Rails.configuration.pusher_key}" }