Module: Facebooker::Rails::Controller

Includes:
BackwardsCompatibleParamChecks, ProfilePublisherExtensions
Defined in:
lib/facebooker/rails/cucumber.rb,
lib/facebooker/rails/controller.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ProfilePublisherExtensions

#render_publisher_error, #render_publisher_interface, #render_publisher_response, #wants_interface?

Methods included from BackwardsCompatibleParamChecks

#one_or_true, #zero_or_false

Class Method Details

.included(controller) ⇒ Object



8
9
10
11
12
13
# File 'lib/facebooker/rails/controller.rb', line 8

def self.included(controller)
  controller.extend(ClassMethods)
  controller.before_filter :set_facebook_request_format
  controller.helper_attr :facebook_session_parameters
  controller.helper_method :request_comes_from_facebook?
end

Instance Method Details

#create_facebook_sessionObject



29
30
31
# File 'lib/facebooker/rails/controller.rb', line 29

def create_facebook_session
  secure_with_facebook_params! || secure_with_cookies! || secure_with_token!
end

#create_facebook_session_with_secretObject

this is used to proxy a connection through a rails app so the facebook secret key is not needed iphone apps use this



35
36
37
# File 'lib/facebooker/rails/controller.rb', line 35

def create_facebook_session_with_secret
  secure_with_session_secret!
end

#facebook_paramsObject



55
56
57
# File 'lib/facebooker/rails/controller.rb', line 55

def facebook_params
  @facebook_params ||= verified_facebook_params
end

#facebook_sessionObject



21
22
23
# File 'lib/facebooker/rails/controller.rb', line 21

def facebook_session
  @facebook_session
end

#facebook_session_parametersObject



25
26
27
# File 'lib/facebooker/rails/controller.rb', line 25

def facebook_session_parameters
  {:fb_sig_session_key=>params[:fb_sig_session_key]}
end

#initialize(*args) ⇒ Object



15
16
17
18
19
# File 'lib/facebooker/rails/controller.rb', line 15

def initialize *args
  @facebook_session       = nil
  @installation_required  = nil
  super
end

#redirect_to(*args) ⇒ Object

prevent Facebooker from rendering fb:redirect



18
19
20
# File 'lib/facebooker/rails/cucumber.rb', line 18

def redirect_to(*args)
  super
end

#set_facebook_sessionObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/facebooker/rails/controller.rb', line 39

def set_facebook_session
  # first, see if we already have a session
  session_set = session_already_secured?
  # if not, see if we can load it from the environment
  unless session_set
    session_set = create_facebook_session
    session[:facebook_session] = @facebook_session if session_set
  end
  if session_set
    capture_facebook_friends_if_available! 
    Session.current = facebook_session
  end
  return session_set
end

#top_redirect_to(*args) ⇒ Object

Redirects the top window to the given url if the content is in an iframe, otherwise performs a normal redirect_to call.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/facebooker/rails/controller.rb', line 61

def top_redirect_to(*args)
  if request_is_facebook_iframe?
    @redirect_url = url_for(*args)
    render :layout => false, :inline => <<-HTML
      <html><head>
        <script type="text/javascript">  
          window.top.location.href = <%= @redirect_url.to_json -%>;
        </script>
        <noscript>
          <meta http-equiv="refresh" content="0;url=<%=h @redirect_url %>" />
          <meta http-equiv="window-target" content="_top" />
        </noscript>                
      </head></html>
    HTML
  else
    redirect_to(*args)
  end
end