fotonauts-facebooker 1.0.67
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +15 -0
- data/CHANGELOG.rdoc +24 -0
- data/COPYING.rdoc +19 -0
- data/Manifest.txt +152 -0
- data/README.rdoc +119 -0
- data/Rakefile +94 -0
- data/TODO.rdoc +4 -0
- data/examples/desktop_login.rb +14 -0
- data/facebooker.gemspec +45 -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 +332 -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/templates/xd_receiver_ssl.html +10 -0
- data/generators/xd_receiver/xd_receiver_generator.rb +10 -0
- data/init.rb +26 -0
- data/install.rb +12 -0
- data/lib/facebooker.rb +275 -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 +60 -0
- data/lib/facebooker/admin.rb +42 -0
- data/lib/facebooker/application.rb +37 -0
- data/lib/facebooker/attachment.rb +51 -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/comment.rb +9 -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/family_relative_info.rb +7 -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/message_thread.rb +89 -0
- data/lib/facebooker/models/notifications.rb +17 -0
- data/lib/facebooker/models/page.rb +46 -0
- data/lib/facebooker/models/photo.rb +19 -0
- data/lib/facebooker/models/tag.rb +12 -0
- data/lib/facebooker/models/user.rb +751 -0
- data/lib/facebooker/models/video.rb +9 -0
- data/lib/facebooker/models/work_info.rb +10 -0
- data/lib/facebooker/parser.rb +970 -0
- data/lib/facebooker/rails/backwards_compatible_param_checks.rb +31 -0
- data/lib/facebooker/rails/controller.rb +353 -0
- data/lib/facebooker/rails/cucumber.rb +28 -0
- data/lib/facebooker/rails/cucumber/world.rb +40 -0
- data/lib/facebooker/rails/extensions/action_controller.rb +48 -0
- data/lib/facebooker/rails/extensions/rack_setup.rb +16 -0
- data/lib/facebooker/rails/extensions/routing.rb +15 -0
- data/lib/facebooker/rails/facebook_form_builder.rb +141 -0
- data/lib/facebooker/rails/facebook_pretty_errors.rb +22 -0
- data/lib/facebooker/rails/facebook_request_fix.rb +28 -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.rb +835 -0
- data/lib/facebooker/rails/helpers/fb_connect.rb +165 -0
- data/lib/facebooker/rails/helpers/stream_publish.rb +22 -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 +608 -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 +103 -0
- data/lib/facebooker/service/base_service.rb +19 -0
- data/lib/facebooker/service/curl_service.rb +44 -0
- data/lib/facebooker/service/net_http_service.rb +12 -0
- data/lib/facebooker/service/typhoeus_multi_service.rb +27 -0
- data/lib/facebooker/service/typhoeus_service.rb +17 -0
- data/lib/facebooker/session.rb +786 -0
- data/lib/facebooker/stream_post.rb +19 -0
- data/lib/facebooker/version.rb +9 -0
- data/lib/net/http_multipart_post.rb +123 -0
- data/lib/rack/facebook.rb +89 -0
- data/lib/rack/facebook_session.rb +21 -0
- data/lib/tasks/facebooker.rake +19 -0
- data/lib/tasks/facebooker.rb +2 -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 +191 -0
- data/test/facebooker/admin_test.rb +102 -0
- data/test/facebooker/application_test.rb +110 -0
- data/test/facebooker/attachment_test.rb +72 -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/page_test.rb +56 -0
- data/test/facebooker/models/photo_test.rb +16 -0
- data/test/facebooker/models/user_test.rb +1074 -0
- data/test/facebooker/rails/facebook_request_fix_2-3_test.rb +25 -0
- data/test/facebooker/rails/facebook_url_rewriting_test.rb +76 -0
- data/test/facebooker/rails/integration_session_test.rb +13 -0
- data/test/facebooker/rails/publisher_test.rb +538 -0
- data/test/facebooker/rails_integration_test.rb +1543 -0
- data/test/facebooker/server_cache_test.rb +44 -0
- data/test/facebooker/service_test.rb +58 -0
- data/test/facebooker/session_test.rb +883 -0
- data/test/facebooker_test.rb +1263 -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_session_test.rb +34 -0
- data/test/rack/facebook_test.rb +73 -0
- data/test/rails_test_helper.rb +36 -0
- data/test/test_helper.rb +74 -0
- metadata +303 -0
data/facebooker.gemspec
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{fotonauts-facebooker}
|
5
|
+
s.version = "1.0.67"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Chad Fowler", "Patrick Ewing", "Mike Mangino", "Shane Vitarana", "Corey Innis", "Mike Mangino"]
|
9
|
+
s.date = %q{2010-03-30}
|
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
|
+
|
12
|
+
* Idiomatic Ruby
|
13
|
+
* No dependencies outside of the Ruby standard library (This is true with Rails 2.1. Previous Rails versions require the JSON gem)
|
14
|
+
* Concrete classes and methods modeling the Facebook data, so it's easy for a Rubyist to understand what's available
|
15
|
+
* Well tested}
|
16
|
+
s.email = ["chad@chadfowlwer.com", "", "", "", "", "mmangino@elevatedrails.com"]
|
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_ssl.html", "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/attachment.rb", "lib/facebooker/admin.rb", "lib/facebooker/application.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/comment.rb", "lib/facebooker/models/education_info.rb", "lib/facebooker/models/event.rb", "lib/facebooker/models/family_relative_info.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/models/message_thread.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/helpers/stream_publish.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/service/base_service.rb", "lib/facebooker/service/curl_service.rb", "lib/facebooker/service/net_http_service.rb", "lib/facebooker/service/typhoeus_service.rb", "lib/facebooker/service/typhoeus_multi_service.rb", "lib/facebooker/session.rb", "lib/facebooker/stream_post.rb", "lib/facebooker/version.rb", "lib/net/http_multipart_post.rb", "lib/rack/facebook.rb", "lib/rack/facebook_session.rb", "lib/tasks/facebooker.rake", "lib/tasks/facebooker.rb", "lib/tasks/tunnel.rake", "rails/init.rb", "setup.rb", "templates/layout.erb", "test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/application_test.rb", "test/facebooker/attachment_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/rack/facebook_session_test.rb", "test/rails_test_helper.rb", "test/test_helper.rb", "test/facebooker/rails/facebook_url_rewriting_test.rb", "test/facebooker/rails/integration_session_test.rb", "test/facebooker/service_test.rb"]
|
19
|
+
s.homepage = %q{http://facebooker.rubyforge.org}
|
20
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
s.rubyforge_project = %q{facebooker}
|
23
|
+
s.rubygems_version = %q{1.3.5}
|
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]}
|
25
|
+
s.test_files = ["test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/application_test.rb", "test/facebooker/attachment_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/integration_session_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_session_test.rb", "test/rack/facebook_test.rb"]
|
26
|
+
|
27
|
+
if s.respond_to? :specification_version then
|
28
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
29
|
+
s.specification_version = 3
|
30
|
+
|
31
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
32
|
+
s.add_runtime_dependency(%q<yajl-ruby>, [">= 0.7.5"])
|
33
|
+
s.add_runtime_dependency(%q<json_pure>, [">= 1.0.0"])
|
34
|
+
s.add_development_dependency(%q<hoe>, [">= 2.4.0"])
|
35
|
+
else
|
36
|
+
s.add_dependency(%q<yajl-ruby>, [">= 0.7.5"])
|
37
|
+
s.add_dependency(%q<json_pure>, [">= 1.0.0"])
|
38
|
+
s.add_dependency(%q<hoe>, [">= 2.4.0"])
|
39
|
+
end
|
40
|
+
else
|
41
|
+
s.add_dependency(%q<yajl-ruby>, [">= 0.7.5"])
|
42
|
+
s.add_dependency(%q<json_pure>, [">= 1.0.0"])
|
43
|
+
s.add_dependency(%q<hoe>, [">= 2.4.0"])
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class FacebookGenerator < Rails::Generator::Base
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
m.file 'config/facebooker.yml', 'config/facebooker.yml'
|
5
|
+
m.file 'public/javascripts/facebooker.js', 'public/javascripts/facebooker.js'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
protected
|
10
|
+
|
11
|
+
def banner
|
12
|
+
"Usage: #{$0} facebooker"
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# The api key, secret key, and canvas page name are required to get started
|
2
|
+
# Tunnel configuration is only needed if you are going to use the facebooker:tunnel Rake tasks
|
3
|
+
# Your callback url in Facebook should be set to http://public_host:public_port
|
4
|
+
# If you're building a Facebook connect site,
|
5
|
+
# change the value of set_asset_host_to_callback_url to false
|
6
|
+
# To develop for the new profile design, add the following key..
|
7
|
+
# api: new
|
8
|
+
# remove the key or set it to anything else to use the old facebook design.
|
9
|
+
# This should only be necessary until the final version of the new profile is released.
|
10
|
+
|
11
|
+
development:
|
12
|
+
api_key:
|
13
|
+
secret_key:
|
14
|
+
canvas_page_name:
|
15
|
+
callback_url:
|
16
|
+
pretty_errors: true
|
17
|
+
set_asset_host_to_callback_url: true
|
18
|
+
tunnel:
|
19
|
+
public_host_username:
|
20
|
+
public_host:
|
21
|
+
public_port: 4007
|
22
|
+
local_port: 3000
|
23
|
+
server_alive_interval: 0
|
24
|
+
|
25
|
+
test:
|
26
|
+
api_key:
|
27
|
+
secret_key:
|
28
|
+
canvas_page_name:
|
29
|
+
callback_url:
|
30
|
+
set_asset_host_to_callback_url: true
|
31
|
+
tunnel:
|
32
|
+
public_host_username:
|
33
|
+
public_host:
|
34
|
+
public_port: 4007
|
35
|
+
local_port: 3000
|
36
|
+
server_alive_interval: 0
|
37
|
+
|
38
|
+
production:
|
39
|
+
api_key:
|
40
|
+
secret_key:
|
41
|
+
canvas_page_name:
|
42
|
+
callback_url:
|
43
|
+
set_asset_host_to_callback_url: true
|
44
|
+
tunnel:
|
45
|
+
public_host_username:
|
46
|
+
public_host:
|
47
|
+
public_port: 4007
|
48
|
+
local_port: 3000
|
49
|
+
server_alive_interval: 0
|
@@ -0,0 +1,332 @@
|
|
1
|
+
function $(element) {
|
2
|
+
if (typeof element == "string") {
|
3
|
+
element=document.getElementById(element);
|
4
|
+
}
|
5
|
+
if (element)
|
6
|
+
extendInstance(element,Element);
|
7
|
+
return element;
|
8
|
+
}
|
9
|
+
|
10
|
+
function getElementsByName(elementName) {
|
11
|
+
var matcher = function(element) {
|
12
|
+
return (element.getName() === elementName);
|
13
|
+
};
|
14
|
+
return domCollect(document.getRootElement(), matcher);
|
15
|
+
}
|
16
|
+
function getElementsByClass(classname) {
|
17
|
+
var matcher = function(element) {
|
18
|
+
return (element.getClassName() === classname);
|
19
|
+
};
|
20
|
+
return domCollect(document.getRootElement(), matcher);
|
21
|
+
}
|
22
|
+
//function getElementsByTagName(tagName) -> native to FJBS
|
23
|
+
|
24
|
+
extendInstance(Ajax, { //Extends the native Facebook Ajax object
|
25
|
+
/*
|
26
|
+
* Make a request to a remote server. Call the 'success' callback with the result.
|
27
|
+
* Ex: Ajax.Load('JSON','http://...',{ success: function(result){console.log(result.toSource())} }, {'json':test_content})
|
28
|
+
*/
|
29
|
+
Load: function(response_type, action_path, callbacks, post_parameters) {
|
30
|
+
callbacks = Ajax.checkCallbacks(callbacks);
|
31
|
+
var ajax = new Ajax();
|
32
|
+
switch(response_type) {
|
33
|
+
case 'FBML':
|
34
|
+
ajax.responseType = Ajax.FBML;
|
35
|
+
break;
|
36
|
+
case 'JSON':
|
37
|
+
ajax.responseType = Ajax.JSON;
|
38
|
+
break;
|
39
|
+
case 'RAW':
|
40
|
+
ajax.responseType = Ajax.RAW;
|
41
|
+
break;
|
42
|
+
default:
|
43
|
+
console.error("Unknow respons format requested. You supplied %s. Supported: 'FBML', 'RAW'", response_type);
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
ajax.ondone = function(result){
|
47
|
+
callbacks.success(result);
|
48
|
+
callbacks.complete();
|
49
|
+
}
|
50
|
+
ajax.onerror = function(error_string) {
|
51
|
+
callbacks.failure(error_string);
|
52
|
+
callbacks.complete();
|
53
|
+
}
|
54
|
+
|
55
|
+
post_parameters = post_parameters || {}
|
56
|
+
post_parameters['authenticity_token'] = _token;
|
57
|
+
|
58
|
+
if(action_path.indexOf('http') == -1) {
|
59
|
+
action_path = _hostname + action_path;
|
60
|
+
}
|
61
|
+
|
62
|
+
callbacks.begin();
|
63
|
+
ajax.post(action_path,post_parameters);
|
64
|
+
},
|
65
|
+
/*
|
66
|
+
* Make a request to a remote server. Update target_element with result. Calls the 'success' callback with the result
|
67
|
+
* Ex: Ajax.Update('test1', 'FBML', 'http://...',{ success: function(result){console.log(result)} })
|
68
|
+
*/
|
69
|
+
Update: function(target_element, response_type, action_path, callbacks, post_parameters) {
|
70
|
+
callbacks = Ajax.checkCallbacks(callbacks);
|
71
|
+
var update_element = function(content) {
|
72
|
+
switch(response_type) {
|
73
|
+
case 'FBML':
|
74
|
+
$(target_element).setInnerFBML(content);
|
75
|
+
break;
|
76
|
+
case 'RAW':
|
77
|
+
$(target_element).setTextValue(content);
|
78
|
+
break;
|
79
|
+
default:
|
80
|
+
console.log("Unsupported response type "+response_type);
|
81
|
+
break;
|
82
|
+
}
|
83
|
+
};
|
84
|
+
|
85
|
+
var onsuccess = (callbacks.success == null)?
|
86
|
+
update_element :
|
87
|
+
chainMethods([update_element,callbacks.success]);
|
88
|
+
|
89
|
+
callbacks.success = onsuccess;
|
90
|
+
Ajax.Load(response_type, action_path, callbacks, post_parameters);
|
91
|
+
},
|
92
|
+
|
93
|
+
|
94
|
+
InPlaceInputEditor: function(target_element, action_path, post_parameters) {
|
95
|
+
var classname = $(target_element).getClassName() || "";
|
96
|
+
|
97
|
+
this.edit = function() {
|
98
|
+
var target = $(target_element);
|
99
|
+
var wrapper = target.getParentNode();
|
100
|
+
var dimensions = $(target_element).getDimensions();
|
101
|
+
var value = $(target_element+'__value').getValue();
|
102
|
+
|
103
|
+
var editArea = document.createElement('input');
|
104
|
+
editArea.setType($(target_element+'__value').getType());
|
105
|
+
editArea.setId(target_element+"__editor");
|
106
|
+
editArea.setValue(value);
|
107
|
+
//editArea.focus();
|
108
|
+
//editArea.setStyle("width",dimensions.width+"px");
|
109
|
+
//editArea.setStyle("height", dimensions.height+'px');
|
110
|
+
|
111
|
+
$(target_element+'__value').remove();
|
112
|
+
wrapper.removeChild(target);
|
113
|
+
wrapper.appendChild(editArea);
|
114
|
+
}
|
115
|
+
this.save = function(callbacks){
|
116
|
+
var newValue = $(target_element + "__editor").getValue();
|
117
|
+
var wrapper = $(target_element + "__editor").getParentNode();
|
118
|
+
callbacks = Ajax.checkCallbacks(callbacks);
|
119
|
+
Ajax.Load("RAW", action_path + "?raw=" + escape(newValue), {
|
120
|
+
success: chainMethods([
|
121
|
+
callbacks.success,
|
122
|
+
function(result){
|
123
|
+
wrapper.setInnerXHTML('<span>'+
|
124
|
+
'<input id="'+target_element+'__value" name="'+target_element+'__value" style="display:none;" type="text" value="'+unescape(result)+'" />'+
|
125
|
+
'<span><span id="'+target_element+'" class="'+classname+'" type="text">'+unescape(result)+'</span></span></span>');
|
126
|
+
}
|
127
|
+
])
|
128
|
+
}, post_parameters)
|
129
|
+
};
|
130
|
+
},
|
131
|
+
InPlaceTextAreaEditor: function(target_element, action_path, post_parameters) {
|
132
|
+
var classname = $(target_element).getClassName() || "";
|
133
|
+
|
134
|
+
this.edit = function() {
|
135
|
+
var target = $(target_element);
|
136
|
+
var wrapper = target.getParentNode();
|
137
|
+
var dimensions = $(target_element).getDimensions();
|
138
|
+
var value = $(target_element+'__value').getValue();
|
139
|
+
|
140
|
+
var editArea = document.createElement('textarea');
|
141
|
+
editArea.setId(target_element+"__editor");
|
142
|
+
editArea.setValue(value.replace(/<br \/>|<br\/>/g,'\n').replace(/<p>|<\/p>/g,''));
|
143
|
+
editArea.addEventListener('keyup', function() {
|
144
|
+
autoExpandTextarea(editArea);
|
145
|
+
});
|
146
|
+
//editArea.focus();
|
147
|
+
editArea.setStyle("width",dimensions.width+"px");
|
148
|
+
//editArea.setStyle("height", dimensions.height+'px');
|
149
|
+
|
150
|
+
$(target_element+'__value').remove();
|
151
|
+
wrapper.removeChild(target);
|
152
|
+
wrapper.appendChild(editArea);
|
153
|
+
autoExpandTextarea(editArea);
|
154
|
+
}
|
155
|
+
this.save = function(callbacks){
|
156
|
+
var newValue = $(target_element + "__editor").getValue();
|
157
|
+
var wrapper = $(target_element + "__editor").getParentNode();
|
158
|
+
callbacks = Ajax.checkCallbacks(callbacks);
|
159
|
+
Ajax.Load("RAW", action_path + "?raw=" + escape(newValue), {
|
160
|
+
success: chainMethods([
|
161
|
+
callbacks.success,
|
162
|
+
function(result){
|
163
|
+
wrapper.setInnerXHTML('<span>'+
|
164
|
+
'<textarea id="'+target_element+'__value" name="'+target_element+'__value" style="display:none;">'+unescape(result.replace(/<br \/>|<br\/>/g,'\n').replace(/<p>|<\/p>/g,''))+'</textarea>'+
|
165
|
+
'<div><div id="'+target_element+'" class="'+classname+'" type="text">'+unescape(result)+'</div></div></span>');
|
166
|
+
}
|
167
|
+
])
|
168
|
+
}, post_parameters)
|
169
|
+
};
|
170
|
+
},
|
171
|
+
/*
|
172
|
+
* Pass the data inside of a form to a target url and place the result inside target_element.
|
173
|
+
* Calls the 'success' callback with the result
|
174
|
+
*/
|
175
|
+
UpdateRemoteForm: function(form_element, target_element, response_type, target_action, callbacks) {
|
176
|
+
callbacks = callbacks || {};
|
177
|
+
Ajax.Update(target_element, response_type, target_action, callbacks, $(form_element).serialize());
|
178
|
+
},
|
179
|
+
checkCallbacks:function(callbacks) {
|
180
|
+
callbacks = callbacks || {};
|
181
|
+
var donothing = function(){};
|
182
|
+
return callbacks = {
|
183
|
+
success: callbacks.success || donothing,
|
184
|
+
failure: callbacks.failure || donothing,
|
185
|
+
begin: callbacks.begin || donothing,
|
186
|
+
complete: callbacks.complete || donothing
|
187
|
+
};
|
188
|
+
}
|
189
|
+
});
|
190
|
+
|
191
|
+
/*
|
192
|
+
* Displays a confirmation dialog. If the user clicks "continue" then callback will be evaluated.
|
193
|
+
* title and message can be strings or fb:js-string objects
|
194
|
+
*/
|
195
|
+
function confirm(title,message,callback) {
|
196
|
+
dialog = new Dialog(Dialog.DIALOG_POP);
|
197
|
+
|
198
|
+
dialog.showChoice(
|
199
|
+
title,
|
200
|
+
message, // Content
|
201
|
+
'Continue',
|
202
|
+
'Cancel');
|
203
|
+
|
204
|
+
dialog.onconfirm = function() {
|
205
|
+
callback();
|
206
|
+
};
|
207
|
+
}
|
208
|
+
|
209
|
+
function chainMethods(callbacks) {
|
210
|
+
return function(par1,par2,par3,par4,par5,par6) {
|
211
|
+
for (var i = 0, l = callbacks.length; i < l; i++) {
|
212
|
+
callbacks[i](par1, par2, par3, par4, par5, par6);
|
213
|
+
}
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
function extendInstance(instance,hash) {
|
218
|
+
for (var name in hash) {
|
219
|
+
instance[name] = hash[name];
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
var Element = {
|
224
|
+
visible: function() {
|
225
|
+
return (this.getStyle('display') != 'none');
|
226
|
+
},
|
227
|
+
toggle: function() {
|
228
|
+
if (this.visible()) {
|
229
|
+
this.hide();
|
230
|
+
} else {
|
231
|
+
this.show();
|
232
|
+
}
|
233
|
+
},
|
234
|
+
hide: function() {
|
235
|
+
this.setStyle({
|
236
|
+
display:'none'
|
237
|
+
});
|
238
|
+
return this;
|
239
|
+
},
|
240
|
+
show: function(element) {
|
241
|
+
this.setStyle({
|
242
|
+
display:''
|
243
|
+
});
|
244
|
+
return this;
|
245
|
+
},
|
246
|
+
remove: function() {
|
247
|
+
this.getParentNode().removeChild(this);
|
248
|
+
return null;
|
249
|
+
},
|
250
|
+
/*
|
251
|
+
* Returns calculated element size
|
252
|
+
*/
|
253
|
+
getDimensions: function() {
|
254
|
+
var display = this.getStyle('display');
|
255
|
+
if (display != 'none' && display != null) // Safari bug
|
256
|
+
return {
|
257
|
+
width: this.getOffsetWidth(),
|
258
|
+
height: this.getOffsetHeight()
|
259
|
+
};
|
260
|
+
|
261
|
+
// All *Width and *Height properties give 0 on elements with display none,
|
262
|
+
// so enable the element temporarily
|
263
|
+
var originalVisibility = this.getStyle("visibility");
|
264
|
+
var originalDisplay = this.getStyle("display");
|
265
|
+
var originalPosition = this.getStyle("position");
|
266
|
+
this.setStyle('visibility','none');
|
267
|
+
this.setStyle('display','block');
|
268
|
+
this.setStyle('position','absolute');
|
269
|
+
var originalWidth = this.getClientWidth();
|
270
|
+
var originalHeight = this.getClientHeight();
|
271
|
+
this.setStyle('visibility',originalVisibility);
|
272
|
+
this.setStyle('display',originalDisplay);
|
273
|
+
this.setStyle('position',originalPosition);
|
274
|
+
|
275
|
+
return {
|
276
|
+
width: originalWidth,
|
277
|
+
height: originalHeight
|
278
|
+
};
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
function encodeURIComponent(str) {
|
283
|
+
if (typeof(str) == "string") {
|
284
|
+
return str.replace(/=/g,'%3D').replace(/&/g,'%26');
|
285
|
+
}
|
286
|
+
//checkboxes and radio buttons return objects instead of a string
|
287
|
+
else if(typeof(str) == "object"){
|
288
|
+
for (prop in str)
|
289
|
+
{
|
290
|
+
return str[prop].replace(/=/g,'%3D').replace(/&/g,'%26');
|
291
|
+
}
|
292
|
+
}
|
293
|
+
return "";
|
294
|
+
}
|
295
|
+
|
296
|
+
/*
|
297
|
+
* Applies block to all elements of an array. Return the array itself.
|
298
|
+
*/
|
299
|
+
function map(array, block){
|
300
|
+
results = [];
|
301
|
+
for (var i=0,l=array.length;i<l;i++){
|
302
|
+
results.push(block(array[i]));
|
303
|
+
}
|
304
|
+
return results;
|
305
|
+
}
|
306
|
+
|
307
|
+
/*
|
308
|
+
* Collects all elements within the 'element' tree that 'matcher' returns true for
|
309
|
+
* For an example, see selectElementsByClass
|
310
|
+
*/
|
311
|
+
function domCollect(element, matcher) {
|
312
|
+
collection = [];
|
313
|
+
var recurse = function(subelement){
|
314
|
+
var nodes = subelement.getChildNodes();
|
315
|
+
map(nodes, function(node){
|
316
|
+
if (matcher(node)) {
|
317
|
+
extendInstance(node,Element)
|
318
|
+
collection.push(node);
|
319
|
+
}
|
320
|
+
if (node.getFirstChild()) {
|
321
|
+
recurse(node);
|
322
|
+
}
|
323
|
+
});
|
324
|
+
};
|
325
|
+
recurse(element);
|
326
|
+
return collection;
|
327
|
+
}
|
328
|
+
|
329
|
+
PeriodicalExecuter = function (callback, frequency) {
|
330
|
+
setTimeout(callback, frequency *1000);
|
331
|
+
setTimeout(function() { new PeriodicalExecuter(callback,frequency); }, frequency*1000);
|
332
|
+
};
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new controller and its views. Pass the controller name, either
|
3
|
+
CamelCased or under_scored, and a list of views as arguments.
|
4
|
+
|
5
|
+
To create a controller within a module, specify the controller name as a
|
6
|
+
path like 'parent_module/controller_name'.
|
7
|
+
|
8
|
+
This generates a controller class in app/controllers, view templates in
|
9
|
+
app/views/controller_name, a helper class in app/helpers, and a functional
|
10
|
+
test suite in test/functional.
|
11
|
+
|
12
|
+
Also, it generates fbml view templates.
|
13
|
+
|
14
|
+
Example:
|
15
|
+
`./script/generate controller CreditCard open debit credit close`
|
16
|
+
|
17
|
+
Credit card controller with URLs like /credit_card/debit.
|
18
|
+
Controller: app/controllers/credit_card_controller.rb
|
19
|
+
Views: app/views/credit_card/debit.html.erb [...],
|
20
|
+
app/views/credit_card/debit.fbml.erb [...]
|
21
|
+
Helper: app/helpers/credit_card_helper.rb
|
22
|
+
Test: test/functional/credit_card_controller_test.rb
|
23
|
+
|
24
|
+
Modules Example:
|
25
|
+
`./script/generate controller 'admin/credit_card' suspend late_fee`
|
26
|
+
|
27
|
+
Credit card admin controller with URLs /admin/credit_card/suspend.
|
28
|
+
Controller: app/controllers/admin/credit_card_controller.rb
|
29
|
+
Views: app/views/admin/credit_card/debit.html.erb [...],
|
30
|
+
app/views/admin/credit_card/debit.fbml.erb [...]
|
31
|
+
Helper: app/helpers/admin/credit_card_helper.rb
|
32
|
+
Test: test/functional/admin/credit_card_controller_test.rb
|
33
|
+
|