Created
April 26, 2012 15:40
-
-
Save cgallagher/2500457 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# application.rb | |
def user_is_safari_fucked? | |
BPLogger.debug(request.env['HTTP_USER_AGENT']) | |
request.env['HTTP_USER_AGENT'].match(/(AppleWebKit).+Version\/(5\.1\.[4-9])/) | |
end | |
def js_redirect_to(url, signed_request=nil) | |
if signed_request.nil? | |
render(:text => "<script>window.top.location = '#{url}';</script>", :content_type => 'text/html') and return | |
else | |
render(:text => "<script>window.top.location = '#{url}?app_data=#{signed_request.app_data}';</script>", :content_type => 'text/html') and return | |
end | |
end | |
###################################### | |
#tab_controller.rb | |
before_filter(:only => :landing) do |c| | |
BPLogger.debug(session[:fusafari]) | |
if c.user_is_safari_fucked? && !session[:fusafari] | |
c.js_redirect_to("http://#{Settings.host_url}/cookie_cookie_cookie", signed_request) | |
end | |
end | |
def cookie_cookie_cookie | |
session[:fusafari] = true | |
unless params[:app_data].nil? | |
js_redirect_to Settings.facebook.app_url + "&app_data=#{params[:app_data]}" | |
else | |
js_redirect_to Settings.facebook.app_url | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment