mmangino-facebooker 1.0.36 → 1.0.37

Sign up to get free protection for your applications and to get access to all the features.
data/facebooker.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{facebooker}
5
- s.version = "1.0.36"
5
+ s.version = "1.0.37"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Chad Fowler", "Patrick Ewing", "Mike Mangino", "Shane Vitarana", "Corey Innis"]
9
- s.date = %q{2009-05-28}
9
+ s.date = %q{2009-06-04}
10
10
  s.description = %q{Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]. Its goals are: * Idiomatic Ruby * No dependencies outside of the Ruby standard library (This is true with Rails 2.1. Previous Rails versions require the JSON gem) * Concrete classes and methods modeling the Facebook data, so it's easy for a Rubyist to understand what's available * Well tested}
11
11
  s.email = %q{mmangino@elevatedrails.com}
12
12
  s.extra_rdoc_files = ["Manifest.txt", "CHANGELOG.rdoc", "COPYING.rdoc", "README.rdoc", "TODO.rdoc"]
@@ -11,21 +11,29 @@ module Facebooker
11
11
  end
12
12
  end
13
13
 
14
+ #
15
+ # For information on the :app_settings argument see http://wiki.developers.facebook.com/index.php/JS_API_M_FB.Facebook.Init_2
16
+ # While it would be nice to treat :app_settings as a hash, some of the arguments do different things if they are a string vs a javascript function
17
+ # and Rails' Hash#to_json always quotes strings so there is no way to indicate when the value should be a javascript function.
18
+ # For this reason :app_settings needs to be a string that is valid JSON (including the {}'s).
19
+ #
14
20
  def init_fb_connect(*required_features,&proc)
15
21
  additions = ""
16
22
  if block_given?
17
23
  additions = capture(&proc)
18
24
  end
19
25
 
20
- options = {:js => :prototype}
26
+ # Yes, app_settings is set to a string of an empty JSON element. That's intentional.
27
+ options = {:js => :prototype, :app_settings => '{}'}
28
+
21
29
  if required_features.last.is_a?(Hash)
22
30
  options.merge!(required_features.pop.symbolize_keys)
23
31
  end
24
32
 
25
33
  if request.ssl?
26
- init_string = "FB.Facebook.init('#{Facebooker.api_key}','/xd_receiver_ssl.html');"
34
+ init_string = "FB.Facebook.init('#{Facebooker.api_key}','/xd_receiver_ssl.html', #{options[:app_settings]});"
27
35
  else
28
- init_string = "FB.Facebook.init('#{Facebooker.api_key}','/xd_receiver.html');"
36
+ init_string = "FB.Facebook.init('#{Facebooker.api_key}','/xd_receiver.html', #{options[:app_settings]});"
29
37
  end
30
38
  unless required_features.blank?
31
39
  init_string = <<-FBML
@@ -98,9 +106,9 @@ module Facebooker
98
106
  link_to_function text, js, *args
99
107
  end
100
108
 
101
- def fb_user_action(action, user_message = "", prompt = "", callback = nil)
109
+ def fb_user_action(action, user_message = nil, prompt = "", callback = nil)
102
110
  update_page do |page|
103
- page.call "FB.Connect.showFeedDialog",action.template_id,action.data,action.target_ids,action.body_general,nil,page.literal("FB.RequireConnect.promptConnect"),callback,prompt,user_message
111
+ page.call("FB.Connect.showFeedDialog",action.template_id,action.data,action.target_ids,action.body_general,nil,page.literal("FB.RequireConnect.promptConnect"),callback,prompt,user_message.nil? ? nil : {:value=>user_message})
104
112
  end
105
113
  end
106
114
 
@@ -56,15 +56,15 @@ module Facebooker
56
56
  # fbml 'text'
57
57
  # text fbml
58
58
  # end
59
- # # This will render the profile in /users/profile.erb
59
+ # # This will render the profile in /users/profile.fbml.erb
60
60
  # # it will set @user to user_to_update in the template
61
61
  # # The mobile profile will be rendered from the app/views/test_publisher/_mobile.erb
62
62
  # # template
63
63
  # def profile_update(user_to_update,user_with_session_to_use)
64
64
  # send_as :profile
65
65
  # from user_with_session_to_use
66
- # to user_to_update
67
- # profile render(:action=>"/users/profile",:assigns=>{:user=>user_to_update})
66
+ # recipients user_to_update
67
+ # profile render(:file=>"users/profile.fbml.erb",:assigns=>{:user=>user_to_update})
68
68
  # profile_action "A string"
69
69
  # mobile_profile render(:partial=>"mobile",:assigns=>{:user=>user_to_update})
70
70
  # end
@@ -74,7 +74,7 @@ module Facebooker
74
74
  # def ref_update(user)
75
75
  # send_as :ref
76
76
  # from user
77
- # fbml render(:action=>"/users/profile",:assigns=>{:user=>user_to_update})
77
+ # fbml render(:file=>"users/profile",:assigns=>{:user=>user_to_update})
78
78
  # handle "a_ref_handle"
79
79
  # end
80
80
  #
@@ -415,8 +415,11 @@ module Facebooker
415
415
  ActionController::Base.append_view_path(controller_root)
416
416
  ActionController::Base.append_view_path(controller_root+"/..")
417
417
  end
418
+ view_paths = ActionController::Base.view_paths
419
+ else
420
+ view_paths = [template_root, controller_root]
418
421
  end
419
- returning ActionView::Base.new([template_root,controller_root], assigns, self) do |template|
422
+ returning ActionView::Base.new(view_paths, assigns, self) do |template|
420
423
  template.controller=self
421
424
  template.extend(self.class.master_helper_module)
422
425
  def template.request_comes_from_facebook?
@@ -2,7 +2,7 @@ module Facebooker #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 36
5
+ TINY = 37
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1000,6 +1000,14 @@ class RailsHelperTest < Test::Unit::TestCase
1000
1000
  assert @h.init_fb_connect("XFBML", :js => :jquery).match(/\$\(document\).ready\(/)
1001
1001
  end
1002
1002
 
1003
+ def test_init_fb_connect_without_options_app_settings
1004
+ assert @h.init_fb_connect().match(/, \{\}\)/)
1005
+ end
1006
+
1007
+ def test_init_fb_connect_with_options_app_settings
1008
+ assert @h.init_fb_connect(:app_settings => "{foo: bar}").match(/, \{foo: bar\}\)/)
1009
+ end
1010
+
1003
1011
 
1004
1012
  def test_fb_login_and_redirect
1005
1013
  assert_equal @h.fb_login_and_redirect("/path"),"<fb:login-button onlogin=\"window.location.href = &quot;/path&quot;;\"></fb:login-button>"
@@ -1010,7 +1018,7 @@ class RailsHelperTest < Test::Unit::TestCase
1010
1018
  end
1011
1019
  def test_fb_user_action
1012
1020
  action = Facebooker::Rails::Publisher::UserAction.new
1013
- assert_equal @h.fb_user_action(action,"message","prompt"),"FB.Connect.showFeedDialog(null, null, null, null, null, FB.RequireConnect.promptConnect, null, \"prompt\", \"message\");"
1021
+ assert_equal @h.fb_user_action(action,"message","prompt"),"FB.Connect.showFeedDialog(null, null, null, null, null, FB.RequireConnect.promptConnect, null, \"prompt\", {\"value\": \"message\"});"
1014
1022
  end
1015
1023
 
1016
1024
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mmangino-facebooker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.36
4
+ version: 1.0.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Fowler
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2009-05-28 00:00:00 -07:00
16
+ date: 2009-06-04 00:00:00 -07:00
17
17
  default_executable:
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency