doesfacebook 0.5.0.pre3 → 0.5.0
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/README.rdoc
CHANGED
@@ -38,7 +38,7 @@ or ssl_callback_url fields of your app. A sample configuration looks like this:
|
|
38
38
|
my_sweet_facebook_app:
|
39
39
|
app_id: 1234567890
|
40
40
|
secret_key: a1b2c3d4e5f6g7h8i9j0k1l
|
41
|
-
|
41
|
+
namespace: my_sweet_canvas_name
|
42
42
|
callback_url: http://your.server.com/and/path
|
43
43
|
ssl_callback_url: https://your.secure.server.com/and/path
|
44
44
|
|
@@ -53,7 +53,7 @@ The typical configuration options are as follows:
|
|
53
53
|
|
54
54
|
* app_id: Facebook ID of your application
|
55
55
|
* secret_key: Facebook secret key of your application (used to parse and validate Facebook requests)
|
56
|
-
*
|
56
|
+
* namespace: The "myapp" from "http://apps.facebook.com/myapp" used frequently for link generation and redirection (previously, this configuration field was known as "canvas_name", but Facebook has deprecated that name in favor of "namespace")
|
57
57
|
* callback_url: The server callback URL for your app. Used to identify the proper configuration which should be loaded for each request.
|
58
58
|
* ssl_callback_url: The server callback for secure, HTTPS requests. Required for production apps. Can be different from your non-secure callback_url
|
59
59
|
|
@@ -86,7 +86,7 @@ against the Facebook platform easier:
|
|
86
86
|
|
87
87
|
* app_id: The current application's id, parsed from doesfacebook.yml
|
88
88
|
* app_callback_url: The current application's callback URL, parsed from doesfacebook.yml
|
89
|
-
*
|
89
|
+
* app_namespace: The current application's canvas shortname, parsed from doesfacebook.yml (aliased as "app_canvas_name" for backwards compatibility)
|
90
90
|
* app_canvas_url: The full URL to the application canvas (e.g., http://apps.facebook.com/myapp)
|
91
91
|
* url_for_canvas(url_opts={}): Like the standard url_for, but ensures the endpoint is in the Facebook canvas
|
92
92
|
* link_to_canvas(text, url_opts={}, html_opts={}): Use as you would the regular link_to helper; generates links to the canvas and properly targets the link to "_top" frame to keep app within canvas and not break into your iframe
|
@@ -19,20 +19,20 @@ module DoesFacebookHelper
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
# Return the current app
|
23
|
-
def
|
24
|
-
controller.send(:facebook_config)[:
|
22
|
+
# Return the current app namespace:
|
23
|
+
def app_namespace
|
24
|
+
controller.send(:facebook_config)[:namespace]
|
25
25
|
end
|
26
|
+
alias_method :app_canvas_name, :app_namespace # <= Deprecation of "canvas_name", but still aliased
|
26
27
|
|
27
28
|
# Return the full canvas URL:
|
28
29
|
def app_canvas_url
|
29
|
-
request.ssl? ? "https://
|
30
|
+
"#{request.ssl? ? "https://" : "http://"}apps.facebook.com/#{app_namespace}"
|
30
31
|
end
|
31
32
|
|
32
33
|
# Generate a URL that points within the Facebook canvas
|
33
34
|
def url_for_canvas(url_opts={})
|
34
|
-
|
35
|
-
canvas_root = File.join(apps_root, app_canvas_name)
|
35
|
+
canvas_root = app_canvas_url
|
36
36
|
if url_opts.is_a?(Hash)
|
37
37
|
return File.join(canvas_root, url_for(url_opts))
|
38
38
|
elsif url_opts.include?("://")
|
data/lib/doesfacebook/config.rb
CHANGED
@@ -9,26 +9,25 @@ module DoesFacebook
|
|
9
9
|
# Load app configuration by Facebook callback path with a fallback to config
|
10
10
|
# defined with name matching our current environment:
|
11
11
|
def facebook_config
|
12
|
-
|
13
|
-
|
12
|
+
@facebook_config ||= nil
|
13
|
+
return @facebook_config unless @facebook_config.nil?
|
14
|
+
app_name, app_config = all_facebook_config.find do |name, config|
|
15
|
+
test_callback = request.ssl? ? config["ssl_callback_url"] : config["callback_url"]
|
16
|
+
request.url.match(/^#{test_callback}.*/)
|
14
17
|
end
|
15
|
-
if
|
16
|
-
|
17
|
-
if app_config
|
18
|
-
|
19
|
-
|
18
|
+
if app_config
|
19
|
+
app_config = HashWithIndifferentAccess.new(app_config)
|
20
|
+
if app_config[:canvas_name]
|
21
|
+
app_config[:namespace] ||= app_config.delete(:canvas_name)
|
22
|
+
Rails.logger.warn(" DoesFacebook Deprecation Warning: \"canvas_name\" field in doesfacebook.yml should be renamed \"namespace\" as per Facebook Roadmap")
|
20
23
|
end
|
21
|
-
|
22
|
-
|
23
|
-
@@facebook_config = HashWithIndifferentAccess.new(all_facebook_config[Rails.env])
|
24
|
-
unless @@facebook_config.blank?
|
25
|
-
Rails.logger.debug(" Facebook configuration loaded for app based on environment \"#{Rails.env}\"")
|
24
|
+
Rails.logger.info(" Facebook configuration for app \"#{app_name}\" loaded for request URL #{request.url}")
|
25
|
+
@facebook_config = app_config
|
26
26
|
else
|
27
27
|
Rails.logger.warn(" Facebook configuration could not be found. doesfacebook.yml has no app for host #{request.host}")
|
28
28
|
Rails.logger.warn(" Facebook configuration can be generated by running \"rails generate does_facebook:config\"")
|
29
29
|
end
|
30
|
-
|
31
|
-
return @@facebook_config
|
30
|
+
return @facebook_config
|
32
31
|
end
|
33
32
|
|
34
33
|
|
@@ -15,7 +15,7 @@ module DoesFacebook
|
|
15
15
|
# Mechanism for redirecting within the Facebook canvas:
|
16
16
|
def redirect_to_canvas_old(opts={})
|
17
17
|
raise MalformedUrlOptions.new("Options passed to `redirect_to_canvas` must be a URL options Hash") unless opts.is_a?(Hash)
|
18
|
-
dest = File.join("http://apps.facebook.com/", facebook_config[:
|
18
|
+
dest = File.join("http://apps.facebook.com/", facebook_config[:namespace], url_for(opts.merge(:only_path=>true)))
|
19
19
|
logger.warn "DoesFacebook: redirect_to_canvas_old method is deprecated and does not support HTTPS."
|
20
20
|
logger.warn "DoesFacebook: Use redirect_to_canvas for HTTPS-support and JavaScript-based redirection."
|
21
21
|
logger.info "Canvas Redirect to #{opts.inspect}=>#{dest}"
|
@@ -26,7 +26,7 @@ module DoesFacebook
|
|
26
26
|
def redirect_to_canvas(opts={})
|
27
27
|
raise MalformedUrlOptions.new("Options passed to `redirect_to_canvas` must be a URL options Hash") unless opts.is_a?(Hash)
|
28
28
|
apps_root = request.ssl? ? "https://apps.facebook.com/" : "http://apps.facebook.com/"
|
29
|
-
dest = File.join(apps_root, facebook_config[:
|
29
|
+
dest = File.join(apps_root, facebook_config[:namespace], url_for(opts.merge(:only_path=>true)))
|
30
30
|
@facebook_redirect_url = dest
|
31
31
|
logger.info "Canvas Redirect to #{opts.inspect}=>#{dest}"
|
32
32
|
begin
|
@@ -15,18 +15,18 @@
|
|
15
15
|
name_of_app:
|
16
16
|
app_id: 1234567890
|
17
17
|
secret_key: 1234567890abcdefghijklmnopqrsttuv
|
18
|
-
|
18
|
+
namespace: your_canvas_name
|
19
19
|
callback_url: http://your.dev.server.com/and/path
|
20
20
|
|
21
21
|
name_of_another_app:
|
22
22
|
app_id: 1234567890
|
23
23
|
secret_key: 1234567890abcdefghijklmnopqrsttuv
|
24
|
-
|
24
|
+
namespace: your_canvas_name
|
25
25
|
callback_url: http://your.dev.server.com/and/path
|
26
26
|
|
27
27
|
name_of_production_app:
|
28
28
|
app_id: 1234567890
|
29
29
|
secret_key: 1234567890abcdefghijklmnopqrsttuv
|
30
|
-
|
30
|
+
namespace: your_canvas_name
|
31
31
|
callback_url: http://your.server.com/and/path
|
32
32
|
ssl_callback_url: https://your.secure.server.com/and/path
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doesfacebook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- mccolin
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-28 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &2162612200 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2162612200
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jeweler
|
27
|
-
requirement: &
|
27
|
+
requirement: &2162611700 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 1.5.1
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2162611700
|
36
36
|
description: Paper-thin Facebook validation and signed request parsing Rails plugin
|
37
37
|
email: info@awexomelabs.com
|
38
38
|
executables: []
|
@@ -67,9 +67,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
68
|
none: false
|
69
69
|
requirements:
|
70
|
-
- - ! '
|
70
|
+
- - ! '>='
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
72
|
+
version: '0'
|
73
73
|
requirements: []
|
74
74
|
rubyforge_project:
|
75
75
|
rubygems_version: 1.8.17
|