feed_satisfaction 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ module FeedSatisfaction
2
+ class FeedbacksController < ::ApplicationController
3
+ def show
4
+ @user = current_user if defined? current_user
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ <% if @user %>
2
+ <%= FeedSatisfaction::FastPass.script(@user.email, @user.name, @user.username) %>
3
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <script type="text/javascript">
2
+ var is_ssl = ("https:" == document.location.protocol);
3
+ var asset_host = is_ssl ? "https://s3.amazonaws.com/getsatisfaction.com/" : "http://s3.amazonaws.com/getsatisfaction.com/";
4
+ document.write(unescape("%3Cscript src='" + asset_host + "javascripts/feedback-v2.js' type='text/javascript'%3E%3C/script%3E"));
5
+ </script>
6
+
7
+ <script type="text/javascript">
8
+ var feedback_widget_options = {};
9
+ feedback_widget_options.display = "inline";
10
+ feedback_widget_options.company = "<%= FeedSatisfaction.company %>";
11
+ feedback_widget_options.product = "<%= FeedSatisfaction.product %>";
12
+ feedback_widget_options.style = "<%= FeedSatisfaction.default_tab %>";
13
+ feedback_widget_options.custom_css = "<%= FeedSatisfaction.custom_css %>";
14
+ feedback_widget_options.limit = "<%= FeedSatisfaction.question_limit %>";
15
+
16
+ GSFN.feedback_widget.prototype.local_base_url = "http://<%= FeedSatisfaction.domain %>";
17
+ GSFN.feedback_widget.prototype.local_ssl_base_url = "http://<%= FeedSatisfaction.domain %>";
18
+
19
+ var feedback_widget = new GSFN.feedback_widget(feedback_widget_options);
20
+ </script>
@@ -0,0 +1,16 @@
1
+ <% if FeedSatisfaction.sidebar_name %>
2
+ <% content_for(FeedSatisfaction.sidebar_name) do %>
3
+ <div id="gsfn_list_widget">
4
+ <h2><a class="widget_title" href="<%= FeedSatisfaction.account_url %>">Active Discussions</a></h2>
5
+ <div id="gsfn_content">Loading...</div>
6
+ <div class="powered_by">
7
+ <a href="<%= FeedSatisfaction.account_url %>">
8
+ <img alt="Favicon" src="http://getsatisfaction.com/favicon.gif" style="vertical-align: middle;"/>
9
+ </a>
10
+ <a href="<%= FeedSatisfaction.account_url %>">Get Satisfaction support network</a>
11
+ </div>
12
+ </div>
13
+ <script src="<%= FeedSatisfaction.account_url %>widgets/javascripts/<%= FeedSatisfaction.widget_id %>/widgets.js" type="text/javascript"></script>
14
+ <script src="<%= FeedSatisfaction.account_url %>topics.widget?callback=gsfnTopicsCallback&amp;length=0&amp;limit=10&amp;sort=recently_active" type="text/javascript"></script>
15
+ <% end %>
16
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <%= render 'fast_pass' %>
2
+
3
+ <%= render 'feedback_form' %>
4
+
5
+ <%= render 'sidebar' %>
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+ scope ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
3
+ get 'feedback' => 'feed_satisfaction/feedbacks#show', :as=>:feedback
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'feed_satisfaction'
2
+ require 'rails'
3
+
4
+ module FeedSatisfaction
5
+ class Engine < Rails::Engine
6
+ end
7
+ end
@@ -0,0 +1,86 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'oauth'
4
+ require 'oauth/client/net_http'
5
+ require 'erb'
6
+
7
+ #
8
+ # Helper module for integrating Get Satisfaction's FastPass single-sign-on service into a Ruby web
9
+ # app. Use #url to create a signed FastPass URL, and #script to generate the JS-based integration.
10
+ #
11
+ module FeedSatisfaction
12
+ module FastPass
13
+ extend ERB::Util
14
+
15
+ def self.domain
16
+ FeedSatisfaction.domain
17
+ end
18
+
19
+ #
20
+ # Generates a FastPass URL with the given +email+, +name+, and +uid+ signed with the provided
21
+ #
22
+ def self.url(email, name, uid, secure=false, additional_fields={})
23
+ consumer = OAuth::Consumer.new(FeedSatisfaction.fastpass_key, FeedSatisfaction.fastpass_secret)
24
+ uri = URI.parse(secure ? "https://#{domain}/fastpass" : "http://#{domain}/fastpass")
25
+ params = additional_fields.merge(:email => email, :name => name, :uid => uid)
26
+
27
+ uri.query = params.to_query
28
+
29
+ http = Net::HTTP.new(uri.host, uri.port)
30
+ http.use_ssl = true if uri.scheme == "https"
31
+ request = Net::HTTP::Get.new(uri.request_uri)
32
+ request.oauth!(http, consumer, nil, :scheme => 'query_string')
33
+
34
+ signature = request.oauth_helper.signature
35
+ #re-apply params with signature to the uri
36
+ query = params.merge(request.oauth_helper.oauth_parameters).merge("oauth_signature" => signature)
37
+ uri.query = query.to_query
38
+ return uri.to_s
39
+ end
40
+
41
+ #
42
+ # Generates a FastPass IMG tag. This integration method is likely to be deprecated, unless strong
43
+ # use cases are presented. Be warned.
44
+ #
45
+ def self.image(*args)
46
+ url = url(*args)
47
+ %Q{<img src="#{h url}" alt="" />}
48
+ end
49
+
50
+ #
51
+ # Generates a FastPass SCRIPT tag. The script will automatically rewrite all GetSatisfaction
52
+ # URLs to include a 'fastpass' query parameter with a signed fastpass URL.
53
+ #
54
+ 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 = {}; }
61
+
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");
72
+
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
+ })()
79
+
80
+ </script>
81
+ EOS
82
+
83
+ html.html_safe
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,5 @@
1
+ module FeedSatisfaction
2
+
3
+ VERSION = '0.1.0'
4
+
5
+ end
@@ -0,0 +1,38 @@
1
+ module FeedSatisfaction
2
+ require 'feed_satisfaction/fast_pass'
3
+
4
+ # Settings
5
+ mattr_accessor(:domain)
6
+ self.domain = 'getsatisfaction.com'
7
+ mattr_accessor(:company)
8
+ mattr_accessor(:product)
9
+
10
+ # single sign on
11
+ mattr_accessor(:fastpass_key)
12
+ mattr_accessor(:fastpass_secret)
13
+
14
+ mattr_accessor(:widget_id)
15
+ mattr_accessor(:custom_css)
16
+ mattr_accessor(:default_tab)
17
+ self.default_tab = 'question'
18
+ mattr_accessor(:question_limit)
19
+ self.question_limit = 5
20
+
21
+ # if you want a list of community discussions to show up in your sidebar
22
+ mattr_accessor(:sidebar_name)
23
+
24
+ def self.account_url
25
+ url = URI.parse ''
26
+ url.scheme = 'http'
27
+ url.host = self.domain
28
+ url.path = "/#{self.company}/"
29
+ url.to_s
30
+ end
31
+
32
+ # for easy configuration
33
+ def self.config
34
+ yield self
35
+ end
36
+
37
+ require 'feed_satisfaction/engine' if defined?(Rails)
38
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: feed_satisfaction
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Adam Crownoble
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-07-05 00:00:00.000000000 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+ description: Simple Ruby on Rails engine that allows you to easily add a Get Satisfaction
16
+ feedback page to your app
17
+ email: adam@obledesign.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - app/views/feed_satisfaction/feedbacks/_sidebar.html.erb
23
+ - app/views/feed_satisfaction/feedbacks/_feedback_form.html.erb
24
+ - app/views/feed_satisfaction/feedbacks/show.html.erb
25
+ - app/views/feed_satisfaction/feedbacks/_fast_pass.html.erb
26
+ - app/controllers/feed_satisfaction/feedbacks_controller.rb
27
+ - lib/feed_satisfaction/version.rb
28
+ - lib/feed_satisfaction/engine.rb
29
+ - lib/feed_satisfaction/fast_pass.rb
30
+ - lib/feed_satisfaction.rb
31
+ - config/routes.rb
32
+ has_rdoc: true
33
+ homepage: http://obledesign.com
34
+ licenses: []
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 1.6.2
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: Get Satisfaction feedback Rails engine
57
+ test_files: []