facebooker 1.0.31 → 1.0.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/CHANGELOG.rdoc +7 -0
  2. data/Manifest.txt +5 -0
  3. data/README.rdoc +9 -0
  4. data/facebooker.gemspec +8 -9
  5. data/generators/facebook/templates/public/javascripts/facebooker.js +10 -16
  6. data/init.rb +4 -1
  7. data/install.rb +1 -1
  8. data/lib/facebooker.rb +75 -20
  9. data/lib/facebooker/adapters/bebo_adapter.rb +9 -9
  10. data/lib/facebooker/data.rb +14 -14
  11. data/lib/facebooker/models/page.rb +16 -0
  12. data/lib/facebooker/models/photo.rb +7 -0
  13. data/lib/facebooker/models/user.rb +75 -28
  14. data/lib/facebooker/parser.rb +187 -127
  15. data/lib/facebooker/rails/backwards_compatible_param_checks.rb +31 -0
  16. data/lib/facebooker/rails/controller.rb +30 -7
  17. data/lib/facebooker/rails/extensions/rack_setup.rb +5 -1
  18. data/lib/facebooker/rails/facebook_request_fix.rb +5 -5
  19. data/lib/facebooker/rails/facebook_request_fix_2-3.rb +31 -0
  20. data/lib/facebooker/rails/facebook_url_rewriting.rb +7 -2
  21. data/lib/facebooker/rails/helpers.rb +29 -5
  22. data/lib/facebooker/rails/helpers/fb_connect.rb +14 -5
  23. data/lib/facebooker/rails/publisher.rb +26 -12
  24. data/lib/facebooker/service.rb +64 -56
  25. data/lib/facebooker/session.rb +56 -22
  26. data/lib/facebooker/version.rb +1 -1
  27. data/lib/rack/facebook.rb +26 -14
  28. data/lib/tasks/tunnel.rake +1 -1
  29. data/test/facebooker/adapters_test.rb +78 -0
  30. data/test/facebooker/data_test.rb +14 -14
  31. data/test/facebooker/models/page_test.rb +46 -0
  32. data/test/facebooker/models/photo_test.rb +16 -0
  33. data/test/facebooker/models/user_test.rb +83 -48
  34. data/test/facebooker/rails/facebook_request_fix_2-3_test.rb +25 -0
  35. data/test/facebooker/rails/facebook_url_rewriting_test.rb +39 -0
  36. data/test/facebooker/rails/publisher_test.rb +5 -1
  37. data/test/facebooker/rails_integration_test.rb +52 -8
  38. data/test/facebooker/service_test.rb +58 -0
  39. data/test/facebooker/session_test.rb +106 -92
  40. data/test/facebooker_test.rb +2 -2
  41. data/test/rack/facebook_test.rb +4 -4
  42. data/test/test_helper.rb +10 -3
  43. metadata +14 -4
@@ -1,3 +1,10 @@
1
+ === HEAD
2
+
3
+ * New Features
4
+
5
+ * Facebooker::User#publish_to for publishing to a Wall or News Stream
6
+ * Optionally parses with Nokogiri. Just require 'nokogiri' in your app.
7
+
1
8
  === 1.0.13 / 2009-02-26
2
9
 
3
10
  * Modified fql_query to return results as Hashes as a last resort [Alan Larkin]
@@ -75,6 +75,7 @@ lib/facebooker/models/user.rb
75
75
  lib/facebooker/models/video.rb
76
76
  lib/facebooker/models/work_info.rb
77
77
  lib/facebooker/parser.rb
78
+ lib/facebooker/rails/backwards_compatible_param_checks.rb
78
79
  lib/facebooker/rails/controller.rb
79
80
  lib/facebooker/rails/cucumber.rb
80
81
  lib/facebooker/rails/cucumber/world.rb
@@ -84,6 +85,7 @@ lib/facebooker/rails/extensions/routing.rb
84
85
  lib/facebooker/rails/facebook_form_builder.rb
85
86
  lib/facebooker/rails/facebook_pretty_errors.rb
86
87
  lib/facebooker/rails/facebook_request_fix.rb
