rfacebook 0.9.6 → 0.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -105,6 +105,11 @@ module RFacebook
105
105
  # A FacebookWebSession. You may want to check is_valid? before using it.
106
106
  def fbsession
107
107
 
108
+ # do a check to ensure that we nil out the rfacebook_session in case there is a new user visiting
109
+ if session[:rfacebook_session] and fbparams["session_key"] and session[:rfacebook_session].session_key != fbparams["session_key"]
110
+ session[:rfacebook_session] = nil
111
+ end
112
+
108
113
  # if we are in the canvas, iframe, or mock ajax, we should be able to activate the session here
109
114
  if (!rfacebook_session_holder.is_valid? and (in_facebook_canvas? or in_facebook_frame? or in_mock_ajax?))
110
115
 
@@ -169,6 +174,11 @@ module RFacebook
169
174
  return (is_mockajax == "1" || is_mockajax == true || params["fb_mockajax_url"] != nil)
170
175
  end
171
176
 
177
+ def in_ajax?
178
+ is_ajax = params["fb_sig_is_ajax"]
179
+ return (is_ajax == "1" || is_ajax == true)
180
+ end
181
+
172
182
  def in_external_app?
173
183
  # FIXME: once you click away in an iframe app, you are considered to be an external app
174
184
  # TODO: read up on the hacks for avoiding nested iframes
@@ -280,6 +290,13 @@ module RFacebook
280
290
  return true
281
291
  end
282
292
 
293
+ # TODO: check this out
294
+ # def require_facebook_install
295
+ # if in_facebook_frame? and not added_facebook_application?
296
+ # render :text => %Q(<script language="javascript">top.location.href="#{fbsession.get_install_url}&next=#{request.path.gsub(/#{facebook_callback_path}/, "")}"</script>)
297
+ # end
298
+ # end
299
+
283
300
  ################################################################################################
284
301
  ################################################################################################
285
302
  # :section: Facebook Debug Panel
@@ -299,6 +316,7 @@ module RFacebook
299
316
  return ERB.new(template).result(Proc.new{})
300
317
  end
301
318
 
319
+ # TODO: implement this in version 1.0
302
320
  # def rescue_action(exception)
303
321
  # # TODO: for security, we only do this in development in the canvas
304
322
  # if (in_facebook_canvas? and RAILS_ENV == "development")
@@ -393,21 +411,19 @@ module RFacebook
393
411
 
394
412
  # fix problems that some Rails installations had with sending nil options
395
413
  options ||= {}
396
-
397
- # # error check
398
- # if !options
399
- # RAILS_DEFAULT_LOGGER.info "** RFACEBOOK WARNING: options cannot be nil in call to url_for"
400
- # end
401
-
414
+
402
415
  # use special URL rewriting when inside the canvas
403
- # setting the mock_ajax option to true will override this
404
- # and force usage of regular Rails rewriting
405
- mockajaxSpecified = false
416
+ # setting the full_callback option to true will override this
417
+ # and force usage of regular Rails rewriting
406
418
  if options.is_a? Hash
407
- mockajaxSpecified = options[:mock_ajax]
419
+ if options[:mock_ajax]
420
+ RAILS_DEFAULT_LOGGER.info "** RFACEBOOK DEPRECATION WARNING: don't use :mock_ajax => true in your link_to anymore. Instead, use :full_callback => true."
421
+ end
422
+ fullCallback = (options[:full_callback] == true) ? true : false
423
+ options.delete(:full_callback)
408
424
  end
409
425
 
410
- if (in_facebook_canvas? and !mockajaxSpecified) #TODO: do something separate for in_facebook_frame?
426
+ if ((in_facebook_canvas? or in_mock_ajax? or in_ajax?) and !fullCallback) #TODO: do something separate for in_facebook_frame?
411
427
 
412
428
  if options.is_a? Hash
413
429
  options[:only_path] = true if options[:only_path].nil?
@@ -437,9 +453,8 @@ module RFacebook
437
453
  path = "#{request.protocol}#{request.host}:#{request.port}#{path}"
438
454
  end
439
455
 
440
- # mock-ajax rewriting
441
- elsif mockajaxSpecified
442
- options.delete(:mock_ajax) # clear it so it doesnt show up in the url
456
+ # full callback rewriting
457
+ elsif fullCallback
443
458
  options[:only_path] = true
444
459
  path = "#{request.protocol}#{request.host}:#{request.port}#{url_for__ALIASED(options, *parameters)}"
445
460
 
@@ -452,12 +467,22 @@ module RFacebook
452
467
  end
453
468
 
454
469
  def redirect_to__RFACEBOOK(options = {}, *parameters) # :nodoc:
470
+
471
+ # get the url
472
+ redirectUrl = url_for(options, *parameters)
473
+
474
+ # canvas redirect
455
475
  if in_facebook_canvas?
476
+
477
+ RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: Canvas redirect to #{redirectUrl}"
478
+ render :text => "<fb:redirect url=\"#{redirectUrl}\" />"
479
+
480
+ # iframe redirect
481
+ elsif redirectUrl.match(/^https?:\/\/([^\/]*\.)?facebook\.com(:\d+)?/i)
482
+ RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: iframe redirect to #{redirectUrl}"
483
+ render :text => %Q(<script type="text/javascript">\ntop.location.href='#{redirectUrl}';\n</script>)
456
484
 
457
- canvasRedirUrl = url_for(options, *parameters)
458
- RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: Canvas redirect to #{canvasRedirUrl}"
459
- render :text => "<fb:redirect url=\"#{canvasRedirUrl}\" />"
460
-
485
+ # otherwise, we only need to do a standard redirect
461
486
  else
462
487
  RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: Regular redirect_to"
463
488
  redirect_to__ALIASED(options, *parameters)
@@ -63,6 +63,8 @@ module RFacebook
63
63
  return @controller.facebook_debug_panel(options)
64
64
  end
65
65
 
66
+ # TODO: override form_for to do <fb:editor> for Canvas pages, perhaps with an option to suppress such behavior
67
+
66
68
  end
67
69
  end
68
70
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: rfacebook
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.9.6
7
- date: 2007-09-10 00:00:00 -04:00
6
+ version: 0.9.7
7
+ date: 2007-09-29 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