rfacebook 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -160,7 +160,7 @@ module RFacebook
160
160
  # handle invalidation
161
161
  if (timeout and (sigParams["time"].nil? or (Time.now.to_i - sigParams["time"].to_i > timeout.to_i)))
162
162
  # invalidate if the timeout has been reached
163
- @logger.debug "** RFACEBOOK(GEM) - fbparams is empty because the signature was timed out" if @logger
163
+ #@logger.debug "** RFACEBOOK(GEM) - fbparams is empty because the signature was timed out" if @logger
164
164
  sigParams = {}
165
165
  end
166
166
 
@@ -168,7 +168,7 @@ module RFacebook
168
168
  expectedSig = originalParams["fb_sig"]
169
169
  if !(sigParams and expectedSig and generate_signature(sigParams, @api_secret) == expectedSig)
170
170
  # didn't match, empty out the params
171
- @logger.debug "** RFACEBOOK(GEM) - fbparams is empty because the signature did not match" if @logger
171
+ #@logger.debug "** RFACEBOOK(GEM) - fbparams is empty because the signature did not match" if @logger
172
172
  sigParams = {}
173
173
  end
174
174
 
@@ -86,6 +86,12 @@ module RFacebook
86
86
  dup_cookies = (self.cookies || {}).dup
87
87
  @fbparams = rfacebook_session_holder.get_fb_sig_params(dup_cookies)
88
88
  end
89
+
90
+ # finally, if we are an iframe app we may have saved the fbparams
91
+ # to the session for safekeeping
92
+ if (!@fbparams || @fbparams.length <= 0)
93
+ @fbparams = session[:rfacebook_session_iframe_fbparams] || {}
94
+ end
89
95
 
90
96
  return @fbparams
91
97
 
@@ -138,25 +144,28 @@ module RFacebook
138
144
  end
139
145
 
140
146
  def in_facebook_canvas?
141
- return (params["fb_sig_in_canvas"] != nil)# and params["fb_sig_in_canvas"] == "1")
147
+ in_canvas = params["fb_sig_in_canvas"] || fbparams["in_canvas"]
148
+ return (in_canvas == "1" || in_canvas == true)
142
149
  end
143
150
 
144
151
  def in_facebook_frame?
145
- return (params["fb_sig_in_iframe"] != nil)# and params["fb_sig_in_iframe"] == "1")
152
+ in_iframe = params["fb_sig_in_iframe"] || fbparams["in_iframe"]
153
+ return (in_iframe == "1" || in_iframe == true)
146
154
  end
147
155
 
148
156
  def in_mock_ajax?
149
- return (params["fb_mockajax_url"] != nil)
157
+ return (params["fb_mockajax_url"] == "1" || params["fb_mockajax_url"] == true)
150
158
  end
151
159
 
152
160
  def in_external_app?
153
161
  # FIXME: once you click away in an iframe app, you are considered to be an external app
154
- # TODO: read up on the RFacebook hacks for avoiding nested iframes
162
+ # TODO: read up on the hacks for avoiding nested iframes
155
163
  return (params["fb_sig"] == nil and !in_facebook_frame?)
156
164
  end
157
165
 
158
166
  def added_facebook_application?
159
- return (params["fb_sig_added"] != nil)# and params["fb_sig_in_iframe"] == "1")
167
+ addedApp = params["fb_sig_added"] || fbparams["added"]
168
+ return (addedApp == "1" || addedApp == true)
160
169
  end
161
170
 
162
171
  def facebook_platform_signature_verified?
@@ -365,6 +374,10 @@ module RFacebook
365
374
  RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: persisting Facebook session information into Rails session"
366
375
  session[:rfacebook_session] = @rfacebook_session_holder.dup
367
376
  session[:rfacebook_session].logger = nil # some session stores can't serialize the Rails logger
377
+ if in_facebook_frame?
378
+ # we need iframe apps to remember they are iframe apps
379
+ session[:rfacebook_session_iframe_fbparams] = fbparams
380
+ end
368
381
  end
