From b5068b6bc40265334afbccdd30ac2c1612ff827b Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Tue, 7 Oct 2014 15:19:10 -0400 Subject: [PATCH 1/2] finalized uservoice config --- app/assets/javascripts/lib/uservoice.js | 23 +--- app/assets/stylesheets/uservoice.css | 135 +----------------------- app/views/layouts/application.html.erb | 9 +- config/initializers/redis.rb | 6 -- config/initializers/uservoice.rb | 9 ++ 5 files changed, 22 insertions(+), 160 deletions(-) delete mode 100644 config/initializers/redis.rb create mode 100644 config/initializers/uservoice.rb diff --git a/app/assets/javascripts/lib/uservoice.js b/app/assets/javascripts/lib/uservoice.js index ae2e0f3f..7676736d 100644 --- a/app/assets/javascripts/lib/uservoice.js +++ b/app/assets/javascripts/lib/uservoice.js @@ -3,7 +3,7 @@ if(USERVOICE == undefined) { USERVOICE = {}; } -USERVOICE.load = function (barometer_id) { +USERVOICE.load = function (sso_token) { // Include the UserVoice JavaScript SDK (only needed once on a page) UserVoice=window.UserVoice||[];(function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/wybK0nSMNuhlWkIKzTyWg.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})(); @@ -21,24 +21,11 @@ UserVoice.push(['set', { // Identify the user and pass traits // To enable, replace sample data with actual user traits and uncomment the line -//TODO NEED HELP HERE MAKING SURE CORRECT USER DATA GETS PUSHED -UserVoice.push(['identify', { - //email: 'getElementsByTagName(userid)', // User’s email address - name: "userid", // User’s real name - //created_at: 1364406966, // Unix timestamp for the date the user signed up - id: "Metamaps.Active.Mapper.id", // Optional: Unique id of the user (if set, this should not change) - //type: 'Owner', // Optional: segment your users by type - //account: { - // id: 123, // Optional: associate multiple users with a single account - // name: 'Acme, Co.', // Account name - // created_at: 1364406966, // Unix timestamp for the date the account was created - // monthly_rate: 9.99, // Decimal; monthly rate of the account - // ltv: 1495.00, // Decimal; lifetime value of the account - // plan: 'Enhanced' // Plan name for the account - //} -}]); +if (sso_token) { + UserVoice.push(['setSSO', sso_token]); +} -// Add default trigger to the bottom-right corner of the window: +// Add default trigger to the bottom-left corner of the window: UserVoice.push(['addTrigger', { mode: 'contact', trigger_position: 'bottom-left' }]); // Or, use your own custom trigger: diff --git a/app/assets/stylesheets/uservoice.css b/app/assets/stylesheets/uservoice.css index fd3c68f5..953a5e5b 100644 --- a/app/assets/stylesheets/uservoice.css +++ b/app/assets/stylesheets/uservoice.css @@ -13,137 +13,4 @@ div.uv-icon.uv-bottom-left { top:25%; width:25px; z-index:100000; - } - -/* =NOTHING AFTER THIS POINT IS BEING USED ---------------------------------------------------------*/ - -#barometer_overlay { - top:0; - left:0; - width: 100%; - height: 100%; - position: fixed; - _position: absolute; - z-index: 1000000; - } - -#barometer_overlay * { - margin: 0; - padding: 0; - font-family: Arial, Helvetica, sans-serif; - font-style:normal; - font-variant:normal; - font-size: 12px; - color:#333; - } - -/* =Barometer Overlay -> Main ---------------------------------------------------------*/ - -#barometer_main { - width: 550px; - height: 100%; - margin: 0 auto; - z-index:2; - position:relative; - background-color: transparent; - } - -#barometer_main div { - padding: 5px 20px 0 20px; - margin:0; - background: #EEE; - overflow:none; - border-right: solid 2px #000; - border-left: solid 2px #000; - } - -#barometer_overlay #barometer_main #overlay_loading h2 { - padding: 10px 0; - font-size:28px; - } - -#barometer_overlay #barometer_main #barometer_close:hover { - background-position:-42px 0; - } - -#barometer_overlay #barometer_main a#barometer_close { - background-image:url(../images/barometer_close.png); - cursor:pointer; - height:42px; - outline-color:-moz-use-text-color; - outline-style:none; - outline-width:medium; - overflow:hidden; - position:absolute; - top:-23px; - right:-22px; - width:42px; - z-index:4; - border: none; - } - -#barometer_overlay #barometer_main span { - background:url(../images/close.png) no-repeat scroll 33px 0 transparent; - color:#FFFFFF; - cursor:pointer; - float:right; - font-size:11px; - height:20px; - padding-right:20px; - text-decoration:underline; -} - -#barometer_iframe { - width: 550px; - height: 100%; - background: transparent url(../images/barometer_loading.png) no-repeat; -} -#barometer_iframe.loaded { - background: transparent; -} - - -/* =Barometer Overlay -> Main -> Overlay header ---------------------------------------------------------*/ - -#barometer_overlay #barometer_main #overlay_header { - padding:6px 5px 1px 0; - background-color:#333; - font-weight: bold; - height:18px; - border: solid 2px #000; - } - -#barometer_overlay #barometer_main #overlay_header a { - color:#fff; - float:left; - font-size:15px; - margin-left:5px; - font-weight: normal; - } - -#barometer_overlay #barometer_main #overlay_header span { - float:right; - height:20px; - padding-right:20px; - background: transparent url(../images/close.png) no-repeat 33px 0; - text-decoration:underline; - font-size:11px; - cursor:pointer; - color: #fff; - } - -/* =Barometer screen id - used to close barometer ---------------------------------------------------------*/ - -#barometer_screen { - top:0; - left:0; - z-index:1; - width: 100%; - position: absolute; - background-color: #000; - opacity: 0.42; filter:alpha(opacity=42); -moz-opacity: 0.42; - } \ No newline at end of file +} \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index a05a85c3..1aad2082 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -66,8 +66,6 @@ <%= render :partial => 'layouts/templates' %> <%= render :partial => 'shared/metacodeBgColors' %> <%= render :partial => 'layouts/googleanalytics' if Rails.env.production? %> diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb deleted file mode 100644 index a109199a..00000000 --- a/config/initializers/redis.rb +++ /dev/null @@ -1,6 +0,0 @@ -if Rails.env.development? ## this also applies to metamaps.cc production mode - $redis = Redis.new(:host => 'localhost', :port=> 6379) -elsif Rails.env.production? ## this is for the heroku staging environment - uri = URI.parse(ENV["REDISTOGO_URL"]) - $redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password) -end \ No newline at end of file diff --git a/config/initializers/uservoice.rb b/config/initializers/uservoice.rb new file mode 100644 index 00000000..e9ff069b --- /dev/null +++ b/config/initializers/uservoice.rb @@ -0,0 +1,9 @@ +require 'uservoice-ruby' + +SSO_KEY = '3f0d5e3bbaff5ea7c95e549f75ebba8c' + +def current_sso_token + @current_sso_token ||= UserVoice.generate_sso_token('metamapscc', SSO_KEY, { + :email => current_user.email + }, 300) # Default expiry time is 5 minutes = 300 seconds +end \ No newline at end of file From 9ba6daec90b111c26c6ae43ee25da9c5415eb70c Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Tue, 7 Oct 2014 15:39:11 -0400 Subject: [PATCH 2/2] further fixed uservoice to identify user --- app/assets/javascripts/lib/uservoice.js | 9 +++++++-- app/views/layouts/application.html.erb | 2 +- config/initializers/uservoice.rb | 4 +--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/lib/uservoice.js b/app/assets/javascripts/lib/uservoice.js index 7676736d..991beff8 100644 --- a/app/assets/javascripts/lib/uservoice.js +++ b/app/assets/javascripts/lib/uservoice.js @@ -3,7 +3,7 @@ if(USERVOICE == undefined) { USERVOICE = {}; } -USERVOICE.load = function (sso_token) { +USERVOICE.load = function (name, id, email, sso_token) { // Include the UserVoice JavaScript SDK (only needed once on a page) UserVoice=window.UserVoice||[];(function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/wybK0nSMNuhlWkIKzTyWg.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})(); @@ -21,8 +21,13 @@ UserVoice.push(['set', { // Identify the user and pass traits // To enable, replace sample data with actual user traits and uncomment the line -if (sso_token) { +if (name) { UserVoice.push(['setSSO', sso_token]); + UserVoice.push(['identify', { + 'email': email, // User’s email address + 'name': name, // User’s real name + 'id': id, // Optional: Unique id of the user + }]); } // Add default trigger to the bottom-left corner of the window: diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1aad2082..b0e0dcca 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -90,7 +90,7 @@ // set up uservoice with signed in user <% if authenticated? %> - USERVOICE.load("<%= current_sso_token %>"); + USERVOICE.load(Metamaps.Active.Mapper.name, Metamaps.Active.Mapper.id, "<%= user.email %>", "<%= current_sso_token %>"); <% else %> USERVOICE.load(); <% end %> diff --git a/config/initializers/uservoice.rb b/config/initializers/uservoice.rb index e9ff069b..3b010613 100644 --- a/config/initializers/uservoice.rb +++ b/config/initializers/uservoice.rb @@ -1,9 +1,7 @@ require 'uservoice-ruby' -SSO_KEY = '3f0d5e3bbaff5ea7c95e549f75ebba8c' - def current_sso_token - @current_sso_token ||= UserVoice.generate_sso_token('metamapscc', SSO_KEY, { + @current_sso_token ||= UserVoice.generate_sso_token('metamapscc', ENV['SSO_KEY'], { :email => current_user.email }, 300) # Default expiry time is 5 minutes = 300 seconds end \ No newline at end of file