fotonauts-facebooker 1.0.67

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. data/.autotest +15 -0
  2. data/CHANGELOG.rdoc +24 -0
  3. data/COPYING.rdoc +19 -0
  4. data/Manifest.txt +152 -0
  5. data/README.rdoc +119 -0
  6. data/Rakefile +94 -0
  7. data/TODO.rdoc +4 -0
  8. data/examples/desktop_login.rb +14 -0
  9. data/facebooker.gemspec +45 -0
  10. data/generators/facebook/facebook_generator.rb +14 -0
  11. data/generators/facebook/templates/config/facebooker.yml +49 -0
  12. data/generators/facebook/templates/public/javascripts/facebooker.js +332 -0
  13. data/generators/facebook_controller/USAGE +33 -0
  14. data/generators/facebook_controller/facebook_controller_generator.rb +40 -0
  15. data/generators/facebook_controller/templates/controller.rb +7 -0
  16. data/generators/facebook_controller/templates/functional_test.rb +11 -0
  17. data/generators/facebook_controller/templates/helper.rb +2 -0
  18. data/generators/facebook_controller/templates/view.fbml.erb +2 -0
  19. data/generators/facebook_controller/templates/view.html.erb +2 -0
  20. data/generators/facebook_publisher/facebook_publisher_generator.rb +14 -0
  21. data/generators/facebook_publisher/templates/create_facebook_templates.rb +15 -0
  22. data/generators/facebook_publisher/templates/publisher.rb +3 -0
  23. data/generators/facebook_scaffold/USAGE +27 -0
  24. data/generators/facebook_scaffold/facebook_scaffold_generator.rb +118 -0
  25. data/generators/facebook_scaffold/templates/controller.rb +93 -0
  26. data/generators/facebook_scaffold/templates/facebook_style.css +2579 -0
  27. data/generators/facebook_scaffold/templates/functional_test.rb +89 -0
  28. data/generators/facebook_scaffold/templates/helper.rb +2 -0
  29. data/generators/facebook_scaffold/templates/layout.fbml.erb +6 -0
  30. data/generators/facebook_scaffold/templates/layout.html.erb +17 -0
  31. data/generators/facebook_scaffold/templates/style.css +74 -0
  32. data/generators/facebook_scaffold/templates/view_edit.fbml.erb +13 -0
  33. data/generators/facebook_scaffold/templates/view_edit.html.erb +18 -0
  34. data/generators/facebook_scaffold/templates/view_index.fbml.erb +24 -0
  35. data/generators/facebook_scaffold/templates/view_index.html.erb +24 -0
  36. data/generators/facebook_scaffold/templates/view_new.fbml.erb +12 -0
  37. data/generators/facebook_scaffold/templates/view_new.html.erb +17 -0
  38. data/generators/facebook_scaffold/templates/view_show.fbml.erb +10 -0
  39. data/generators/facebook_scaffold/templates/view_show.html.erb +10 -0
  40. data/generators/publisher/publisher_generator.rb +14 -0
  41. data/generators/xd_receiver/templates/xd_receiver.html +10 -0
  42. data/generators/xd_receiver/templates/xd_receiver_ssl.html +10 -0
  43. data/generators/xd_receiver/xd_receiver_generator.rb +10 -0
  44. data/init.rb +26 -0
  45. data/install.rb +12 -0
  46. data/lib/facebooker.rb +275 -0
  47. data/lib/facebooker/adapters/adapter_base.rb +91 -0
  48. data/lib/facebooker/adapters/bebo_adapter.rb +77 -0
  49. data/lib/facebooker/adapters/facebook_adapter.rb +60 -0
  50. data/lib/facebooker/admin.rb +42 -0
  51. data/lib/facebooker/application.rb +37 -0
  52. data/lib/facebooker/attachment.rb +51 -0
  53. data/lib/facebooker/batch_request.rb +45 -0
  54. data/lib/facebooker/data.rb +57 -0
  55. data/lib/facebooker/feed.rb +78 -0
  56. data/lib/facebooker/logging.rb +44 -0
  57. data/lib/facebooker/mobile.rb +20 -0
  58. data/lib/facebooker/mock/service.rb +50 -0
  59. data/lib/facebooker/mock/session.rb +18 -0
  60. data/lib/facebooker/model.rb +139 -0
  61. data/lib/facebooker/models/affiliation.rb +10 -0
  62. data/lib/facebooker/models/album.rb +11 -0
  63. data/lib/facebooker/models/applicationproperties.rb +39 -0
  64. data/lib/facebooker/models/applicationrestrictions.rb +10 -0
  65. data/lib/facebooker/models/comment.rb +9 -0
  66. data/lib/facebooker/models/cookie.rb +10 -0
  67. data/lib/facebooker/models/education_info.rb +11 -0
  68. data/lib/facebooker/models/event.rb +28 -0
  69. data/lib/facebooker/models/family_relative_info.rb +7 -0
  70. data/lib/facebooker/models/friend_list.rb +16 -0
  71. data/lib/facebooker/models/group.rb +36 -0
  72. data/lib/facebooker/models/info_item.rb +10 -0
  73. data/lib/facebooker/models/info_section.rb +10 -0
  74. data/lib/facebooker/models/location.rb +8 -0
  75. data/lib/facebooker/models/message_thread.rb +89 -0
  76. data/lib/facebooker/models/notifications.rb +17 -0
  77. data/lib/facebooker/models/page.rb +46 -0
  78. data/lib/facebooker/models/photo.rb +19 -0
  79. data/lib/facebooker/models/tag.rb +12 -0
  80. data/lib/facebooker/models/user.rb +751 -0
  81. data/lib/facebooker/models/video.rb +9 -0
  82. data/lib/facebooker/models/work_info.rb +10 -0
  83. data/lib/facebooker/parser.rb +970 -0
  84. data/lib/facebooker/rails/backwards_compatible_param_checks.rb +31 -0
  85. data/lib/facebooker/rails/controller.rb +353 -0
  86. data/lib/facebooker/rails/cucumber.rb +28 -0
  87. data/lib/facebooker/rails/cucumber/world.rb +40 -0
  88. data/lib/facebooker/rails/extensions/action_controller.rb +48 -0
  89. data/lib/facebooker/rails/extensions/rack_setup.rb +16 -0
  90. data/lib/facebooker/rails/extensions/routing.rb +15 -0
  91. data/lib/facebooker/rails/facebook_form_builder.rb +141 -0
  92. data/lib/facebooker/rails/facebook_pretty_errors.rb +22 -0
  93. data/lib/facebooker/rails/facebook_request_fix.rb +28 -0
  94. data/lib/facebooker/rails/facebook_request_fix_2-3.rb +31 -0
  95. data/lib/facebooker/rails/facebook_session_handling.rb +68 -0
  96. data/lib/facebooker/rails/facebook_url_helper.rb +192 -0
  97. data/lib/facebooker/rails/facebook_url_rewriting.rb +60 -0
  98. data/lib/facebooker/rails/helpers.rb +835 -0
  99. data/lib/facebooker/rails/helpers/fb_connect.rb +165 -0
  100. data/lib/facebooker/rails/helpers/stream_publish.rb +22 -0
  101. data/lib/facebooker/rails/integration_session.rb +38 -0
  102. data/lib/facebooker/rails/profile_publisher_extensions.rb +42 -0
  103. data/lib/facebooker/rails/publisher.rb +608 -0
  104. data/lib/facebooker/rails/routing.rb +49 -0
  105. data/lib/facebooker/rails/test_helpers.rb +68 -0
  106. data/lib/facebooker/rails/utilities.rb +22 -0
  107. data/lib/facebooker/server_cache.rb +24 -0
  108. data/lib/facebooker/service.rb +103 -0
  109. data/lib/facebooker/service/base_service.rb +19 -0
  110. data/lib/facebooker/service/curl_service.rb +44 -0
  111. data/lib/facebooker/service/net_http_service.rb +12 -0
  112. data/lib/facebooker/service/typhoeus_multi_service.rb +27 -0
  113. data/lib/facebooker/service/typhoeus_service.rb +17 -0
  114. data/lib/facebooker/session.rb +786 -0
  115. data/lib/facebooker/stream_post.rb +19 -0
  116. data/lib/facebooker/version.rb +9 -0
  117. data/lib/net/http_multipart_post.rb +123 -0
  118. data/lib/rack/facebook.rb +89 -0
  119. data/lib/rack/facebook_session.rb +21 -0
  120. data/lib/tasks/facebooker.rake +19 -0
  121. data/lib/tasks/facebooker.rb +2 -0
  122. data/lib/tasks/tunnel.rake +46 -0
  123. data/rails/init.rb +1 -0
  124. data/setup.rb +1585 -0
  125. data/templates/layout.erb +24 -0
  126. data/test/facebooker/adapters_test.rb +191 -0
  127. data/test/facebooker/admin_test.rb +102 -0
  128. data/test/facebooker/application_test.rb +110 -0
  129. data/test/facebooker/attachment_test.rb +72 -0
  130. data/test/facebooker/batch_request_test.rb +83 -0
  131. data/test/facebooker/data_test.rb +86 -0
  132. data/test/facebooker/logging_test.rb +43 -0
  133. data/test/facebooker/mobile_test.rb +45 -0
  134. data/test/facebooker/model_test.rb +133 -0
  135. data/test/facebooker/models/event_test.rb +15 -0
  136. data/test/facebooker/models/page_test.rb +56 -0
  137. data/test/facebooker/models/photo_test.rb +16 -0
  138. data/test/facebooker/models/user_test.rb +1074 -0
  139. data/test/facebooker/rails/facebook_request_fix_2-3_test.rb +25 -0
  140. data/test/facebooker/rails/facebook_url_rewriting_test.rb +76 -0
  141. data/test/facebooker/rails/integration_session_test.rb +13 -0
  142. data/test/facebooker/rails/publisher_test.rb +538 -0
  143. data/test/facebooker/rails_integration_test.rb +1543 -0
  144. data/test/facebooker/server_cache_test.rb +44 -0
  145. data/test/facebooker/service_test.rb +58 -0
  146. data/test/facebooker/session_test.rb +883 -0
  147. data/test/facebooker_test.rb +1263 -0
  148. data/test/fixtures/multipart_post_body_with_only_parameters.txt +33 -0
  149. data/test/fixtures/multipart_post_body_with_single_file.txt +38 -0
  150. data/test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt +38 -0
  151. data/test/net/http_multipart_post_test.rb +52 -0
  152. data/test/rack/facebook_session_test.rb +34 -0
  153. data/test/rack/facebook_test.rb +73 -0
  154. data/test/rails_test_helper.rb +36 -0
  155. data/test/test_helper.rb +74 -0
  156. metadata +303 -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,2 @@