369
382
  end
370
383
 
@@ -376,10 +389,13 @@ module RFacebook
376
389
 
377
390
  def url_for__RFACEBOOK(options={}, *parameters) # :nodoc:
378
391
 
379
- # error check
380
- if !options
381
- RAILS_DEFAULT_LOGGER.info "** RFACEBOOK WARNING: options cannot be nil in call to url_for"
382
- end
392
+ # fix problems that some Rails installations had with sending nil options
393
+ options ||= {}
394
+
395
+ # # error check
396
+ # if !options
397
+ # RAILS_DEFAULT_LOGGER.info "** RFACEBOOK WARNING: options cannot be nil in call to url_for"
398
+ # end
383
399
 
384
400
  # use special URL rewriting when inside the canvas
385
401
  # setting the mock_ajax option to true will override this
@@ -392,7 +408,7 @@ module RFacebook
392
408
  if (in_facebook_canvas? and !mockajaxSpecified) #TODO: do something separate for in_facebook_frame?
393
409
 
394
410
  if options.is_a? Hash
395
- options[:only_path] = true
411
+ options[:only_path] = true if options[:only_path].nil?
396
412
  end
397
413
 
398
414
  # try to get a regular URL
@@ -400,9 +416,12 @@ module RFacebook
400
416
 
401
417
  # replace anything that references the callback with the
402
418
  # Facebook canvas equivalent (apps.facebook.com/*)
403
- if (path.starts_with?(self.facebook_callback_path) or "#{path}/".starts_with?(self.facebook_callback_path))
419
+ if path.starts_with?(self.facebook_callback_path)
404
420
  path.sub!(self.facebook_callback_path, self.facebook_canvas_path)
405
421
  path = "http://apps.facebook.com#{path}"
422
+ elsif "#{path}/".starts_with?(self.facebook_callback_path)
423
+ path.sub!(self.facebook_callback_path.chop, self.facebook_canvas_path.chop)
424
+ path = "http://apps.facebook.com#{path}"
406
425
  elsif (path.starts_with?("http://www.facebook.com") or path.starts_with?("https://www.facebook.com"))
407
426
  # be sure that URLs that go to some other Facebook service redirect back to the canvas
408
427
  if path.include?("?")
@@ -147,6 +147,8 @@ module RFacebook
147
147
  ######################
148
148
  module InstanceMethods
149
149
 
150
+ # TODO: to help developers stay within the TOS, we should have a method in here like "with_facebook_scope(fbsession){...}"
151
+
150
152
  def facebook_session
151
153
  if !@facebook_session
152
154
  @facebook_session = FacebookWebSession.new(self.facebook_api_key, self.facebook_api_secret)
@@ -36,6 +36,7 @@ module RFacebook::Rails::Plugin
36
36
 
37
37
  module ControllerExtensions
38
38
  def facebook_api_key
39
+ # TODO: pull these overrides up into the original module, and make a FACEBOOK global in the backwards-compatibility file
39
40
  FACEBOOK["key"] || super
40
41
  end
41
42
  def facebook_api_secret
@@ -53,7 +53,7 @@ module RFacebook
53
53
 
54
54
  def image_path(*params)
55
55
  path = super(*params)
56
- if (in_facebook_canvas? or in_mock_ajax?)
56
+ if ((in_facebook_canvas? or in_mock_ajax?) and !(/(\w+)(\:\/\/)([\w0-9\.]+)([\:0-9]*)(.*)/.match(path)))
57
57
  path = "#{request.protocol}#{request.host_with_port}#{path}"
58
58
  end
59
59
  return path
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.1
3
3
  specification_version: 1
4
4
  name: rfacebook
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.9.2
7
- date: 2007-08-27 00:00:00 -04:00
6
+ version: 0.9.3
7
+ date: 2007-09-03 00:00:00 -04:00
8
8
  summary: A Ruby interface to the Facebook API v1.0+. Works with RFacebook on Rails plugin (see http://rfacebook.rubyforge.org).
9
9
  require_paths:
10
10
  - lib