taweili-facebooker 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.autotest +15 -0
- data/CHANGELOG.rdoc +24 -0
- data/COPYING.rdoc +19 -0
- data/Manifest.txt +133 -0
- data/README.rdoc +104 -0
- data/Rakefile +85 -0
- data/TODO.rdoc +4 -0
- data/examples/desktop_login.rb +14 -0
- data/facebooker.gemspec +38 -0
- data/generators/facebook/facebook_generator.rb +14 -0
- data/generators/facebook/templates/config/facebooker.yml +49 -0
- data/generators/facebook/templates/public/javascripts/facebooker.js +83 -0
- data/generators/facebook_controller/USAGE +33 -0
- data/generators/facebook_controller/facebook_controller_generator.rb +40 -0
- data/generators/facebook_controller/templates/controller.rb +7 -0
- data/generators/facebook_controller/templates/functional_test.rb +11 -0
- data/generators/facebook_controller/templates/helper.rb +2 -0
- data/generators/facebook_controller/templates/view.fbml.erb +2 -0
- data/generators/facebook_controller/templates/view.html.erb +2 -0
- data/generators/facebook_publisher/facebook_publisher_generator.rb +14 -0
- data/generators/facebook_publisher/templates/create_facebook_templates.rb +15 -0
- data/generators/facebook_publisher/templates/publisher.rb +3 -0
- data/generators/facebook_scaffold/USAGE +27 -0
- data/generators/facebook_scaffold/facebook_scaffold_generator.rb +118 -0
- data/generators/facebook_scaffold/templates/controller.rb +93 -0
- data/generators/facebook_scaffold/templates/facebook_style.css +2579 -0
- data/generators/facebook_scaffold/templates/functional_test.rb +89 -0
- data/generators/facebook_scaffold/templates/helper.rb +2 -0
- data/generators/facebook_scaffold/templates/layout.fbml.erb +6 -0
- data/generators/facebook_scaffold/templates/layout.html.erb +17 -0
- data/generators/facebook_scaffold/templates/style.css +74 -0
- data/generators/facebook_scaffold/templates/view_edit.fbml.erb +13 -0
- data/generators/facebook_scaffold/templates/view_edit.html.erb +18 -0
- data/generators/facebook_scaffold/templates/view_index.fbml.erb +24 -0
- data/generators/facebook_scaffold/templates/view_index.html.erb +24 -0
- data/generators/facebook_scaffold/templates/view_new.fbml.erb +12 -0
- data/generators/facebook_scaffold/templates/view_new.html.erb +17 -0
- data/generators/facebook_scaffold/templates/view_show.fbml.erb +10 -0
- data/generators/facebook_scaffold/templates/view_show.html.erb +10 -0
- data/generators/publisher/publisher_generator.rb +14 -0
- data/generators/xd_receiver/templates/xd_receiver.html +10 -0
- data/generators/xd_receiver/xd_receiver_generator.rb +10 -0
- data/init.rb +25 -0
- data/install.rb +12 -0
- data/lib/facebooker/adapters/adapter_base.rb +91 -0
- data/lib/facebooker/adapters/bebo_adapter.rb +77 -0
- data/lib/facebooker/adapters/facebook_adapter.rb +52 -0
- data/lib/facebooker/admin.rb +42 -0
- data/lib/facebooker/batch_request.rb +45 -0
- data/lib/facebooker/data.rb +57 -0
- data/lib/facebooker/feed.rb +78 -0
- data/lib/facebooker/logging.rb +44 -0
- data/lib/facebooker/mobile.rb +20 -0
- data/lib/facebooker/mock/service.rb +50 -0
- data/lib/facebooker/mock/session.rb +18 -0
- data/lib/facebooker/model.rb +139 -0
- data/lib/facebooker/models/affiliation.rb +10 -0
- data/lib/facebooker/models/album.rb +11 -0
- data/lib/facebooker/models/applicationproperties.rb +39 -0
- data/lib/facebooker/models/applicationrestrictions.rb +10 -0
- data/lib/facebooker/models/cookie.rb +10 -0
- data/lib/facebooker/models/education_info.rb +11 -0
- data/lib/facebooker/models/event.rb +28 -0
- data/lib/facebooker/models/friend_list.rb +16 -0
- data/lib/facebooker/models/group.rb +36 -0
- data/lib/facebooker/models/info_item.rb +10 -0
- data/lib/facebooker/models/info_section.rb +10 -0
- data/lib/facebooker/models/location.rb +8 -0
- data/lib/facebooker/models/notifications.rb +17 -0
- data/lib/facebooker/models/page.rb +28 -0
- data/lib/facebooker/models/photo.rb +19 -0
- data/lib/facebooker/models/tag.rb +12 -0
- data/lib/facebooker/models/user.rb +497 -0
- data/lib/facebooker/models/video.rb +9 -0
- data/lib/facebooker/models/work_info.rb +10 -0
- data/lib/facebooker/parser.rb +650 -0
- data/lib/facebooker/rails/backwards_compatible_param_checks.rb +31 -0
- data/lib/facebooker/rails/controller.rb +337 -0
- data/lib/facebooker/rails/cucumber/world.rb +46 -0
- data/lib/facebooker/rails/cucumber.rb +28 -0
- data/lib/facebooker/rails/extensions/action_controller.rb +48 -0
- data/lib/facebooker/rails/extensions/rack_setup.rb +6 -0
- data/lib/facebooker/rails/extensions/routing.rb +15 -0
- data/lib/facebooker/rails/facebook_form_builder.rb +112 -0
- data/lib/facebooker/rails/facebook_pretty_errors.rb +22 -0
- data/lib/facebooker/rails/facebook_request_fix.rb +30 -0
- data/lib/facebooker/rails/facebook_request_fix_2-3.rb +31 -0
- data/lib/facebooker/rails/facebook_session_handling.rb +68 -0
- data/lib/facebooker/rails/facebook_url_helper.rb +192 -0
- data/lib/facebooker/rails/facebook_url_rewriting.rb +60 -0
- data/lib/facebooker/rails/helpers/fb_connect.rb +118 -0
- data/lib/facebooker/rails/helpers.rb +780 -0
- data/lib/facebooker/rails/integration_session.rb +38 -0
- data/lib/facebooker/rails/profile_publisher_extensions.rb +42 -0
- data/lib/facebooker/rails/publisher.rb +554 -0
- data/lib/facebooker/rails/routing.rb +49 -0
- data/lib/facebooker/rails/test_helpers.rb +68 -0
- data/lib/facebooker/rails/utilities.rb +22 -0
- data/lib/facebooker/server_cache.rb +24 -0
- data/lib/facebooker/service.rb +102 -0
- data/lib/facebooker/session.rb +606 -0
- data/lib/facebooker/version.rb +9 -0
- data/lib/facebooker.rb +180 -0
- data/lib/net/http_multipart_post.rb +123 -0
- data/lib/rack/facebook.rb +77 -0
- data/lib/tasks/facebooker.rake +18 -0
- data/lib/tasks/tunnel.rake +46 -0
- data/rails/init.rb +1 -0
- data/setup.rb +1585 -0
- data/templates/layout.erb +24 -0
- data/test/facebooker/adapters_test.rb +96 -0
- data/test/facebooker/admin_test.rb +102 -0
- data/test/facebooker/batch_request_test.rb +83 -0
- data/test/facebooker/data_test.rb +86 -0
- data/test/facebooker/logging_test.rb +43 -0
- data/test/facebooker/mobile_test.rb +45 -0
- data/test/facebooker/model_test.rb +133 -0
- data/test/facebooker/models/event_test.rb +15 -0
- data/test/facebooker/models/photo_test.rb +16 -0
- data/test/facebooker/models/user_test.rb +343 -0
- data/test/facebooker/rails/facebook_request_fix_2-3_test.rb +24 -0
- data/test/facebooker/rails/facebook_url_rewriting_test.rb +39 -0
- data/test/facebooker/rails/publisher_test.rb +481 -0
- data/test/facebooker/rails_integration_test.rb +1398 -0
- data/test/facebooker/server_cache_test.rb +44 -0
- data/test/facebooker/session_test.rb +614 -0
- data/test/facebooker_test.rb +951 -0
- data/test/fixtures/multipart_post_body_with_only_parameters.txt +33 -0
- data/test/fixtures/multipart_post_body_with_single_file.txt +38 -0
- data/test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt +38 -0
- data/test/net/http_multipart_post_test.rb +52 -0
- data/test/rack/facebook_test.rb +61 -0
- data/test/rails_test_helper.rb +27 -0
- data/test/test_helper.rb +74 -0
- metadata +232 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require File.dirname(__FILE__)+'/../../vendor/plugins/facebooker/lib/facebooker/rails/test_helpers.rb'
|
3
|
+
|
4
|
+
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
|
5
|
+
include Facebooker::Rails::TestHelpers
|
6
|
+
def test_should_get_index_for_facebook
|
7
|
+
facebook_get :index
|
8
|
+
assert_response :success
|
9
|
+
assert_not_nil assigns(:<%= table_name %>)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_should_get_new_for_facebook
|
13
|
+
facebook_get :new
|
14
|
+
assert_response :success
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_create_<%= file_name %>_for_facebook
|
18
|
+
assert_difference('<%= class_name %>.count') do
|
19
|
+
facebook_post :create, :<%= file_name %> => { }
|
20
|
+
end
|
21
|
+
|
22
|
+
assert_facebook_redirect_to <%= file_name %>_path(assigns(:<%= file_name %>))
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_should_show_<%= file_name %>_for_facebook
|
26
|
+
facebook_get :show, :id => <%= table_name %>(:one).id
|
27
|
+
assert_response :success
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_should_get_edit_for_facebook
|
31
|
+
facebook_get :edit, :id => <%= table_name %>(:one).id
|
32
|
+
assert_response :success
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_should_update_<%= file_name %>_for_facebook
|
36
|
+
facebook_put :update, :id => <%= table_name %>(:one).id, :<%= file_name %> => { }
|
37
|
+
assert_facebook_redirect_to <%= file_name %>_path(assigns(:<%= file_name %>))
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_should_destroy_<%= file_name %>_for_facebook
|
41
|
+
assert_difference('<%= class_name %>.count', -1) do
|
42
|
+
facebook_delete :destroy, :id => <%= table_name %>(:one).id
|
43
|
+
end
|
44
|
+
|
45
|
+
assert_facebook_redirect_to <%= table_name %>_path
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_should_get_index
|
49
|
+
get :index
|
50
|
+
assert_response :success
|
51
|
+
assert_not_nil assigns(:<%= table_name %>)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_should_get_new
|
55
|
+
get :new
|
56
|
+
assert_response :success
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_should_create_<%= file_name %>
|
60
|
+
assert_difference('<%= class_name %>.count') do
|
61
|
+
post :create, :<%= file_name %> => { }
|
62
|
+
end
|
63
|
+
|
64
|
+
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_should_show_<%= file_name %>
|
68
|
+
get :show, :id => <%= table_name %>(:one).id
|
69
|
+
assert_response :success
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_should_get_edit
|
73
|
+
get :edit, :id => <%= table_name %>(:one).id
|
74
|
+
assert_response :success
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_should_update_<%= file_name %>
|
78
|
+
put :update, :id => <%= table_name %>(:one).id, :<%= file_name %> => { }
|
79
|
+
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_should_destroy_<%= file_name %>
|
83
|
+
assert_difference('<%= class_name %>.count', -1) do
|
84
|
+
delete :destroy, :id => <%= table_name %>(:one).id
|
85
|
+
end
|
86
|
+
|
87
|
+
assert_redirected_to <%= table_name %>_path
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
7
|
+
<title><%= controller_class_name %>: <%%= controller.action_name %></title>
|
8
|
+
<%%= stylesheet_link_tag 'scaffold' %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
|
12
|
+
<p style="color: green"><%%= flash[:notice] %></p>
|
13
|
+
|
14
|
+
<%%= yield %>
|
15
|
+
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,74 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
.fieldWithErrors {
|
20
|
+
padding: 2px;
|
21
|
+
background-color: red;
|
22
|
+
display: table;
|
23
|
+
}
|
24
|
+
|
25
|
+
#errorExplanation {
|
26
|
+
width: 400px;
|
27
|
+
border: 2px solid red;
|
28
|
+
padding: 7px;
|
29
|
+
padding-bottom: 12px;
|
30
|
+
margin-bottom: 20px;
|
31
|
+
background-color: #f0f0f0;
|
32
|
+
}
|
33
|
+
|
34
|
+
#errorExplanation h2 {
|
35
|
+
text-align: left;
|
36
|
+
font-weight: bold;
|
37
|
+
padding: 5px 5px 5px 15px;
|
38
|
+
font-size: 12px;
|
39
|
+
margin: -7px;
|
40
|
+
background-color: #c00;
|
41
|
+
color: #fff;
|
42
|
+
}
|
43
|
+
|
44
|
+
#errorExplanation p {
|
45
|
+
color: #333;
|
46
|
+
margin-bottom: 0;
|
47
|
+
padding: 5px;
|
48
|
+
}
|
49
|
+
|
50
|
+
#errorExplanation ul li {
|
51
|
+
font-size: 12px;
|
52
|
+
list-style: square;
|
53
|
+
}
|
54
|
+
|
55
|
+
div.uploadStatus {
|
56
|
+
margin: 5px;
|
57
|
+
}
|
58
|
+
|
59
|
+
div.progressBar {
|
60
|
+
margin: 5px;
|
61
|
+
}
|
62
|
+
|
63
|
+
div.progressBar div.border {
|
64
|
+
background-color: #fff;
|
65
|
+
border: 1px solid gray;
|
66
|
+
width: 100%;
|
67
|
+
}
|
68
|
+
|
69
|
+
div.progressBar div.background {
|
70
|
+
background-color: #333;
|
71
|
+
height: 18px;
|
72
|
+
width: 0%;
|
73
|
+
}
|
74
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<h1>Editing <%= singular_name %></h1>
|
2
|
+
|
3
|
+
<%% facebook_form_for(@<%= singular_name %>) do |f| %>
|
4
|
+
<%%= f.error_messages %>
|
5
|
+
|
6
|
+
<% for attribute in attributes -%>
|
7
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
8
|
+
<% end -%>
|
9
|
+
<%%= f.buttons "Update" %>
|
10
|
+
<%% end %>
|
11
|
+
|
12
|
+
<%%= link_to 'Show', @<%= singular_name %> %> |
|
13
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<h1>Editing <%= singular_name %></h1>
|
2
|
+
|
3
|
+
<%% form_for(@<%= singular_name %>) do |f| %>
|
4
|
+
<%%= f.error_messages %>
|
5
|
+
|
6
|
+
<% for attribute in attributes -%>
|
7
|
+
<p>
|
8
|
+
<%%= f.label :<%= attribute.name %> %><br />
|
9
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
10
|
+
</p>
|
11
|
+
<% end -%>
|
12
|
+
<p>
|
13
|
+
<%%= f.submit "Update" %>
|
14
|
+
</p>
|
15
|
+
<%% end %>
|
16
|
+
|
17
|
+
<%%= link_to 'Show', @<%= singular_name %> %> |
|
18
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<h1>Listing <%= plural_name %></h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<% for attribute in attributes -%>
|
6
|
+
<th><%= attribute.column.human_name %></th>
|
7
|
+
<% end -%>
|
8
|
+
</tr>
|
9
|
+
|
10
|
+
<%% for <%= singular_name %> in @<%= plural_name %> %>
|
11
|
+
<tr>
|
12
|
+
<% for attribute in attributes -%>
|
13
|
+
<td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
|
14
|
+
<% end -%>
|
15
|
+
<td><%%= link_to 'Show', <%= singular_name %> %></td>
|
16
|
+
<td><%%= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) %></td>
|
17
|
+
<td><%%= button_to 'Destroy', <%= singular_name %>, :method => :delete %></td>
|
18
|
+
</tr>
|
19
|
+
<%% end %>
|
20
|
+
</table>
|
21
|
+
|
22
|
+
<br />
|
23
|
+
|
24
|
+
<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<h1>Listing <%= plural_name %></h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<% for attribute in attributes -%>
|
6
|
+
<th><%= attribute.column.human_name %></th>
|
7
|
+
<% end -%>
|
8
|
+
</tr>
|
9
|
+
|
10
|
+
<%% for <%= singular_name %> in @<%= plural_name %> %>
|
11
|
+
<tr>
|
12
|
+
<% for attribute in attributes -%>
|
13
|
+
<td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
|
14
|
+
<% end -%>
|
15
|
+
<td><%%= link_to 'Show', <%= singular_name %> %></td>
|
16
|
+
<td><%%= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) %></td>
|
17
|
+
<td><%%= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %></td>
|
18
|
+
</tr>
|
19
|
+
<%% end %>
|
20
|
+
</table>
|
21
|
+
|
22
|
+
<br />
|
23
|
+
|
24
|
+
<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<h1>New <%= singular_name %></h1>
|
2
|
+
|
3
|
+
<%% facebook_form_for(@<%= singular_name %>) do |f| %>
|
4
|
+
<%%= f.error_messages %>
|
5
|
+
|
6
|
+
<% for attribute in attributes -%>
|
7
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
8
|
+
<% end -%>
|
9
|
+
<%%= f.buttons "Create" %>
|
10
|
+
<%% end %>
|
11
|
+
|
12
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<h1>New <%= singular_name %></h1>
|
2
|
+
|
3
|
+
<%% form_for(@<%= singular_name %>) do |f| %>
|
4
|
+
<%%= f.error_messages %>
|
5
|
+
|
6
|
+
<% for attribute in attributes -%>
|
7
|
+
<p>
|
8
|
+
<%%= f.label :<%= attribute.name %> %><br />
|
9
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
10
|
+
</p>
|
11
|
+
<% end -%>
|
12
|
+
<p>
|
13
|
+
<%%= f.submit "Create" %>
|
14
|
+
</p>
|
15
|
+
<%% end %>
|
16
|
+
|
17
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% for attribute in attributes -%>
|
2
|
+
<p>
|
3
|
+
<b><%= attribute.column.human_name %>:</b>
|
4
|
+
<%%=h @<%= singular_name %>.<%= attribute.name %> %>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
<%%= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) %> |
|
10
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% for attribute in attributes -%>
|
2
|
+
<p>
|
3
|
+
<b><%= attribute.column.human_name %>:</b>
|
4
|
+
<%%=h @<%= singular_name %>.<%= attribute.name %> %>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
<%%= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) %> |
|
10
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" >
|
4
|
+
<head>
|
5
|
+
<title>Cross-Domain Receiver Page</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.debug.js" type="text/javascript"></script>
|
9
|
+
</body>
|
10
|
+
</html>
|
data/init.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Added support to the Facebooker.yml file for switching to the new profile design..
|
2
|
+
# Config parsing needs to happen before files are required.
|
3
|
+
facebook_config = "#{RAILS_ROOT}/config/facebooker.yml"
|
4
|
+
|
5
|
+
require 'facebooker'
|
6
|
+
FACEBOOKER = Facebooker.load_configuration(facebook_config)
|
7
|
+
|
8
|
+
# enable logger before including everything else, in case we ever want to log initialization
|
9
|
+
Facebooker.logger = RAILS_DEFAULT_LOGGER if Object.const_defined? :RAILS_DEFAULT_LOGGER
|
10
|
+
|
11
|
+
require 'net/http_multipart_post'
|
12
|
+
if defined? Rails
|
13
|
+
require 'facebooker/rails/backwards_compatible_param_checks'
|
14
|
+
require 'facebooker/rails/controller'
|
15
|
+
require 'facebooker/rails/facebook_url_rewriting'
|
16
|
+
require 'facebooker/rails/facebook_session_handling' if Rails.version < '2.3'
|
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'
|
19
|
+
require 'facebooker/rails/routing'
|
20
|
+
require 'facebooker/rails/facebook_pretty_errors' rescue nil
|
21
|
+
require 'facebooker/rails/facebook_url_helper'
|
22
|
+
require 'facebooker/rails/extensions/rack_setup' if Rails.version > '2.3'
|
23
|
+
require 'facebooker/rails/extensions/action_controller'
|
24
|
+
require 'facebooker/rails/extensions/routing'
|
25
|
+
end
|
data/install.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
dir = File.dirname(__FILE__)
|
5
|
+
templates = File.join(dir, 'generators', 'facebook', 'templates')
|
6
|
+
config = File.join('config', 'facebooker.yml')
|
7
|
+
script = File.join('public', 'javascripts', 'facebooker.js')
|
8
|
+
|
9
|
+
[config, script].each do |path|
|
10
|
+
FileUtils.cp File.join(templates, path), File.join(RAILS_ROOT, path) unless File.exist?(File.join(RAILS_ROOT, path))
|
11
|
+
end
|
12
|
+
puts IO.read(File.join(dir, 'README.rdoc'))
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Facebooker
|
2
|
+
|
3
|
+
class AdapterBase
|
4
|
+
class UnableToLoadAdapter < Exception; end
|
5
|
+
require 'active_support/inflector'
|
6
|
+
include ActiveSupport::CoreExtensions::String::Inflections
|
7
|
+
def facebook_path_prefix
|
8
|
+
"/" + (@facebook_path_prefix || canvas_page_name || ENV['FACEBOOK_CANVAS_PATH'] || ENV['FACEBOOKER_RELATIVE_URL_ROOT'])
|
9
|
+
end
|
10
|
+
|
11
|
+
def facebook_path_prefix=(prefix)
|
12
|
+
@facebook_path_prefix = prefix
|
13
|
+
end
|
14
|
+
|
15
|
+
def facebooker_config
|
16
|
+
@config
|
17
|
+
end
|
18
|
+
|
19
|
+
def api_server_base_url
|
20
|
+
"http://" + api_server_base
|
21
|
+
end
|
22
|
+
|
23
|
+
def is_for?(application_context)
|
24
|
+
raise "SubClassShouldDefine"
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(config)
|
28
|
+
@config = config
|
29
|
+
@facebook_path_prefix = nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.facebooker_config
|
33
|
+
Facebooker.facebooker_config
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def self.load_adapter(params)
|
38
|
+
|
39
|
+
config_key_base = params[:config_key_base] # This allows for loading of a aspecific adapter
|
40
|
+
config_key_base += "_" if config_key_base && config_key_base.length > 0
|
41
|
+
|
42
|
+
unless api_key = (params[:fb_sig_api_key] || facebooker_config["#{config_key_base}api_key"])
|
43
|
+
raise Facebooker::AdapterBase::UnableToLoadAdapter
|
44
|
+
end
|
45
|
+
|
46
|
+
unless facebooker_config
|
47
|
+
return self.default_adapter(params)
|
48
|
+
end
|
49
|
+
|
50
|
+
facebooker_config.each do |key,value|
|
51
|
+
next unless value == api_key
|
52
|
+
|
53
|
+
key_base = key.match(/(.*)[_]?api_key/)[1]
|
54
|
+
|
55
|
+
adapter_class_name = if !key_base || key_base.length == 0
|
56
|
+
"FacebookAdapter"
|
57
|
+
else
|
58
|
+
facebooker_config[key_base + "adapter"]
|
59
|
+
end
|
60
|
+
|
61
|
+
adapter_class = "Facebooker::#{adapter_class_name}".constantize
|
62
|
+
|
63
|
+
# Collect the rest of the configuration
|
64
|
+
adapter_config = {}
|
65
|
+
facebooker_config.each do |key,value|
|
66
|
+
if (match = key.match(/#{key_base}[_]?(.*)/))
|
67
|
+
adapter_config[match[1]] = value
|
68
|
+
end
|
69
|
+
end
|
70
|
+
return adapter_class.new(adapter_config)
|
71
|
+
end
|
72
|
+
|
73
|
+
return self.default_adapter(params)
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.default_adapter(params = {})
|
78
|
+
if facebooker_config.nil? || (facebooker_config.blank? rescue nil)
|
79
|
+
config = { "api_key" => ENV['FACEBOOK_API_KEY'], "secret_key" => ENV['FACEBOOK_SECRET_KEY']}
|
80
|
+
else
|
81
|
+
config = facebooker_config
|
82
|
+
end
|
83
|
+
FacebookAdapter.new(config)
|
84
|
+
end
|
85
|
+
|
86
|
+
[:canvas_page_name, :api_key,:secret_key].each do |key_method|
|
87
|
+
define_method(key_method){ return facebooker_config[key_method.to_s]}
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Facebooker
|
2
|
+
class BeboAdapter < AdapterBase
|
3
|
+
|
4
|
+
def canvas_server_base
|
5
|
+
"apps.bebo.com"
|
6
|
+
end
|
7
|
+
|
8
|
+
def api_server_base
|
9
|
+
'apps.bebo.com'
|
10
|
+
end
|
11
|
+
|
12
|
+
def api_rest_path
|
13
|
+
"/restserver.php"
|
14
|
+
end
|
15
|
+
|
16
|
+
def is_for?(application_context)
|
17
|
+
application_context == :bebo
|
18
|
+
end
|
19
|
+
|
20
|
+
def www_server_base_url
|
21
|
+
"www.bebo.com"
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def login_url_base
|
26
|
+
"http://#{www_server_base_url}/SignIn.jsp?ApiKey=#{api_key}&v=1.0"
|
27
|
+
end
|
28
|
+
|
29
|
+
def install_url_base
|
30
|
+
"http://#{www_server_base_url}/c/apps/add?ApiKey=#{api_key}&v=1.0"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Things that don't actually work as expected in BEBO
|
36
|
+
module Facebooker
|
37
|
+
class User
|
38
|
+
def set_profile_fbml_with_bebo_adapter(profile_fbml, mobile_fbml, profile_action_fbml, profile_main = nil)
|
39
|
+
if(Facebooker.is_for?(:bebo))
|
40
|
+
self.session.post('facebook.profile.setFBML', :uid => @id, :markup => profile_fbml)
|
41
|
+
else
|
42
|
+
set_profile_fbml_without_bebo_adapter(profile_fbml,mobile_fbml, profile_action_fbml, profile_main)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
alias_method :set_profile_fbml_without_bebo_adapter, :set_profile_fbml
|
46
|
+
alias_method :set_profile_fbml, :set_profile_fbml_with_bebo_adapter
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
BEBO_FIELDS = FIELDS - [:meeting_sex, :wall_count, :meeting_for]
|
51
|
+
|
52
|
+
remove_method :collect
|
53
|
+
|
54
|
+
def collect(fields)
|
55
|
+
if(Facebooker.is_for?(:bebo) )
|
56
|
+
BEBO_FIELDS.reject{|field_name| !fields.empty? && !fields.include?(field_name)}.join(',')
|
57
|
+
else
|
58
|
+
FIELDS.reject{|field_name| !fields.empty? && !fields.include?(field_name)}.join(',')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
class PublishTemplatizedAction < Parser#:nodoc:
|
65
|
+
class <<self
|
66
|
+
def process_with_bebo_adapter(data)
|
67
|
+
if(Facebooker.is_for?(:bebo))
|
68
|
+
element('feed_publishTemplatizedAction_response', data).content
|
69
|
+
else
|
70
|
+
process_without_bebo_adapter(data)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
alias_method :process_without_bebo_adapter, :process
|
74
|
+
alias_method :process, :process_with_bebo_adapter
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Facebooker
|
2
|
+
|
3
|
+
|
4
|
+
class FacebookAdapter < AdapterBase
|
5
|
+
|
6
|
+
def canvas_server_base
|
7
|
+
"apps.facebook.com"
|
8
|
+
end
|
9
|
+
|
10
|
+
def api_server_base
|
11
|
+
"api.facebook.com"
|
12
|
+
end
|
13
|
+
|
14
|
+
def video_server_base
|
15
|
+
"api-video.facebook.com"
|
16
|
+
end
|
17
|
+
|
18
|
+
def www_server_base_url
|
19
|
+
"www.facebook.com"
|
20
|
+
end
|
21
|
+
|
22
|
+
def api_rest_path
|
23
|
+
"/restserver.php"
|
24
|
+
end
|
25
|
+
|
26
|
+
def api_key
|
27
|
+
ENV['FACEBOOK_API_KEY'] || super
|
28
|
+
end
|
29
|
+
|
30
|
+
def secret_key
|
31
|
+
ENV['FACEBOOK_SECRET_KEY'] || super
|
32
|
+
end
|
33
|
+
|
34
|
+
def is_for?(application_context)
|
35
|
+
application_context == :facebook
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
def login_url_base
|
41
|
+
"http://#{www_server_base_url}/login.php?api_key=#{api_key}&v=1.0"
|
42
|
+
end
|
43
|
+
|
44
|
+
def install_url_base
|
45
|
+
"http://#{www_server_base_url}/install.php?api_key=#{api_key}&v=1.0"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Facebooker
|
2
|
+
class Admin
|
3
|
+
def initialize(session)
|
4
|
+
@session = session
|
5
|
+
end
|
6
|
+
|
7
|
+
# ** BETA ***
|
8
|
+
# +properties+: Hash of properties you want to set
|
9
|
+
def set_app_properties(properties)
|
10
|
+
properties = properties.respond_to?(:to_json) ? properties.to_json : properties
|
11
|
+
(@session.post 'facebook.admin.setAppProperties', :properties => properties) == '1'
|
12
|
+
end
|
13
|
+
|
14
|
+
# ** BETA ***
|
15
|
+
# +properties+: Hash of properties you want to view.
|
16
|
+
def get_app_properties(*properties)
|
17
|
+
json = @session.post('facebook.admin.getAppProperties', :properties => properties.to_json)
|
18
|
+
hash = Facebooker.json_decode(CGI.unescapeHTML(json))
|
19
|
+
@properties = ApplicationProperties.from_hash(hash)
|
20
|
+
end
|
21
|
+
|
22
|
+
# ** BETA ***
|
23
|
+
# +restrictions+: Hash of restrictions you want to set.
|
24
|
+
def set_restriction_info(restrictions)
|
25
|
+
restrictions = restrictions.respond_to?(:to_json) ? restrictions.to_json : restrictions
|
26
|
+
(@session.post 'facebook.admin.setRestrictionInfo', :restriction_str => restrictions) == '1'
|
27
|
+
end
|
28
|
+
|
29
|
+
# ** BETA ***
|
30
|
+
def get_restriction_info(*restrictions)
|
31
|
+
json = @session.post('facebook.admin.getRestrictionInfo')
|
32
|
+
hash = Facebooker.json_decode(CGI.unescapeHTML(json))
|
33
|
+
@restrictions = ApplicationRestrictions.from_hash(hash)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Integration points include..
|
37
|
+
# :notifications_per_day, :requests_per_day, :emails_per_day, :email_disable_message_location
|
38
|
+
def get_allocation(integration_point)
|
39
|
+
@session.post('facebook.admin.getAllocation', :integration_point_name => integration_point.to_s).to_i
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|