88
+ lib/facebooker/rails/facebook_request_fix_2-3.rb
87
89
  lib/facebooker/rails/facebook_session_handling.rb
88
90
  lib/facebooker/rails/facebook_url_helper.rb
89
91
  lib/facebooker/rails/facebook_url_rewriting.rb
@@ -114,9 +116,12 @@ test/facebooker/logging_test.rb
114
116
  test/facebooker/mobile_test.rb
115
117
  test/facebooker/model_test.rb
116
118
  test/facebooker/models/event_test.rb
119
+ test/facebooker/models/page_test.rb
120
+ test/facebooker/models/photo_test.rb
117
121
  test/facebooker/models/user_test.rb
118
122
  test/facebooker/rails/publisher_test.rb
119
123
  test/facebooker/rails_integration_test.rb
124
+ test/facebooker/rails/facebook_request_fix_2-3_test.rb
120
125
  test/facebooker/server_cache_test.rb
121
126
  test/facebooker/session_test.rb
122
127
  test/facebooker_test.rb
@@ -56,6 +56,12 @@ Your application users will need to have added the application in facebook to ac
56
56
 
57
57
  to your application controller.
58
58
 
59
+ To prevent a violation of Facebook Terms of Service while reducing log bloat, you should also add
60
+
61
+ filter_parameter_logging :fb_sig_friends
62
+
63
+ to your application controller.
64
+
59
65
  == using MemCache session
60
66
 
61
67
  Facebook uses some non alphanum characters in the session identifier which interfere with memcache stored sessions. If you want to use MemCache for storing sessions, you can override the valid session id method on memcache by placing the following code in an initializer:
@@ -71,6 +77,9 @@ class CGI
71
77
  end
72
78
  end
73
79
 
80
+ == Other versions
81
+
82
+ A facebooker port for Sinatra is available at http://github.com/jsmestad/frankie/tree/master
74
83
 
75
84
  == LICENSE:
76
85
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{facebooker}
5
- s.version = "1.0.31"
5
+ s.version = "1.0.41"
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-04-30}
9
+ s.date = %q{2009-07-15}
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:
11
11
 
12
12
  * Idiomatic Ruby
@@ -15,15 +15,14 @@ Gem::Specification.new do |s|
15
15
  * Well tested}
16
16
  s.email = %q{mmangino@elevatedrails.com}
17
17
  s.extra_rdoc_files = ["Manifest.txt", "CHANGELOG.rdoc", "COPYING.rdoc", "README.rdoc", "TODO.rdoc"]
