feed_satisfaction 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,8 @@ require 'oauth'
4
4
  require 'oauth/client/net_http'
5
5
  require 'erb'
6
6
 
7
+ # This file was adapted from http://support.soundcloud.com/fastpass/ruby.zip
8
+
7
9
  #
8
10
  # Helper module for integrating Get Satisfaction's FastPass single-sign-on service into a Ruby web
9
11
  # app. Use #url to create a signed FastPass URL, and #script to generate the JS-based integration.
@@ -15,6 +17,14 @@ module FeedSatisfaction
15
17
  def self.domain
16
18
  FeedSatisfaction.domain
17
19
  end
20
+
21
+ def self.key
22
+ FeedSatisfaction.fastpass_key
23
+ end
24
+
25
+ def self.secret
26
+ FeedSatisfaction.fastpass_secret
27
+ end
18
28
 
19
29
  #
20
30
  # Generates a FastPass URL with the given +email+, +name+, and +uid+ signed with the provided
@@ -52,35 +62,37 @@ module FeedSatisfaction
52
62
  # URLs to include a 'fastpass' query parameter with a signed fastpass URL.
53
63
  #
54
64
  def self.script(email, name, uid, secure=false, additional_fields={})
55
- url = url(email, name, uid, secure, additional_fields)
56
-
57
- html = <<-EOS
58
- <script type="text/javascript">
59
- var GSFN;
60
- if(GSFN == undefined) { GSFN = {}; }
65
+ if key && secret
66
+ url = url(email, name, uid, secure, additional_fields)
67
+
68
+ html = <<-EOS
69
+ <script type="text/javascript">
70
+ var GSFN;
71
+ if(GSFN == undefined) { GSFN = {}; }
61
72
 
62
- (function(){
63
- add_js = function(jsid, url) {
64
- var head = document.getElementsByTagName("head")[0];
65
- script = document.createElement('script');
66
- script.id = jsid;
67
- script.type = 'text/javascript';
68
- script.src = url;
69
- head.appendChild(script);
70
- }
71
- add_js("fastpass_common", document.location.protocol + "//#{domain}/javascripts/fastpass.js");
73
+ (function(){
74
+ add_js = function(jsid, url) {
75
+ var head = document.getElementsByTagName("head")[0];
76
+ script = document.createElement('script');
77
+ script.id = jsid;
78
+ script.type = 'text/javascript';
79
+ script.src = url;
80
+ head.appendChild(script);
81
+ }
82
+ add_js("fastpass_common", document.location.protocol + "//#{domain}/javascripts/fastpass.js");
72
83
 
73
- if(window.onload) { var old_load = window.onload; }
74
- window.onload = function() {
75
- if(old_load) old_load();
76
- add_js("fastpass", #{url.to_json});
77
- }
78
- })()
84
+ if(window.onload) { var old_load = window.onload; }
85
+ window.onload = function() {
86
+ if(old_load) old_load();
87
+ add_js("fastpass", #{url.to_json});
88
+ }
89
+ })()
79
90
 
80
- </script>
81
- EOS
82
-
83
- html.html_safe
91
+ </script>
92
+ EOS
93
+
94
+ html.html_safe
95
+ end
84
96
  end
85
97
  end
86
98
  end
@@ -1,5 +1,5 @@
1
1
  module FeedSatisfaction
2
2
 
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feed_satisfaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-05 00:00:00.000000000 -07:00
12
+ date: 2011-07-07 00:00:00.000000000 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description: Simple Ruby on Rails engine that allows you to easily add a Get Satisfaction