rack-initforthe-facebook 0.0.4 → 0.0.5
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.md
CHANGED
@@ -13,6 +13,14 @@ Corrects Facebook POST to GET for signed requests.
|
|
13
13
|
|
14
14
|
Redirects users to the specified like gate URL if they haven't liked the page.
|
15
15
|
|
16
|
+
## AppDataRedirect
|
17
|
+
|
18
|
+
Redirects users to a path passed in via Facebook's app_data parameter. Useful for allowing users to Facebook share a link to content which doesn't live on the landing page of a tab application.
|
19
|
+
|
20
|
+
# Notes
|
21
|
+
|
16
22
|
SignedRequest should always come first in the chain, all the other middleware depends on the environment changes it makes.
|
17
23
|
|
24
|
+
# Credits
|
25
|
+
|
18
26
|
Copyright 2012 Initforthe Ltd
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rack/initforthe/facebook/version'
|
2
2
|
require 'rack/initforthe/facebook/signed_request'
|
3
3
|
require 'rack/initforthe/facebook/method_fix'
|
4
|
-
require 'rack/initforthe/facebook/like_gate'
|
4
|
+
require 'rack/initforthe/facebook/like_gate'
|
5
|
+
require 'rack/initforthe/facebook/app_data_redirect'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Rack
|
2
|
+
module Initforthe
|
3
|
+
module Facebook
|
4
|
+
class AppDataRedirect
|
5
|
+
def initialize(app, options = {})
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
signed_params = env['facebook.signed_request'] || {}
|
11
|
+
url = signed_params['app_data'].to_s
|
12
|
+
if url[0] == '/'
|
13
|
+
# Not sure what status code is applicable here really, this seems closest.
|
14
|
+
[303, { 'Location' => url }, ['Redirecting']]
|
15
|
+
else
|
16
|
+
@app.call(env)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-initforthe-facebook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -24,6 +24,7 @@ files:
|
|
24
24
|
- README.md
|
25
25
|
- Rakefile
|
26
26
|
- lib/rack-initforthe-facebook.rb
|
27
|
+
- lib/rack/initforthe/facebook/app_data_redirect.rb
|
27
28
|
- lib/rack/initforthe/facebook/like_gate.rb
|
28
29
|
- lib/rack/initforthe/facebook/method_fix.rb
|
29
30
|
- lib/rack/initforthe/facebook/signed_request.rb
|