1
+ module <%= controller_class_name %>Helper
2
+ end
@@ -0,0 +1,6 @@
1
+ <%%= stylesheet_link_tag 'facebook_scaffold' %>
2
+ <%%= facebook_messages %>
3
+
4
+ <div style="padding:10px">
5
+ <%%= yield %>
6
+ </div>
@@ -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,14 @@
1
+ class PublisherGenerator < Rails::Generator::NamedBase
2
+ def manifest
3
+ puts banner
4
+ exit(1)
5
+ end
6
+
7
+ def banner
8
+ <<-EOM
9
+ This generator has been renamed to facebook_publisher
10
+ please run: #{$0} facebook_publisher
11
+ EOM
12
+ end
13
+
14
+ end
@@ -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.js" type="text/javascript"></script>
9
+ </body>
10
+ </html>
@@ -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="https://ssl.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"></script>
9
+ </body>
10
+ </html>
@@ -0,0 +1,10 @@
1
+ class XdReceiverGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.template "xd_receiver.html", "public/xd_receiver.html"
5
+ m.template "xd_receiver_ssl.html", "public/xd_receiver_ssl.html"
6
+ end
7
+ end
8
+
9
+
10
+ end
data/init.rb ADDED
@@ -0,0 +1,26 @@
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/action_view'
25
+ require 'facebooker/rails/extensions/routing'
26
+ end
@@ -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,275 @@
1
+ begin
2
+ require 'yajl'
3
+
4
+ module Facebooker
5
+ def self.json_decode(str)
6
+ Yajl::Parser.parse(str)
7
+ end
8
+
9
+ def self.json_encode(o)
10
+ Yajl::Encoder.encode(o)
11
+ end
12
+ end
13
+ rescue LoadError
14
+ unless defined?(ActiveSupport) and defined?(ActiveSupport::JSON)
15
+ begin
16
+ require 'json'
17
+ rescue LoadError
18
+ gem "json_pure"
19
+ require "json"
20
+ end
21
+ module Facebooker
22
+ def self.json_decode(str)
23
+ JSON.parse(str)
24
+ end
25
+
26
+ def self.json_encode(o)
27
+ JSON.dump(o)
28
+ end
29
+ end
30
+ else
31
+ module Facebooker
32
+ def self.json_decode(str)
33
+ ActiveSupport::JSON.decode(str)
34
+ end
35
+
36
+ def self.json_encode(o)
37
+ ActiveSupport::JSON.encode(o)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ require 'zlib'
44
+ require 'digest/md5'
45
+
46
+ module Facebooker
47
+
48
+ @facebooker_configuration = {}
49
+ @raw_facebooker_configuration = {}
50
+ @current_adapter = nil
51
+ @set_asset_host_to_callback_url = true
52
+ @path_prefix = nil
53
+ @use_curl = false
54
+
55
+ class << self
56
+
57
+ def load_configuration(facebooker_yaml_file)
58
+ return false unless File.exist?(facebooker_yaml_file)
59
+ @raw_facebooker_configuration = YAML.load(ERB.new(File.read(facebooker_yaml_file)).result)
60
+ if defined? RAILS_ENV
61
+ @raw_facebooker_configuration = @raw_facebooker_configuration[RAILS_ENV]
62
+ end
63
+ Thread.current[:fb_api_config] = @raw_facebooker_configuration unless Thread.current[:fb_api_config]
64
+ apply_configuration(@raw_facebooker_configuration)
65
+ end
66
+
67
+ # Sets the Facebook environment based on a hash of options.
68
+ # By default the hash passed in is loaded from facebooker.yml, but it can also be passed in
69
+ # manually every request to run multiple Facebook apps off one Rails app.
70
+ def apply_configuration(config)
71
+ ENV['FACEBOOK_API_KEY'] = config['api_key']
72
+ ENV['FACEBOOK_SECRET_KEY'] = config['secret_key']
73
+ ENV['FACEBOOKER_RELATIVE_URL_ROOT'] = config['canvas_page_name']
74
+ ENV['FACEBOOKER_API'] = config['api']
75
+ if config.has_key?('set_asset_host_to_callback_url')
76
+ Facebooker.set_asset_host_to_callback_url = config['set_asset_host_to_callback_url']
77
+ end
78
+ if Object.const_defined?("ActionController") and Facebooker.set_asset_host_to_callback_url
79
+ ActionController::Base.asset_host = config['callback_url']
80
+ end
81
+ Facebooker.timeout = config['timeout']
82
+
83
+ @facebooker_configuration = config # must be set before adapter loaded
84
+ load_adapter(:fb_sig_api_key => config['api_key'])
85
+ facebooker_config
86
+ end
87
+
88
+ def facebooker_config
89
+ @facebooker_configuration
90
+ end
91
+
92
+ def with_application(api_key, &block)
93
+ config = fetch_config_for( api_key )
94
+
95
+ unless config
96
+ self.logger.info "Can't find facebooker config: '#{api_key}'" if self.logger
97
+ yield if block_given?
98
+ return
99
+ end
100
+
101
+ # Save the old config to handle nested activation. If no app context is
102
+ # set yet, use default app's configuration.
103
+ old = Thread.current[:fb_api_config] ? Thread.current[:fb_api_config].dup : @raw_facebooker_configuration
104
+
105
+ if block_given?
106
+ begin
107
+ self.logger.info "Swapping facebooker config: '#{api_key}'" if self.logger
108
+ Thread.current[:fb_api_config] = apply_configuration(config)
109
+ yield
110
+ ensure
111
+ Thread.current[:fb_api_config] = old if old && !old.empty?
112
+ apply_configuration(Thread.current[:fb_api_config])
113
+ end
114
+ end
115
+ end
116
+
117
+ def all_api_keys
118
+ [
119
+ @raw_facebooker_configuration['api_key']
120
+ ] + (
121
+ @raw_facebooker_configuration['alternative_keys'] ?
122
+ @raw_facebooker_configuration['alternative_keys'].keys :
123
+ []
124
+ )
125
+ end
126
+
127
+ def with_all_applications(&block)
128
+ all_api_keys.each do |current_api_key|
129
+ with_application(current_api_key) do
130
+ block.call
131
+ end
132
+ end
133
+ end
134
+
135
+ def fetch_config_for(api_key)
136
+ if @raw_facebooker_configuration['api_key'] == api_key
137
+ return @raw_facebooker_configuration
138
+ elsif @raw_facebooker_configuration['alternative_keys'] and
139
+ @raw_facebooker_configuration['alternative_keys'].keys.include?(api_key)
140
+ return @raw_facebooker_configuration['alternative_keys'][api_key].merge(
141
+ 'api_key' => api_key )
142
+ end
143
+ return false
144
+ end
145
+
146
+ # TODO: This should be converted to attr_accessor, but we need to
147
+ # get all the require statements at the top of the file to work.
148
+
149
+ # Set the current adapter
150
+ attr_writer :current_adapter
151
+
152
+ # Get the current adapter
153
+ def current_adapter
154
+ @current_adapter || Facebooker::AdapterBase.default_adapter
155
+ end
156
+
157
+ def load_adapter(params)
158
+ self.current_adapter = Facebooker::AdapterBase.load_adapter(params)
159
+ end
160
+
161
+ def facebook_path_prefix=(path)
162
+ current_adapter.facebook_path_prefix = path
163
+ end
164
+
165
+ # Default is canvas_page_name in yml file
166
+ def facebook_path_prefix
167
+ current_adapter.facebook_path_prefix
168
+ end
169
+
170
+ def is_for?(application_container)
171
+ current_adapter.is_for?(application_container)
172
+ end
173
+
174
+ attr_accessor :set_asset_host_to_callback_url
175
+ attr_accessor :use_curl
176
+ alias :use_curl? :use_curl
177
+
178
+ def timeout=(val)
179
+ @timeout = val.to_i
180
+ end
181
+
182
+ def timeout
183
+ @timeout
184
+ end
185
+
186
+ [:api_key,:secret_key, :www_server_base_url,:login_url_base,:install_url_base,:permission_url_base,:connect_permission_url_base,:api_rest_path,:api_server_base,:api_server_base_url,:canvas_server_base, :video_server_base].each do |delegated_method|
187
+ define_method(delegated_method){ return current_adapter.send(delegated_method)}
188
+ end
189
+
190
+
191
+ attr_reader :path_prefix
192
+
193
+
194
+ # Set the asset path to the canvas path for just this one request
195
+ # by definition, we will make this a canvas request
196
+ def with_asset_path_for_canvas
197
+ original_asset_host = ActionController::Base.asset_host
198
+ begin
199
+ ActionController::Base.asset_host = Facebooker.api_server_base_url
200
+ request_for_canvas(true) do
201
+ yield
202
+ end
203
+ ensure
204
+ ActionController::Base.asset_host = original_asset_host
205
+ end
206
+ end
207
+
208
+ # If this request is_canvas_request
209
+ # then use the application name as the url root
210
+ def request_for_canvas(is_canvas_request)
211
+ original_path_prefix = @path_prefix
212
+ begin
213
+ @path_prefix = facebook_path_prefix if is_canvas_request
214
+ yield
215
+ ensure
216
+ @path_prefix = original_path_prefix
217
+ end
218
+ end
219
+ end
220
+ end
221
+
222
+ require 'facebooker/attachment'
223
+ require 'facebooker/batch_request'
224
+ require 'facebooker/feed'
225
+ require 'facebooker/logging'
226
+ require 'facebooker/model'
227
+ require 'facebooker/parser'
228
+ require 'facebooker/service'
229
+ require 'facebooker/service/base_service'
230
+ #optional HTTP service adapters
231
+ begin
232
+ require 'facebooker/service/curl_service'
233
+ rescue LoadError
234
+ nil
235
+ end
236
+ begin
237
+ require 'facebooker/service/typhoeus_service'
238
+ require 'facebooker/service/typhoeus_multi_service'
239
+ rescue LoadError
240
+ nil
241
+ end
242
+
243
+ require 'facebooker/service/net_http_service'
244
+ require 'facebooker/server_cache'
245
+ require 'facebooker/data'
246
+ require 'facebooker/admin'
247
+ require 'facebooker/application'
248
+ require 'facebooker/mobile'
249
+ require 'facebooker/session'
250
+ require 'facebooker/stream_post'
251
+ require 'facebooker/version'
252
+ require 'facebooker/models/location'
253
+ require 'facebooker/models/affiliation'
254
+ require 'facebooker/models/album'
255
+ require 'facebooker/models/comment'
256
+ require 'facebooker/models/education_info'
257
+ require 'facebooker/models/work_info'
258
+ require 'facebooker/models/event'
259
+ require 'facebooker/models/group'
260
+ require 'facebooker/models/notifications'
261
+ require 'facebooker/models/page'
262
+ require 'facebooker/models/photo'
263
+ require 'facebooker/models/cookie'
264
+ require 'facebooker/models/applicationproperties'
265
+ require 'facebooker/models/applicationrestrictions'
266
+ require 'facebooker/models/tag'
267
+ require 'facebooker/models/user'
268
+ require 'facebooker/models/info_item'
269
+ require 'facebooker/models/info_section'
270
+ require 'facebooker/models/friend_list'
271
+ require 'facebooker/models/video'
272
+ require 'facebooker/models/message_thread'
273
+ require 'facebooker/adapters/adapter_base'
274
+ require 'facebooker/adapters/facebook_adapter'
275
+ require 'facebooker/adapters/bebo_adapter'