mmangino-facebooker 1.0.28 → 1.0.29
Sign up to get free protection for your applications and to get access to all the features.
- data/generators/facebook/templates/config/facebooker.yml +3 -0
- data/lib/facebooker/models/user.rb +1 -1
- data/lib/facebooker/rails/controller.rb +29 -4
- data/lib/facebooker/rails/helpers/fb_connect.rb +12 -3
- data/lib/facebooker/rails/helpers.rb +7 -0
- data/lib/facebooker/rails/publisher.rb +1 -0
- data/lib/facebooker/version.rb +1 -1
- data/lib/tasks/tunnel.rake +3 -3
- data/test/facebooker/rails_integration_test.rb +28 -0
- metadata +2 -2
@@ -20,6 +20,7 @@ development:
|
|
20
20
|
public_host:
|
21
21
|
public_port: 4007
|
22
22
|
local_port: 3000
|
23
|
+
server_alive_interval: 0
|
23
24
|
|
24
25
|
test:
|
25
26
|
api_key:
|
@@ -32,6 +33,7 @@ test:
|
|
32
33
|
public_host:
|
33
34
|
public_port: 4007
|
34
35
|
local_port: 3000
|
36
|
+
server_alive_interval: 0
|
35
37
|
|
36
38
|
production:
|
37
39
|
api_key:
|
@@ -44,3 +46,4 @@ production:
|
|
44
46
|
public_host:
|
45
47
|
public_port: 4007
|
46
48
|
local_port: 3000
|
49
|
+
server_alive_interval: 0
|
@@ -10,7 +10,7 @@ module Facebooker
|
|
10
10
|
include Model
|
11
11
|
attr_accessor :message, :time, :status_id
|
12
12
|
end
|
13
|
-
FIELDS = [:status, :political, :pic_small, :name, :quotes, :is_app_user, :tv, :profile_update_time, :meeting_sex, :hs_info, :timezone, :relationship_status, :hometown_location, :about_me, :wall_count, :significant_other_id, :pic_big, :music, :uid, :work_history, :sex, :religion, :notes_count, :activities, :pic_square, :movies, :has_added_app, :education_history, :birthday, :first_name, :meeting_for, :last_name, :interests, :current_location, :pic, :books, :affiliations, :locale, :profile_url, :proxied_email, :email_hashes, :allowed_restrictions]
|
13
|
+
FIELDS = [:status, :political, :pic_small, :name, :quotes, :is_app_user, :tv, :profile_update_time, :meeting_sex, :hs_info, :timezone, :relationship_status, :hometown_location, :about_me, :wall_count, :significant_other_id, :pic_big, :music, :uid, :work_history, :sex, :religion, :notes_count, :activities, :pic_square, :movies, :has_added_app, :education_history, :birthday, :first_name, :meeting_for, :last_name, :interests, :current_location, :pic, :books, :affiliations, :locale, :profile_url, :proxied_email, :email_hashes, :allowed_restrictions, :pic_with_logo, :pic_big_with_logo, :pic_small_with_logo, :pic_square_with_logo]
|
14
14
|
STANDARD_FIELDS = [:uid, :first_name, :last_name, :name, :timezone, :birthday, :sex, :affiliations, :locale, :profile_url, :pic_square]
|
15
15
|
populating_attr_accessor *FIELDS
|
16
16
|
attr_reader :affiliations
|
@@ -45,6 +45,27 @@ module Facebooker
|
|
45
45
|
@facebook_params ||= verified_facebook_params
|
46
46
|
end
|
47
47
|
|
48
|
+
# Redirects the top window to the given url if the content is in an iframe, otherwise performs
|
49
|
+
# a normal redirect_to call.
|
50
|
+
def top_redirect_to(*args)
|
51
|
+
if request_is_facebook_iframe?
|
52
|
+
@redirect_url = url_for(*args)
|
53
|
+
render :layout => false, :inline => <<-HTML
|
54
|
+
<html><head>
|
55
|
+
<script type="text/javascript">
|
56
|
+
window.top.location.href = <%= @redirect_url.to_json -%>;
|
57
|
+
</script>
|
58
|
+
<noscript>
|
59
|
+
<meta http-equiv="refresh" content="0;url=<%=h @redirect_url %>" />
|
60
|
+
<meta http-equiv="window-target" content="_top" />
|
61
|
+
</noscript>
|
62
|
+
</head></html>
|
63
|
+
HTML
|
64
|
+
else
|
65
|
+
redirect_to(*args)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
48
69
|
def redirect_to(*args)
|
49
70
|
if request_is_for_a_facebook_canvas? and !request_is_facebook_tab?
|
50
71
|
render :text => fbml_redirect_tag(*args)
|
@@ -140,7 +161,7 @@ module Facebooker
|
|
140
161
|
def create_new_facebook_session_and_redirect!
|
141
162
|
session[:facebook_session] = new_facebook_session
|
142
163
|
url_params = after_facebook_login_url.nil? ? {} : {:next=>after_facebook_login_url}
|
143
|
-
|
164
|
+
top_redirect_to session[:facebook_session].login_url(url_params) unless @installation_required
|
144
165
|
false
|
145
166
|
end
|
146
167
|
|
@@ -218,6 +239,10 @@ module Facebooker
|
|
218
239
|
!params["fb_sig_in_profile_tab"].blank?
|
219
240
|
end
|
220
241
|
|
242
|
+
def request_is_facebook_iframe?
|
243
|
+
!params["fb_sig_in_iframe"].blank?
|
244
|
+
end
|
245
|
+
|
221
246
|
def request_is_facebook_ajax?
|
222
247
|
params["fb_sig_is_mockajax"]=="1" || params["fb_sig_is_ajax"]=="1" || params["fb_sig_is_ajax"]==true || params["fb_sig_is_mockajax"]==true
|
223
248
|
end
|
@@ -245,7 +270,7 @@ module Facebooker
|
|
245
270
|
end
|
246
271
|
|
247
272
|
def application_needs_permission(perm)
|
248
|
-
|
273
|
+
top_redirect_to(facebook_session.permission_url(perm))
|
249
274
|
end
|
250
275
|
|
251
276
|
def has_extended_permission?(perm)
|
@@ -265,13 +290,13 @@ module Facebooker
|
|
265
290
|
|
266
291
|
def application_is_not_installed_by_facebook_user
|
267
292
|
url_params = after_facebook_login_url.nil? ? {} : { :next => after_facebook_login_url }
|
268
|
-
|
293
|
+
top_redirect_to session[:facebook_session].install_url(url_params)
|
269
294
|
end
|
270
295
|
|
271
296
|
def set_facebook_request_format
|
272
297
|
if request_is_facebook_ajax?
|
273
298
|
request.format = :fbjs
|
274
|
-
elsif request_comes_from_facebook?
|
299
|
+
elsif request_comes_from_facebook? && !request_is_facebook_iframe?
|
275
300
|
request.format = :fbml
|
276
301
|
end
|
277
302
|
end
|
@@ -16,10 +16,19 @@ module Facebooker
|
|
16
16
|
if block_given?
|
17
17
|
additions = capture(&proc)
|
18
18
|
end
|
19
|
+
|
20
|
+
options = {:js => :prototype}
|
21
|
+
if required_features.last.is_a?(Hash)
|
22
|
+
options.merge!(required_features.pop.symbolize_keys)
|
23
|
+
end
|
24
|
+
|
19
25
|
init_string = "FB.Facebook.init('#{Facebooker.api_key}','/xd_receiver.html');"
|
20
26
|
unless required_features.blank?
|
21
27
|
init_string = <<-FBML
|
22
|
-
|
28
|
+
#{case options[:js]
|
29
|
+
when :jquery then "$(document).ready("
|
30
|
+
else "Element.observe(window,'load',"
|
31
|
+
end} function() {
|
23
32
|
FB_RequireFeatures(#{required_features.to_json}, function() {
|
24
33
|
#{init_string}
|
25
34
|
#{additions}
|
@@ -27,8 +36,8 @@ module Facebooker
|
|
27
36
|
});
|
28
37
|
FBML
|
29
38
|
end
|
30
|
-
if block_given?
|
31
|
-
concat
|
39
|
+
if block_given? && block_is_within_action_view?(proc)
|
40
|
+
concat(javascript_tag(init_string), proc.binding)
|
32
41
|
else
|
33
42
|
javascript_tag init_string
|
34
43
|
end
|
@@ -44,6 +44,13 @@ module Facebooker
|
|
44
44
|
|
45
45
|
FB_DIALOG_BUTTON_VALID_OPTION_KEYS = [:close_dialog, :href, :form_id, :clickrewriteurl, :clickrewriteid, :clickrewriteform]
|
46
46
|
|
47
|
+
def fb_show_feed_dialog(action, user_message = "", prompt = "", callback = nil)
|
48
|
+
update_page do |page|
|
49
|
+
page.call "Facebook.showFeedDialog",action.template_id,action.data,action.body_general,action.target_ids,callback,prompt,user_message
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
47
54
|
# Create an fb:request-form without a selector
|
48
55
|
#
|
49
56
|
# The block passed to this tag is used as the content of the form
|
@@ -430,6 +430,7 @@ module Facebooker
|
|
430
430
|
include ActionView::Helpers::FormHelper
|
431
431
|
include ActionView::Helpers::FormTagHelper
|
432
432
|
include ActionView::Helpers::AssetTagHelper
|
433
|
+
include ActionView::Helpers::NumberHelper
|
433
434
|
include Facebooker::Rails::Helpers
|
434
435
|
|
435
436
|
#define this for the publisher views
|
data/lib/facebooker/version.rb
CHANGED
data/lib/tasks/tunnel.rake
CHANGED
@@ -19,8 +19,7 @@ namespace :facebooker do
|
|
19
19
|
# Adapted from Evan Weaver: http://blog.evanweaver.com/articles/2007/07/13/developing-a-facebook-app-locally/
|
20
20
|
desc "Check if reverse tunnel is running"
|
21
21
|
task :status => [ :environment, :config ] do
|
22
|
-
if `ssh #{@public_host} -l #{@public_host_username} netstat -an |
|
23
|
-
egrep "tcp.*:#{@public_port}.*LISTEN" | wc`.to_i > 0
|
22
|
+
if `ssh #{@public_host} -l #{@public_host_username} netstat -an | egrep "tcp.*:#{@public_port}.*LISTEN" | wc`.to_i > 0
|
24
23
|
puts "Seems ok"
|
25
24
|
else
|
26
25
|
puts "Down"
|
@@ -35,10 +34,11 @@ namespace :facebooker do
|
|
35
34
|
@public_port = FACEBOOKER['tunnel']['public_port']
|
36
35
|
@local_port = FACEBOOKER['tunnel']['local_port']
|
37
36
|
@ssh_port = FACEBOOKER['tunnel']['ssh_port'] || 22
|
37
|
+
@server_alive_interval = FACEBOOKER['tunnel']['server_alive_interval'] || 0
|
38
38
|
@notification = "Starting tunnel #{@public_host}:#{@public_port} to 0.0.0.0:#{@local_port}"
|
39
39
|
@notification << " using SSH port #{@ssh_port}" unless @ssh_port == 22
|
40
40
|
# "GatewayPorts yes" needs to be enabled in the remote's sshd config
|
41
|
-
@ssh_command =
|
41
|
+
@ssh_command = %Q[ssh -v -p #{@ssh_port} -nNT4 -o "ServerAliveInterval #{@server_alive_interval}" -R *:#{@public_port}:localhost:#{@local_port} #{@public_host_username}@#{@public_host}]
|
42
42
|
end
|
43
43
|
end
|
44
44
|
desc "Create a reverse ssh tunnel from a public server to a private development server."
|
@@ -437,6 +437,15 @@ class RailsIntegrationTest < Test::Unit::TestCase
|
|
437
437
|
assert_equal("<fb:redirect url=\"http://www.facebook.com/login.php?api_key=1234567&v=1.0\" />", @response.body)
|
438
438
|
end
|
439
439
|
|
440
|
+
def test_redirect_to_renders_javascript_redirect_if_request_is_for_a_facebook_iframe
|
441
|
+
get :index, facebook_params(:fb_sig_user => nil, :fb_sig_in_iframe => 1)
|
442
|
+
assert_response :success
|
443
|
+
assert_match "javascript", @response.body
|
444
|
+
assert_match "http-equiv", @response.body
|
445
|
+
assert_match "http://www.facebook.com/login.php?api_key=1234567&v=1.0".to_json, @response.body
|
446
|
+
assert_match "http://www.facebook.com/login.php?api_key=1234567&v=1.0", @response.body
|
447
|
+
end
|
448
|
+
|
440
449
|
def test_url_for_links_to_canvas_if_canvas_is_true_and_not_in_canvas
|
441
450
|
get :link_test, facebook_params(:fb_sig_in_canvas=>0,:canvas=>true)
|
442
451
|
assert_match /apps.facebook.com/,@response.body
|
@@ -966,6 +975,20 @@ class RailsHelperTest < Test::Unit::TestCase
|
|
966
975
|
end
|
967
976
|
assert @h.output_buffer =~ /Body Content/
|
968
977
|
end
|
978
|
+
|
979
|
+
def test_init_fb_connect_no_options
|
980
|
+
assert ! @h.init_fb_connect.match(/Element.observe\(window,'load',/)
|
981
|
+
end
|
982
|
+
|
983
|
+
def test_init_fb_connect_with_options_js_jquery
|
984
|
+
assert ! @h.init_fb_connect(:js => :jquery).match(/\$\(document\).ready\(/)
|
985
|
+
end
|
986
|
+
|
987
|
+
def test_init_fb_connect_with_features_and_options_js_jquery
|
988
|
+
assert @h.init_fb_connect("XFBML", :js => :jquery).match(/XFBML.*/)
|
989
|
+
assert @h.init_fb_connect("XFBML", :js => :jquery).match(/\$\(document\).ready\(/)
|
990
|
+
end
|
991
|
+
|
969
992
|
|
970
993
|
def test_fb_login_and_redirect
|
971
994
|
assert_equal @h.fb_login_and_redirect("/path"),"<fb:login-button onlogin=\"window.location.href = "/path";\"></fb:login-button>"
|
@@ -1327,4 +1350,9 @@ class RailsRequestFormatTest < Test::Unit::TestCase
|
|
1327
1350
|
assert_equal 'fbjs', @response.body
|
1328
1351
|
end
|
1329
1352
|
|
1353
|
+
def test_responds_to_html_when_iframe
|
1354
|
+
get :index, facebook_params(:fb_sig_in_iframe => '1')
|
1355
|
+
assert_equal 'html', @response.body
|
1356
|
+
end
|
1357
|
+
|
1330
1358
|
end
|
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.
|
4
|
+
version: 1.0.29
|
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-04-
|
16
|
+
date: 2009-04-21 00:00:00 -07:00
|
17
17
|
default_executable:
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|