rfacebook 0.8.7 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -336,20 +336,24 @@ module RFacebook
336
336
 
337
337
  # try to get a regular URL
338
338
  path = url_for__ALIASED(options, *parameters)
339
- path += "/"
340
339
 
341
340
  # replace anything that references the callback with the
342
341
  # Facebook canvas equivalent (apps.facebook.com/*)
343
- if path.starts_with?(self.facebook_callback_path)
342
+ if (path.starts_with?(self.facebook_callback_path) or "#{path}/".starts_with?(self.facebook_callback_path))
344
343
  path.sub!(self.facebook_callback_path, self.facebook_canvas_path)
345
344
  path = "http://apps.facebook.com#{path}"
346
345
  else
347
346
  # default to a full URL (will link externally)
348
347
  RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: failed to get canvas-friendly URL ("+path+") for ["+options.inspect+"], creating an external URL instead"
349
- options[:only_path] = false
350
- path = url_for__ALIASED(options, *parameters)
348
+ path = "#{request.protocol}#{request.host}:#{request.port}#{path}"
351
349
  end
352
350
 
351
+ # mock-ajax rewriting
352
+ elsif options[:mock_ajax]
353
+ options.delete(:mock_ajax) # clear it so it doesnt show up in the url
354
+ options[:only_path] = true
355
+ path = "#{request.protocol}#{request.host}:#{request.port}#{url_for__ALIASED(options, *parameters)}"
356
+
353
357
  # regular Rails rewriting
354
358
  else
355
359
  path = url_for__ALIASED(options, *parameters)
@@ -363,9 +367,18 @@ module RFacebook
363
367
 
364
368
  def redirect_to(options = {}, *parameters)
365
369
  if in_facebook_canvas?
370
+
366
371
  canvasRedirUrl = url_for(options, *parameters)
372
+
373
+ # ensure that we come back to the canvas if we redirect
374
+ # to somewhere else on Facebook
375
+ if canvasRedirUrl.starts_with?("http://www.facebook.com")
376
+ canvasRedirUrl = "#{canvasRedirUrl}&canvas"
377
+ end
378
+
367
379
  RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: Canvas redirect to #{canvasRedirUrl}"
368
- render :text => "<fb:redirect url=\"#{canvasRedirUrl}\" />"
380
+ render :text => "<fb:redirect url=\"#{canvasRedirUrl}\" />"
381
+
369
382
  else
370
383
  RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: Regular redirect_to"
371
384
  redirect_to__ALIASED(options, *parameters)
@@ -40,25 +40,25 @@ module RFacebook
40
40
  #####
41
41
  module ControllerExtensions
42
42
  def facebook_api_key
43
- FACEBOOK["key"]
43
+ FACEBOOK["key"] || super
44
44
  end
45
45
  def facebook_api_secret
46
- FACEBOOK["secret"]
46
+ FACEBOOK["secret"] || super
47
47
  end
48
48
  def facebook_canvas_path
49
- FACEBOOK["canvas_path"]
49
+ FACEBOOK["canvas_path"] || super
50
50
  end
51
51
  def facebook_callback_path
52
- FACEBOOK["callback_path"]
52
+ FACEBOOK["callback_path"] || super
53
53
  end
54
54
  end
55
55
  #####
56
56
  module ModelExtensions
57
57
  def facebook_api_key
58
- FACEBOOK["key"]
58
+ FACEBOOK["key"] || super
59
59
  end
60
60
  def facebook_api_secret
61
- FACEBOOK["secret"]
61
+ FACEBOOK["secret"] || super
62
62
  end
63
63
  end
64
64
  #####
@@ -85,14 +85,14 @@ def ensureLeadingAndTrailingSlashesForPath(path)
85
85
  if !path.reverse.starts_with?("/")
86
86
  path = "#{path}/"
87
87
  end
88
- return path
88
+ return path.strip
89
89
  else
90
90
  return nil
91
91
  end
92
92
  end
93
93
 
94
- FACEBOOK["canvas_path"] = ensureLeadingAndTrailingSlashesForPath(FACEBOOK["canvas_path"]).strip
95
- FACEBOOK["callback_path"] = ensureLeadingAndTrailingSlashesForPath(FACEBOOK["callback_path"]).strip
94
+ FACEBOOK["canvas_path"] = ensureLeadingAndTrailingSlashesForPath(FACEBOOK["canvas_path"])
95
+ FACEBOOK["callback_path"] = ensureLeadingAndTrailingSlashesForPath(FACEBOOK["callback_path"])
96
96
 
97
97
  # inject methods
98
98
  ActionView::Base.send(:include, RFacebook::Rails::ViewExtensions)
@@ -39,6 +39,10 @@ module RFacebook
39
39
  @controller.in_facebook_frame?
40
40
  end
41
41
 
42
+ def in_mock_ajax?
43
+ @controller.in_mock_ajax?
44
+ end
45
+
42
46
  def fbparams
43
47
  @controller.fbparams
44
48
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.1
3
3
  specification_version: 1
4
4
  name: rfacebook
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.8.7
7
- date: 2007-08-16 00:00:00 -05:00
6
+ version: 0.8.8
7
+ date: 2007-08-17 00:00:00 -05:00
8
8
  summary: A Ruby interface to the Facebook API v1.0+ (F8 and beyond). Works with RFacebook on Rails plugin (see rfacebook.rubyforge.org).
9
9
  require_paths:
10
10
  - lib