rack-initforthe-facebook 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
-
RACK middleware
|
1
|
+
# RACK middleware:
|
2
2
|
|
3
|
-
|
4
|
-
* Correct Facebook POST to GET for signed requests.
|
3
|
+
## SignedRequest
|
5
4
|
|
5
|
+
Parses the Facebook signed requests into the RACK environment.
|
6
6
|
Currently doesn't validate the request signature.
|
7
7
|
|
8
|
-
|
8
|
+
## MethodFix
|
9
|
+
|
10
|
+
Corrects Facebook POST to GET for signed requests.
|
11
|
+
|
12
|
+
## LikeGate [url]
|
13
|
+
|
14
|
+
Redirects users to the specified like gate URL if they haven't liked the page.
|
15
|
+
|
16
|
+
SignedRequest should always come first in the chain, all the other middleware depends on the environment changes it makes.
|
9
17
|
|
10
18
|
Copyright 2012 Initforthe Ltd
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Rack
|
2
|
+
module Initforthe
|
3
|
+
module Facebook
|
4
|
+
class LikeGate
|
5
|
+
def initialize(app, url, options = {})
|
6
|
+
@app = app
|
7
|
+
@url = url
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
signed_params = env['facebook.signed_request']
|
12
|
+
if signed_params.nil? || page_liked?(signed_params)
|
13
|
+
@app.call(env)
|
14
|
+
else
|
15
|
+
[301, { 'Location' => @url }, ['Please like the application']]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def page_liked?(signed_params)
|
22
|
+
signed_params.try(:[], 'page').try(:[], 'liked') || false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
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.4
|
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/like_gate.rb
|
27
28
|
- lib/rack/initforthe/facebook/method_fix.rb
|
28
29
|
- lib/rack/initforthe/facebook/signed_request.rb
|
29
30
|
- lib/rack/initforthe/facebook/version.rb
|