18
- s.files = [".autotest", "CHANGELOG.rdoc", "COPYING.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "TODO.rdoc", "examples/desktop_login.rb", "facebooker.gemspec", "generators/facebook/facebook_generator.rb", "generators/facebook/templates/config/facebooker.yml", "generators/facebook/templates/public/javascripts/facebooker.js", "generators/facebook_controller/USAGE", "generators/facebook_controller/facebook_controller_generator.rb", "generators/facebook_controller/templates/controller.rb", "generators/facebook_controller/templates/functional_test.rb", "generators/facebook_controller/templates/helper.rb", "generators/facebook_controller/templates/view.fbml.erb", "generators/facebook_controller/templates/view.html.erb", "generators/facebook_publisher/facebook_publisher_generator.rb", "generators/facebook_publisher/templates/create_facebook_templates.rb", "generators/facebook_publisher/templates/publisher.rb", "generators/facebook_scaffold/USAGE", "generators/facebook_scaffold/facebook_scaffold_generator.rb", "generators/facebook_scaffold/templates/controller.rb", "generators/facebook_scaffold/templates/facebook_style.css", "generators/facebook_scaffold/templates/functional_test.rb", "generators/facebook_scaffold/templates/helper.rb", "generators/facebook_scaffold/templates/layout.fbml.erb", "generators/facebook_scaffold/templates/layout.html.erb", "generators/facebook_scaffold/templates/style.css", "generators/facebook_scaffold/templates/view_edit.fbml.erb", "generators/facebook_scaffold/templates/view_edit.html.erb", "generators/facebook_scaffold/templates/view_index.fbml.erb", "generators/facebook_scaffold/templates/view_index.html.erb", "generators/facebook_scaffold/templates/view_new.fbml.erb", "generators/facebook_scaffold/templates/view_new.html.erb", "generators/facebook_scaffold/templates/view_show.fbml.erb", "generators/facebook_scaffold/templates/view_show.html.erb", "generators/publisher/publisher_generator.rb", "generators/xd_receiver/templates/xd_receiver.html", "generators/xd_receiver/xd_receiver_generator.rb", "init.rb", "install.rb", "lib/facebooker.rb", "lib/facebooker/adapters/adapter_base.rb", "lib/facebooker/adapters/bebo_adapter.rb", "lib/facebooker/adapters/facebook_adapter.rb", "lib/facebooker/admin.rb", "lib/facebooker/batch_request.rb", "lib/facebooker/data.rb", "lib/facebooker/feed.rb", "lib/facebooker/logging.rb", "lib/facebooker/mobile.rb", "lib/facebooker/mock/service.rb", "lib/facebooker/mock/session.rb", "lib/facebooker/model.rb", "lib/facebooker/models/affiliation.rb", "lib/facebooker/models/album.rb", "lib/facebooker/models/applicationproperties.rb", "lib/facebooker/models/applicationrestrictions.rb", "lib/facebooker/models/cookie.rb", "lib/facebooker/models/education_info.rb", "lib/facebooker/models/event.rb", "lib/facebooker/models/friend_list.rb", "lib/facebooker/models/group.rb", "lib/facebooker/models/info_item.rb", "lib/facebooker/models/info_section.rb", "lib/facebooker/models/location.rb", "lib/facebooker/models/notifications.rb", "lib/facebooker/models/page.rb", "lib/facebooker/models/photo.rb", "lib/facebooker/models/tag.rb", "lib/facebooker/models/user.rb", "lib/facebooker/models/video.rb", "lib/facebooker/models/work_info.rb", "lib/facebooker/parser.rb", "lib/facebooker/rails/controller.rb", "lib/facebooker/rails/cucumber.rb", "lib/facebooker/rails/cucumber/world.rb", "lib/facebooker/rails/extensions/action_controller.rb", "lib/facebooker/rails/extensions/rack_setup.rb", "lib/facebooker/rails/extensions/routing.rb", "lib/facebooker/rails/facebook_form_builder.rb", "lib/facebooker/rails/facebook_pretty_errors.rb", "lib/facebooker/rails/facebook_request_fix.rb", "lib/facebooker/rails/facebook_session_handling.rb", "lib/facebooker/rails/facebook_url_helper.rb", "lib/facebooker/rails/facebook_url_rewriting.rb", "lib/facebooker/rails/helpers.rb", "lib/facebooker/rails/helpers/fb_connect.rb", "lib/facebooker/rails/integration_session.rb", "lib/facebooker/rails/profile_publisher_extensions.rb", "lib/facebooker/rails/publisher.rb", "lib/facebooker/rails/routing.rb", "lib/facebooker/rails/test_helpers.rb", "lib/facebooker/rails/utilities.rb", "lib/facebooker/server_cache.rb", "lib/facebooker/service.rb", "lib/facebooker/session.rb", "lib/facebooker/version.rb", "lib/net/http_multipart_post.rb", "lib/rack/facebook.rb", "lib/tasks/facebooker.rake", "lib/tasks/tunnel.rake", "rails/init.rb", "setup.rb", "templates/layout.erb", "test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/fixtures/multipart_post_body_with_only_parameters.txt", "test/fixtures/multipart_post_body_with_single_file.txt", "test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt", "test/net/http_multipart_post_test.rb", "test/rack/facebook_test.rb", "test/rails_test_helper.rb", "test/test_helper.rb"]
19
- s.has_rdoc = true
18
+ s.files = [".autotest", "CHANGELOG.rdoc", "COPYING.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "TODO.rdoc", "examples/desktop_login.rb", "facebooker.gemspec", "generators/facebook/facebook_generator.rb", "generators/facebook/templates/config/facebooker.yml", "generators/facebook/templates/public/javascripts/facebooker.js", "generators/facebook_controller/USAGE", "generators/facebook_controller/facebook_controller_generator.rb", "generators/facebook_controller/templates/controller.rb", "generators/facebook_controller/templates/functional_test.rb", "generators/facebook_controller/templates/helper.rb", "generators/facebook_controller/templates/view.fbml.erb", "generators/facebook_controller/templates/view.html.erb", "generators/facebook_publisher/facebook_publisher_generator.rb", "generators/facebook_publisher/templates/create_facebook_templates.rb", "generators/facebook_publisher/templates/publisher.rb", "generators/facebook_scaffold/USAGE", "generators/facebook_scaffold/facebook_scaffold_generator.rb", "generators/facebook_scaffold/templates/controller.rb", "generators/facebook_scaffold/templates/facebook_style.css", "generators/facebook_scaffold/templates/functional_test.rb", "generators/facebook_scaffold/templates/helper.rb", "generators/facebook_scaffold/templates/layout.fbml.erb", "generators/facebook_scaffold/templates/layout.html.erb", "generators/facebook_scaffold/templates/style.css", "generators/facebook_scaffold/templates/view_edit.fbml.erb", "generators/facebook_scaffold/templates/view_edit.html.erb", "generators/facebook_scaffold/templates/view_index.fbml.erb", "generators/facebook_scaffold/templates/view_index.html.erb", "generators/facebook_scaffold/templates/view_new.fbml.erb", "generators/facebook_scaffold/templates/view_new.html.erb", "generators/facebook_scaffold/templates/view_show.fbml.erb", "generators/facebook_scaffold/templates/view_show.html.erb", "generators/publisher/publisher_generator.rb", "generators/xd_receiver/templates/xd_receiver.html", "generators/xd_receiver/xd_receiver_generator.rb", "init.rb", "install.rb", "lib/facebooker.rb", "lib/facebooker/adapters/adapter_base.rb", "lib/facebooker/adapters/bebo_adapter.rb", "lib/facebooker/adapters/facebook_adapter.rb", "lib/facebooker/admin.rb", "lib/facebooker/batch_request.rb", "lib/facebooker/data.rb", "lib/facebooker/feed.rb", "lib/facebooker/logging.rb", "lib/facebooker/mobile.rb", "lib/facebooker/mock/service.rb", "lib/facebooker/mock/session.rb", "lib/facebooker/model.rb", "lib/facebooker/models/affiliation.rb", "lib/facebooker/models/album.rb", "lib/facebooker/models/applicationproperties.rb", "lib/facebooker/models/applicationrestrictions.rb", "lib/facebooker/models/cookie.rb", "lib/facebooker/models/education_info.rb", "lib/facebooker/models/event.rb", "lib/facebooker/models/friend_list.rb", "lib/facebooker/models/group.rb", "lib/facebooker/models/info_item.rb", "lib/facebooker/models/info_section.rb", "lib/facebooker/models/location.rb", "lib/facebooker/models/notifications.rb", "lib/facebooker/models/page.rb", "lib/facebooker/models/photo.rb", "lib/facebooker/models/tag.rb", "lib/facebooker/models/user.rb", "lib/facebooker/models/video.rb", "lib/facebooker/models/work_info.rb", "lib/facebooker/parser.rb", "lib/facebooker/rails/backwards_compatible_param_checks.rb", "lib/facebooker/rails/controller.rb", "lib/facebooker/rails/cucumber.rb", "lib/facebooker/rails/cucumber/world.rb", "lib/facebooker/rails/extensions/action_controller.rb", "lib/facebooker/rails/extensions/rack_setup.rb", "lib/facebooker/rails/extensions/routing.rb", "lib/facebooker/rails/facebook_form_builder.rb", "lib/facebooker/rails/facebook_pretty_errors.rb", "lib/facebooker/rails/facebook_request_fix.rb", "lib/facebooker/rails/facebook_request_fix_2-3.rb", "lib/facebooker/rails/facebook_session_handling.rb", "lib/facebooker/rails/facebook_url_helper.rb", "lib/facebooker/rails/facebook_url_rewriting.rb", "lib/facebooker/rails/helpers.rb", "lib/facebooker/rails/helpers/fb_connect.rb", "lib/facebooker/rails/integration_session.rb", "lib/facebooker/rails/profile_publisher_extensions.rb", "lib/facebooker/rails/publisher.rb", "lib/facebooker/rails/routing.rb", "lib/facebooker/rails/test_helpers.rb", "lib/facebooker/rails/utilities.rb", "lib/facebooker/server_cache.rb", "lib/facebooker/service.rb", "lib/facebooker/session.rb", "lib/facebooker/version.rb", "lib/net/http_multipart_post.rb", "lib/rack/facebook.rb", "lib/tasks/facebooker.rake", "lib/tasks/tunnel.rake", "rails/init.rb", "setup.rb", "templates/layout.erb", "test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/page_test.rb", "test/facebooker/models/photo_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/rails/facebook_request_fix_2-3_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/fixtures/multipart_post_body_with_only_parameters.txt", "test/fixtures/multipart_post_body_with_single_file.txt", "test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt", "test/net/http_multipart_post_test.rb", "test/rack/facebook_test.rb", "test/rails_test_helper.rb", "test/test_helper.rb", "test/facebooker/rails/facebook_url_rewriting_test.rb", "test/facebooker/service_test.rb"]
20
19
  s.homepage = %q{http://facebooker.rubyforge.org}
21
20
  s.rdoc_options = ["--main", "README.rdoc"]
22
21
  s.require_paths = ["lib"]
23
22
  s.rubyforge_project = %q{facebooker}
24
- s.rubygems_version = %q{1.3.2}
23
+ s.rubygems_version = %q{1.3.4}
25
24
  s.summary = %q{Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]}
26
- s.test_files = ["test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/net/http_multipart_post_test.rb", "test/rack/facebook_test.rb"]
25
+ s.test_files = ["test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/page_test.rb", "test/facebooker/models/photo_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/facebook_request_fix_2-3_test.rb", "test/facebooker/rails/facebook_url_rewriting_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/service_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/net/http_multipart_post_test.rb", "test/rack/facebook_test.rb"]
27
26
 
28
27
  if s.respond_to? :specification_version then
29
28
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -31,13 +30,13 @@ Gem::Specification.new do |s|
31
30
 
32
31
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
33
32
  s.add_runtime_dependency(%q<json>, [">= 1.0.0"])
34
- s.add_development_dependency(%q<hoe>, [">= 1.12.1"])
33
+ s.add_development_dependency(%q<hoe>, [">= 2.3.2"])
35
34
  else
36
35
  s.add_dependency(%q<json>, [">= 1.0.0"])
37
- s.add_dependency(%q<hoe>, [">= 1.12.1"])
36
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
38
37
  end
39
38
  else
40
39
  s.add_dependency(%q<json>, [">= 1.0.0"])
41
- s.add_dependency(%q<hoe>, [">= 1.12.1"])
40
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
42
41
  end
43
42
  end
@@ -48,7 +48,7 @@ function encodeURIComponent(str) {
48
48
 
49
49
  var Form = {};
50
50
  Form.serialize = function(form_element) {
51
- return $(form_element).serialize();
51
+ return $(form_element).serialize();
52
52
  };
53
53
 
54
54
  Ajax.Updater = function (container,url,options) {
@@ -69,22 +69,16 @@ Ajax.Updater = function (container,url,options) {
69
69
  this.ajax.onerror = options["onFailure"];
70
70
  }
71
71
 
72
- // Yes, this is an excercise in undoing what we just did
73
- // FB doesn't provide encodeURI, but they will encode things passed as a hash
74
- // so we turn it into a string, esaping & and =
75
- // then we split it all back out here
76
- // this could be killed if encodeURIComponent was available
77
- parameters={};
78
- if (options['parameters']) {
79
- pairs=options['parameters'].split('&');
80
- for (var i=0; i<pairs.length; i++) {
81
- kv=pairs[i].split('=');
82
- key=kv[0].replace(/%3D/g,'=').replace(/%26/g,'&');
83
- val=kv[1].replace(/%3D/g,'=').replace(/%26/g,'&');
84
- parameters[key]=val;
85
- }
72
+ if (!options['parameters']) {
73
+ options['parameters'] = {}
74
+ }
75
+
76
+ // simulate other verbs over post
77
+ if (options['method']) {
78
+ options['parameters']['_method'] = options['method'];
86
79
  }
87
- this.ajax.post(url,parameters);
80
+
81
+ this.ajax.post(url,options['parameters']);
88
82
  if (options["onLoading"]) {
89
83
  options["onLoading"].call()
90
84
  }
data/init.rb CHANGED
@@ -5,19 +5,22 @@ facebook_config = "#{RAILS_ROOT}/config/facebooker.yml"
5
5
  require 'facebooker'
6
6
  FACEBOOKER = Facebooker.load_configuration(facebook_config)
7
7
 
8
- # enable logger before including everything else, in case we ever want to log initialization
8
+ # enable logger before including everything else, in case we ever want to log initialization
9
9
  Facebooker.logger = RAILS_DEFAULT_LOGGER if Object.const_defined? :RAILS_DEFAULT_LOGGER
10
10
 
11
11
  require 'net/http_multipart_post'
12
12
  if defined? Rails
13
+ require 'facebooker/rails/backwards_compatible_param_checks'
13
14
  require 'facebooker/rails/controller'
14
15
  require 'facebooker/rails/facebook_url_rewriting'
15
16
  require 'facebooker/rails/facebook_session_handling' if Rails.version < '2.3'
16
17
  require 'facebooker/rails/facebook_request_fix' if Rails.version < '2.3'
18
+ require 'facebooker/rails/facebook_request_fix_2-3' if Rails.version >= '2.3'
17
19
  require 'facebooker/rails/routing'
18
20
  require 'facebooker/rails/facebook_pretty_errors' rescue nil
19
21
  require 'facebooker/rails/facebook_url_helper'
20
22
  require 'facebooker/rails/extensions/rack_setup' if Rails.version > '2.3'
21
23
  require 'facebooker/rails/extensions/action_controller'
24
+ #require 'facebooker/rails/extensions/action_view'
22
25
  require 'facebooker/rails/extensions/routing'
23
26
  end
data/install.rb CHANGED
@@ -9,4 +9,4 @@ script = File.join('public', 'javascripts', 'facebooker.js')
9
9
  [config, script].each do |path|
10
10
  FileUtils.cp File.join(templates, path), File.join(RAILS_ROOT, path) unless File.exist?(File.join(RAILS_ROOT, path))
11
11
  end
12
- puts IO.read(File.join(dir, 'README'))
12
+ puts IO.read(File.join(dir, 'README.rdoc'))
@@ -1,29 +1,33 @@
1
- begin
2
- unless Object.const_defined?("ActiveSupport") and ActiveSupport.const_defined?("JSON")
3
- require 'json'
4
- module Facebooker
5
- def self.json_decode(str)
6
- JSON.parse(str)
7
- end
1
+ unless defined?(ActiveSupport) and defined?(ActiveSupport::JSON)
2
+ require 'json'
3
+ module Facebooker
4
+ def self.json_decode(str)
5
+ JSON.parse(str)
8
6
  end
9
- else
10
- module Facebooker
11
- def self.json_decode(str)
12
- ActiveSupport::JSON.decode(str)
13
- end
7
+
8
+ def self.json_encode(o)
9
+ JSON.dump(o)
10
+ end
11
+ end
12
+ else
13
+ module Facebooker
14
+ def self.json_decode(str)
15
+ ActiveSupport::JSON.decode(str)
16
+ end
17
+
18
+ def self.json_encode(o)
19
+ ActiveSupport::JSON.encode(o)
14
20
  end
15
21
  end
16
- rescue
17
- require 'json'
18
22
  end
23
+
19
24
  require 'zlib'
20
25
  require 'digest/md5'
21
26
 
22
-
23
-
24
27
  module Facebooker
25
28
 
26
29
  @facebooker_configuration = {}
30
+ @raw_facebooker_configuration = {}
27
31
  @current_adapter = nil
28
32
  @set_asset_host_to_callback_url = true
29
33
  @path_prefix = nil
@@ -33,12 +37,12 @@ module Facebooker
33
37
 
34
38
  def load_configuration(facebooker_yaml_file)
35
39
  if File.exist?(facebooker_yaml_file)
40
+ @raw_facebooker_configuration = YAML.load(ERB.new(File.read(facebooker_yaml_file)).result)
36
41
  if defined? RAILS_ENV
37
- config = YAML.load_file(facebooker_yaml_file)[RAILS_ENV]
38
- else
39
- config = YAML.load_file(facebooker_yaml_file)
42
+ @raw_facebooker_configuration = @raw_facebooker_configuration[RAILS_ENV]
40
43
  end
41
- apply_configuration(config)
44
+ Thread.current[:fb_api_config] = @raw_facebooker_configuration unless Thread.current[:fb_api_config]
45
+ apply_configuration(@raw_facebooker_configuration)
42
46
  end
43
47
  end
44
48
 
@@ -64,6 +68,42 @@ module Facebooker
64
68
  @facebooker_configuration
65
69
  end
66
70
 
71
+ def with_application(api_key, &block)
72
+ config = fetch_config_for( api_key )
73
+
74
+ unless config
75
+ self.logger.info "Can't find facebooker config: '#{api_key}'" if self.logger
76
+ yield if block_given?
77
+ return
78
+ end
79
+
80
+ # Save the old config to handle nested activation. If no app context is
81
+ # set yet, use default app's configuration.
82
+ old = Thread.current[:fb_api_config] ? Thread.current[:fb_api_config].dup : @raw_facebooker_configuration
83
+
84
+ if block_given?
85
+ begin
86
+ self.logger.info "Swapping facebooker config: '#{api_key}'" if self.logger
87
+ Thread.current[:fb_api_config] = apply_configuration(config)
88
+ yield
89
+ ensure
90
+ Thread.current[:fb_api_config] = old if old
91
+ apply_configuration(Thread.current[:fb_api_config])
92
+ end
93
+ end
94
+ end
95
+
96
+ def fetch_config_for(api_key)
97
+ if @raw_facebooker_configuration['api_key'] == api_key
98
+ return @raw_facebooker_configuration
99
+ elsif @raw_facebooker_configuration['alternative_keys'] and
100
+ @raw_facebooker_configuration['alternative_keys'].keys.include?(api_key)
101
+ return @raw_facebooker_configuration['alternative_keys'][api_key].merge(
102
+ 'api_key' => api_key )
103
+ end
104
+ return false
105
+ end
106
+
67
107
  # TODO: This should be converted to attr_accessor, but we need to
68
108
  # get all the require statements at the top of the file to work.
69
109
 
@@ -146,6 +186,21 @@ require 'facebooker/logging'
146
186
  require 'facebooker/model'
147
187
  require 'facebooker/parser'
148
188
  require 'facebooker/service'
189
+ require 'facebooker/service/base_service'
190
+ #optional HTTP service adapters
191
+ begin
192
+ require 'facebooker/service/curl_service'
193
+ rescue LoadError
194
+ nil
195
+ end
196
+ begin
197
+ require 'facebooker/service/typhoeus_service'
198
+ require 'facebooker/service/typhoeus_multi_service'
199
+ rescue LoadError
200
+ nil
201
+ end
202
+
203
+ require 'facebooker/service/net_http_service'
149
204
  require 'facebooker/server_cache'
150
205
  require 'facebooker/data'
151
206
  require 'facebooker/admin'
@@ -1,14 +1,14 @@
1
1
  module Facebooker
2
2
  class BeboAdapter < AdapterBase
3
-
3
+
4
4
  def canvas_server_base
5
5
  "apps.bebo.com"
6
6
  end
7
-
7
+
8
8
  def api_server_base
9
9
  'apps.bebo.com'
10
10
  end
11
-
11
+
12
12
  def api_rest_path
13
13
  "/restserver.php"
14
14
  end
@@ -44,9 +44,9 @@ module Facebooker
44
44
  end
45
45
  alias_method :set_profile_fbml_without_bebo_adapter, :set_profile_fbml
46
46
  alias_method :set_profile_fbml, :set_profile_fbml_with_bebo_adapter
47
-
47
+
48
48
  private
49
-
49
+
50
50
  BEBO_FIELDS = FIELDS - [:meeting_sex, :wall_count, :meeting_for]
51
51
 
52
52
  remove_method :collect
@@ -57,15 +57,15 @@ module Facebooker
57
57
  else
58
58
  FIELDS.reject{|field_name| !fields.empty? && !fields.include?(field_name)}.join(',')
59
59
  end
60
- end
60
+ end
61
61
  end
62
-
63
-
62
+
63
+
64
64
  class PublishTemplatizedAction < Parser#:nodoc:
65
65
  class <<self
66
66
  def process_with_bebo_adapter(data)
67
67
  if(Facebooker.is_for?(:bebo))
68
- element('feed_publishTemplatizedAction_response', data).text_value
68
+ element('feed_publishTemplatizedAction_response', data).content
69
69
  else
70
70
  process_without_bebo_adapter(data)
71
71
  end
@@ -3,7 +3,7 @@ module Facebooker
3
3
  def initialize(session)
4
4
  @session = session
5
5
  end
6
-
6
+
7
7
  ##
8
8
  # ** BETA ***
9
9
  # Sets a cookie on Facebook
@@ -11,32 +11,32 @@ module Facebooker
11
11
  # +name+ Name of the cookie
12
12
  # +value+ Value of the cookie
13
13
  # Optional:
14
- # +expires+ Time when the cookie should expire. If not specified, the cookie never expires.
14
+ # +expires+ Time when the cookie should expire. If not specified, the cookie never expires.
15
15
  # +path+ Path relative to the application's callback URL, with which the cookie should be associated. (default value is /?
16
16
  def set_cookie(user, name, value, expires=nil, path=nil)
17
- @session.post('facebook.data.setCookie',
18
- :uid => User.cast_to_facebook_id(user),
19
- :name => name,
20
- :value => value,
21
- :expires => expires,
17
+ @session.post('facebook.data.setCookie',
18
+ :uid => User.cast_to_facebook_id(user),
19
+ :name => name,
20
+ :value => value,
21
+ :expires => expires,
22
22
  :path => path) {|response| response == '1'}
23
23
  end
24
-
24
+
25
25
  ##
26
26
  # ** BETA ***
27
27
  # Gets a cookie stored on Facebook
28
- # +user+ The user from whom to get the cookies.
29
- # Optional:
28
+ # +user+ The user from whom to get the cookies.
29
+ # Optional:
30
30
  # +name+ The name of the cookie. If not specified, all the cookies for the given user get returned.
31
31
  def get_cookies(user, name=nil)
32
- @cookies = @session.post(
32
+ @cookies = @session.post(
33
33
  'facebook.data.getCookies', :uid => User.cast_to_facebook_id(user), :name => name) do |response|
34
34
  response.map do |hash|
35
35
  Cookie.from_hash(hash)
36
36
  end
37
37
  end
38
- end
39
-
38
+ end
39
+
40
40
  ##
41
41
  # ** BETA ***
42
42
  # Gets a preference stored on Facebook
@@ -54,4 +54,4 @@ module Facebooker
54
54
  @session.post('facebook.data.setUserPreference', :pref_id=>pref_id, :value=>value)
55
55
  end
56
56
  end
57
- end
57
+ end
@@ -1,6 +1,14 @@
1
1
  require 'facebooker/model'
2
2
  module Facebooker
3
3
  class Page
4
+
5
+ def initialize(*args)
6
+ if args.size == 1 and (args.first.is_a?(Integer) or args.first.is_a?(String))
7
+ self.page_id=args.first
8
+ else
9
+ super
10
+ end
11
+ end
4
12
 
5
13
  class Genre
6
14
  include Model
@@ -24,5 +32,13 @@ module Facebooker
24
32
  def genre=(value)
25
33
  @genre = value.kind_of?(Hash) ? Genre.from_hash(value) : value
26
34
  end
35
+
36
+ def user_is_admin?(user)
37
+ Session.current.post('facebook.pages.isAdmin', :page_id=>self.page_id, :uid=>Facebooker::User.cast_to_facebook_id(user))
38
+ end
39
+
40
+ def user_is_fan?(user)
41
+ Session.current.post('facebook.pages.isFan', :page_id=>self.page_id, :uid=>Facebooker::User.cast_to_facebook_id(user))
42
+ end
27
43
  end
28
44
  end