mmangino-facebooker 1.0.29 → 1.0.30
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +15 -0
- data/Manifest.txt +129 -0
- data/Rakefile +2 -3
- data/examples/desktop_login.rb +14 -0
- data/facebooker.gemspec +43 -0
- data/lib/facebooker/adapters/adapter_base.rb +3 -2
- data/lib/facebooker/adapters/bebo_adapter.rb +6 -4
- data/lib/facebooker/batch_request.rb +11 -10
- data/lib/facebooker/logging.rb +6 -13
- data/lib/facebooker/mobile.rb +2 -2
- data/lib/facebooker/model.rb +15 -13
- data/lib/facebooker/models/applicationproperties.rb +1 -1
- data/lib/facebooker/models/applicationrestrictions.rb +3 -3
- data/lib/facebooker/models/event.rb +2 -2
- data/lib/facebooker/models/friend_list.rb +2 -2
- data/lib/facebooker/models/group.rb +4 -4
- data/lib/facebooker/models/page.rb +3 -2
- data/lib/facebooker/models/photo.rb +2 -2
- data/lib/facebooker/models/user.rb +13 -5
- data/lib/facebooker/models/work_info.rb +3 -2
- data/lib/facebooker/rails/controller.rb +6 -1
- data/lib/facebooker/rails/facebook_request_fix.rb +12 -8
- data/lib/facebooker/rails/facebook_session_handling.rb +1 -2
- data/lib/facebooker/rails/facebook_url_rewriting.rb +14 -11
- data/lib/facebooker/rails/helpers/fb_connect.rb +8 -2
- data/lib/facebooker/rails/helpers.rb +4 -3
- data/lib/facebooker/rails/publisher.rb +36 -30
- data/lib/facebooker/session.rb +81 -73
- data/lib/facebooker/version.rb +1 -1
- data/lib/facebooker.rb +41 -39
- data/test/facebooker/adapters_test.rb +23 -23
- data/test/facebooker/model_test.rb +10 -0
- data/test/facebooker/rails/publisher_test.rb +97 -88
- data/test/facebooker/rails_integration_test.rb +44 -43
- data/test/facebooker/session_test.rb +5 -5
- data/test/rack/facebook_test.rb +2 -3
- data/test/rails_test_helper.rb +14 -0
- data/test/test_helper.rb +5 -4
- metadata +21 -16
@@ -1,16 +1,18 @@
|
|
1
1
|
module ::ActionController
|
2
2
|
class AbstractRequest
|
3
3
|
def request_method_with_facebooker
|
4
|
-
if parameters[:
|
5
|
-
parameters[:
|
4
|
+
if parameters[:_method].blank?
|
5
|
+
if %w{GET HEAD}.include?(parameters[:fb_sig_request_method])
|
6
|
+
parameters[:_method] = parameters[:fb_sig_request_method]
|
7
|
+
end
|
6
8
|
end
|
7
9
|
request_method_without_facebooker
|
8
10
|
end
|
9
|
-
|
11
|
+
|
10
12
|
if new.methods.include?("request_method")
|
11
|
-
alias_method_chain :request_method, :facebooker
|
13
|
+
alias_method_chain :request_method, :facebooker
|
12
14
|
end
|
13
|
-
|
15
|
+
|
14
16
|
def xml_http_request_with_facebooker?
|
15
17
|
parameters["fb_sig_is_mockajax"] == "1" ||
|
16
18
|
parameters["fb_sig_is_ajax"] == "1" ||
|
@@ -18,7 +20,9 @@ module ::ActionController
|
|
18
20
|
end
|
19
21
|
alias_method_chain :xml_http_request?, :facebooker
|
20
22
|
# we have to re-alias xhr? since it was pointing to the old method
|
21
|
-
|
22
|
-
|
23
|
+
unless defined? :xhr?
|
24
|
+
alias xhr? :xml_http_request?
|
25
|
+
end
|
26
|
+
|
23
27
|
end
|
24
|
-
end
|
28
|
+
end
|
@@ -24,7 +24,6 @@ end
|
|
24
24
|
|
25
25
|
class CGI
|
26
26
|
class Session
|
27
|
-
private
|
28
27
|
alias :initialize_aliased_by_facebooker :initialize
|
29
28
|
attr_reader :request, :initialization_options
|
30
29
|
|
@@ -66,4 +65,4 @@ class CGI
|
|
66
65
|
@session_id || create_new_id_aliased_by_facebooker
|
67
66
|
end
|
68
67
|
end
|
69
|
-
end
|
68
|
+
end
|
@@ -1,35 +1,38 @@
|
|
1
1
|
module ::ActionController
|
2
2
|
if Rails.version < '2.3'
|
3
|
-
class AbstractRequest
|
3
|
+
class AbstractRequest
|
4
4
|
def relative_url_root
|
5
5
|
Facebooker.path_prefix
|
6
|
-
end
|
6
|
+
end
|
7
7
|
end
|
8
8
|
else
|
9
|
-
class Request
|
9
|
+
class Request
|
10
10
|
def relative_url_root
|
11
11
|
Facebooker.path_prefix
|
12
|
-
end
|
12
|
+
end
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
class Base
|
17
|
-
|
18
|
-
|
17
|
+
class << self
|
18
|
+
alias :old_relative_url_root :relative_url_root
|
19
|
+
def relative_url_root
|
20
|
+
Facebooker.path_prefix
|
21
|
+
end
|
19
22
|
end
|
20
|
-
end
|
21
|
-
|
23
|
+
end
|
24
|
+
|
22
25
|
class UrlRewriter
|
23
26
|
RESERVED_OPTIONS << :canvas
|
24
27
|
def link_to_new_canvas?
|
25
|
-
@request.parameters["fb_sig_in_new_facebook"] == "1"
|
28
|
+
@request.parameters["fb_sig_in_new_facebook"] == "1"
|
26
29
|
end
|
27
30
|
def link_to_canvas?(params, options)
|
28
31
|
option_override = options[:canvas]
|
29
32
|
return false if option_override == false # important to check for false. nil should use default behavior
|
30
33
|
option_override || (can_safely_access_request_parameters? && (@request.parameters["fb_sig_in_canvas"] == "1" || @request.parameters[:fb_sig_in_canvas] == "1" ))
|
31
34
|
end
|
32
|
-
|
35
|
+
|
33
36
|
#rails blindly tries to merge things that may be nil into the parameters. Make sure this won't break
|
34
37
|
def can_safely_access_request_parameters?
|
35
38
|
@request.request_parameters
|
@@ -36,8 +36,14 @@ module Facebooker
|
|
36
36
|
});
|
37
37
|
FBML
|
38
38
|
end
|
39
|
-
|
40
|
-
|
39
|
+
|
40
|
+
# block_is_within_action_view? is rails 2.1.x and has been
|
41
|
+
# deprecated. rails >= 2.2.x uses block_called_from_erb?
|
42
|
+
block_tester = respond_to?(:block_is_within_action_view?) ?
|
43
|
+
:block_is_within_action_view? : :block_called_from_erb?
|
44
|
+
|
45
|
+
if block_given? && send(block_tester, proc)
|
46
|
+
concat(javascript_tag(init_string))
|
41
47
|
else
|
42
48
|
javascript_tag init_string
|
43
49
|
end
|
@@ -1,16 +1,17 @@
|
|
1
1
|
require 'action_pack'
|
2
|
+
|
2
3
|
module Facebooker
|
3
4
|
module Rails
|
4
|
-
|
5
|
+
|
5
6
|
# Facebook specific helpers for creating FBML
|
6
7
|
#
|
7
8
|
# All helpers that take a user as a parameter will get the Facebook UID from the facebook_id attribute if it exists.
|
8
9
|
# It will use to_s if the facebook_id attribute is not present.
|
9
10
|
#
|
10
11
|
module Helpers
|
11
|
-
|
12
|
+
|
12
13
|
include Facebooker::Rails::Helpers::FbConnect
|
13
|
-
|
14
|
+
|
14
15
|
# Create an fb:dialog
|
15
16
|
# id must be a unique name e.g. "my_dialog"
|
16
17
|
# cancel_button is true or false
|
@@ -88,31 +88,32 @@ module Facebooker
|
|
88
88
|
#
|
89
89
|
# Publisher makes many helpers available, including the linking and asset helpers
|
90
90
|
class Publisher
|
91
|
-
|
91
|
+
|
92
92
|
#story sizes from the Facebooker API
|
93
93
|
ONE_LINE=1
|
94
94
|
SHORT=2
|
95
95
|
FULL=4
|
96
|
-
|
96
|
+
|
97
97
|
def initialize
|
98
|
-
@
|
98
|
+
@from = nil
|
99
|
+
@full_story_template = nil
|
100
|
+
@recipients = nil
|
101
|
+
@controller = PublisherController.new
|
99
102
|
end
|
100
|
-
|
103
|
+
|
101
104
|
# use facebook options everywhere
|
102
105
|
def request_comes_from_facebook?
|
103
106
|
true
|
104
107
|
end
|
105
|
-
|
108
|
+
|
106
109
|
class FacebookTemplate < ::ActiveRecord::Base
|
107
|
-
|
108
|
-
|
109
110
|
cattr_accessor :template_cache
|
110
111
|
self.template_cache = {}
|
111
|
-
|
112
|
+
|
112
113
|
def self.inspect(*args)
|
113
114
|
"FacebookTemplate"
|
114
115
|
end
|
115
|
-
|
116
|
+
|
116
117
|
def template_changed?(hash)
|
117
118
|
if respond_to?(:content_hash)
|
118
119
|
content_hash != hash
|
@@ -180,20 +181,21 @@ module Facebooker
|
|
180
181
|
(publisher.full_story_template and publisher.full_story_template.to_a.sort_by{|e| e[0].to_s})
|
181
182
|
].to_json
|
182
183
|
end
|
183
|
-
|
184
|
+
|
184
185
|
def template_name(klass,method)
|
185
186
|
"#{klass.name}::#{method}"
|
186
187
|
end
|
187
188
|
end
|
188
189
|
end
|
189
|
-
|
190
|
+
|
190
191
|
class_inheritable_accessor :master_helper_module
|
191
|
-
attr_accessor :one_line_story_templates, :short_story_templates
|
192
|
-
|
192
|
+
attr_accessor :one_line_story_templates, :short_story_templates
|
193
|
+
attr_writer :action_links
|
194
|
+
|
193
195
|
cattr_accessor :skip_registry
|
194
196
|
self.skip_registry = false
|
195
|
-
|
196
|
-
|
197
|
+
|
198
|
+
|
197
199
|
class InvalidSender < StandardError; end
|
198
200
|
class UnknownBodyType < StandardError; end
|
199
201
|
class UnspecifiedBodyType < StandardError; end
|
@@ -219,20 +221,21 @@ module Facebooker
|
|
219
221
|
end
|
220
222
|
class UserAction
|
221
223
|
attr_accessor :data
|
222
|
-
|
224
|
+
attr_reader :target_ids
|
223
225
|
attr_accessor :body_general
|
224
226
|
attr_accessor :template_id
|
225
227
|
attr_accessor :template_name
|
226
228
|
attr_accessor :story_size
|
227
|
-
|
229
|
+
|
228
230
|
def target_ids=(val)
|
229
231
|
@target_ids = val.is_a?(Array) ? val.join(",") : val
|
230
232
|
end
|
233
|
+
|
231
234
|
def data_hash
|
232
235
|
data||{}
|
233
236
|
end
|
234
237
|
end
|
235
|
-
|
238
|
+
|
236
239
|
cattr_accessor :ignore_errors
|
237
240
|
attr_accessor :_body
|
238
241
|
|
@@ -288,12 +291,12 @@ module Facebooker
|
|
288
291
|
@one_line_story_templates ||= []
|
289
292
|
@one_line_story_templates << str
|
290
293
|
end
|
291
|
-
|
294
|
+
|
292
295
|
def short_story_template(title,body,params={})
|
293
296
|
@short_story_templates ||= []
|
294
297
|
@short_story_templates << params.merge(:template_title=>title, :template_body=>body)
|
295
298
|
end
|
296
|
-
|
299
|
+
|
297
300
|
def action_links(*links)
|
298
301
|
if links.blank?
|
299
302
|
@action_links
|
@@ -493,38 +496,41 @@ module Facebooker
|
|
493
496
|
args.each do |arg|
|
494
497
|
case arg
|
495
498
|
when Symbol,String
|
496
|
-
add_template_helper("#{arg.to_s.classify}Helper".constantize)
|
499
|
+
add_template_helper("#{arg.to_s.classify}Helper".constantize)
|
497
500
|
when Module
|
498
501
|
add_template_helper(arg)
|
499
502
|
end
|
500
503
|
end
|
501
504
|
end
|
502
|
-
|
505
|
+
|
503
506
|
def add_template_helper(helper_module) #:nodoc:
|
504
507
|
master_helper_module.send :include,helper_module
|
505
508
|
include master_helper_module
|
506
509
|
end
|
507
510
|
|
508
|
-
|
511
|
+
|
509
512
|
def inherited(child)
|
510
|
-
super
|
513
|
+
super
|
511
514
|
child.master_helper_module=Module.new
|
512
515
|
child.master_helper_module.__send__(:include,self.master_helper_module)
|
513
516
|
child.send(:include, child.master_helper_module)
|
514
517
|
FacebookTemplate.clear_cache!
|
515
518
|
end
|
516
|
-
|
519
|
+
|
517
520
|
end
|
518
521
|
class PublisherController
|
519
522
|
include Facebooker::Rails::Publisher.master_helper_module
|
520
523
|
include ActionController::UrlWriter
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
+
|
525
|
+
class << self
|
526
|
+
alias :old_default_url_options :default_url_options
|
527
|
+
def default_url_options(*args)
|
528
|
+
Facebooker::Rails::Publisher.default_url_options(*args)
|
529
|
+
end
|
524
530
|
end
|
525
|
-
|
531
|
+
|
526
532
|
end
|
527
|
-
|
533
|
+
|
528
534
|
end
|
529
535
|
end
|
530
536
|
end
|