Permalink
Browse files

Attempting to extract direct references to DP and Watchdog and other …

…URLs to external settings.
  • Loading branch information...
1 parent 3bbeddf commit 80f1930594e7e027e056a9e57ccaa74bef6c391d @bguthrie bguthrie committed Aug 6, 2013
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -1,7 +1,12 @@
var donation = (function() {
- function sendDonationTrackRequest(){
+ function sendDonationTrackRequest() {
+ var btn = $(this),
+ business = btn.data("business"),
+ item_name = btn.data("item-name");
+
+
$.post(VK.donation_tracking_url, {
- petition_id: VK.petition_id,
+ petition_id: VK.petition_id,
referral_code: VK.ref_code,
signature_id: VK.signature_id
}, function() {
@@ -12,10 +17,10 @@ var donation = (function() {
function buildPaypalUrl() {
var params = [
'cmd=_donations',
- 'business=info@demandprogress.org',
+ 'business=' + VK.contact_email,
+ 'item_name=' + VK.support_email.replace(/@/, "%20"),
+ 'item_number=' + $.cookie('member_id'),
'lc=US',
- 'item_name=Support%20Watchdog.net',
- 'item_number='+$.cookie('member_id'),
'no_note=1',
'no_shipping=1',
'currency_code=USD',
@@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base
include Whiplash
extend Memoist
helper_method :win!, :spin!, :spin_if_cool_browser!, :measure!, :is_admin
-
+
protect_from_forgery
before_filter :add_environment_to_title, :stash_http_referer, :add_contact_url_to_footer
@@ -15,10 +15,10 @@ def retrieve_http_referer
end
def add_environment_to_title
- @title = "Watchdog.net"
- @title << " - #{Rails.env}" unless Rails.env.production?
+ @title = Settings.site.name
+ @title << " - #{Rails.env}" unless Rails.env.production?
end
-
+
def add_contact_url_to_footer
@contact_url = contact_path
end
@@ -51,14 +51,14 @@ def current_user
@current_user ||= User.find_by_id(session[:user_id]) if session[:user_id]
end
helper_method :current_user
-
+
def require_login
if current_user.nil?
session['redirect_url'] = request.url
redirect_to login_path
end
end
-
+
def require_admin
if current_user.nil? #@@ is there some way to DRY this with the function above?
session['redirect_url'] = request.url
@@ -71,7 +71,7 @@ def require_admin
def render_403
render :file => "#{Rails.root}/public/403", :formats => [:html], :status => 403
end
-
+
def is_admin
current_user && (current_user.is_super_user || current_user.is_admin)
end
@@ -45,9 +45,9 @@ def petition_link petition, email, is_preview=false
end
end
- def compose(petition, member, email, petition_link, raw_petition_link)
+ def compose(petition, member, email, petition_link, raw_petition_link)
#raw_petition_link is the url without the tracking param. There must be a nicer way to do this
-
+
email_hash = email.to_hash
email_experiment = EmailExperiments.new(email)
@@ -60,6 +60,10 @@ def compose(petition, member, email, petition_link, raw_petition_link)
@fb_share_url = "https://www.facebook.com/sharer/sharer.php?u=#{raw_petition_link}?mail_share_ref=#{email_hash}"
@image_url = email_experiment.image_url
@short_summary = email_experiment.petition_short_summary
+
+ mailbox, domain = Settings.site.list_unsubscribe.split("@")
+ address = "mailto:#{mailbox}+#{email_hash}@#{domain}"
+
headers["List-Unsubscribe"] = "mailto:unsubscribe+" + email_hash + "@appmail.watchdog.net"
mail = mail(
@@ -1,10 +1,12 @@
class UserFeedbackMailer < ActionMailer::Base
def new_message(feedback)
@feedback = feedback
- mail({
- from: "#{feedback.name} <info@watchdog.net>",
- subject: "Feedback from #{feedback.email || feedback.name || 'anon'} about act.watchdog.net",
- to: "me+watchdog@aaronsw.com",
- template_name: 'new_message'}).deliver
+
+ mail(
+ from: "#{feedback.name} <#{Settings.site.email}>",
+ subject: "Feedback from #{feedback.email || feedback.name || 'anon'} about #{Settings.site.name}",
+ to: Settings.site.feedback_email,
+ template_name: 'new_message'
+ ).deliver
end
end
View
@@ -142,8 +142,10 @@ def strip_chart gauge, averaging_window, thresholds=[]
from = "1#{timeframe}"
main = "movingAverage(#{gauge}, #{averaging_window})"
timeshift = "timeShift(#{main}, '#{from}')"
+
+ baseUri = "http://#{$statsd.hostname}/render"
u = <<-url
-http://graphite.watchdog.net/render?\
+#{baseUri}?\
target=color(lineWidth(#{timeshift}, 2), 'dddddd')&\
target=color(lineWidth(#{main}, 2), 'blue')&\
#{thresholds.join('&')}&\
@@ -166,31 +166,32 @@
.span7
#charts
- %span
- = link_to_self_with_param :t, Statistics::TIMEFRAMES, " | "
- %span{style:"padding-left:350px"}
- %span{style:"color:blue;font-weight:bold"}
- &#x2015;
- %span
- current
- %span{style:"color:#dddddd;font-weight:bold"}
- &#x2015;
- %span
- prior
- %h3 NPS
- %iframe{ src: nps_chart, style: "border:none", height: "180px" }
-
- %h3 Facebook Actions
- %iframe{ src: facebook_actions_chart, style: "border:none", height: "180px" }
-
- %h3 Facebook Referrals
- %iframe{ src: facebook_referrals_chart, style: "border:none", height: "180px" }
-
- %h3 Unsubscribed
- %iframe{ src: unsubscribes_chart, style: "border:none", height: "180px" }
-
- %h3 Sent
- %iframe{ src: emails_sent_chart, style: "border:none", height: "180px" }
+ - unless Rails.env.test?
+ %span
+ = link_to_self_with_param :t, Statistics::TIMEFRAMES, " | "
+ %span{style:"padding-left:350px"}
+ %span{style:"color:blue;font-weight:bold"}
+ &#x2015;
+ %span
+ current
+ %span{style:"color:#dddddd;font-weight:bold"}
+ &#x2015;
+ %span
+ prior
+ %h3 NPS
+ %iframe{ src: nps_chart, style: "border:none", height: "180px" }
+
+ %h3 Facebook Actions
+ %iframe{ src: facebook_actions_chart, style: "border:none", height: "180px" }
+
+ %h3 Facebook Referrals
+ %iframe{ src: facebook_referrals_chart, style: "border:none", height: "180px" }
+
+ %h3 Unsubscribed
+ %iframe{ src: unsubscribes_chart, style: "border:none", height: "180px" }
+
+ %h3 Sent
+ %iframe{ src: emails_sent_chart, style: "border:none", height: "180px" }
- content_for :javascripts do
$(document).ready(setInterval(function(){$('#dashboard').load(window.location.href + ' #dashboard');}, 60000));
@@ -34,7 +34,7 @@
.container
.span12
.copyright
- © 2012 Demand Progress (<a href="#{@contact_url}">contact us</a>)
+ © 2013 #{Settings.organization.name} (<a href="#{@contact_url}">contact us</a>)
= javascript_include_tag :application
%script{type: "text/javascript"}
@@ -1,16 +1,18 @@
= javascript_include_tag "http://connect.facebook.net/en_US/all.js#xfbml=1"
- content_for :javascripts do
- @modal_coloring = spin! "modal coloring", :share, ["white-box-on-blackout", "white-box-on-dark"]
- VK.modal_coloring = '#{@modal_coloring}';
- VK.signing_from_email = '#{@signing_from_email}';
- VK.petition_id = '#{@petition.id}';
- VK.petition_title = '#{j @petition.title}';
- VK.signature_id = '#{@signature.id}';
- VK.social_tracking_url = '#{social_tracking_url}';
+ VK.modal_coloring = '#{@modal_coloring}';
+ VK.signing_from_email = '#{@signing_from_email}';
+ VK.petition_id = '#{@petition.id}';
+ VK.petition_title = '#{j @petition.title}';
+ VK.signature_id = '#{@signature.id}';
+ VK.social_tracking_url = '#{social_tracking_url}';
VK.donation_tracking_url = '#{donation_tracking_url}';
VK.facebook_sharing_type = '#{facebook_sharing_option}';
- VK.facebook_friend_ids = '#{j @facebook_friend_ids}';
- VK.ref_code = '#{j @signer_code.code}';
+ VK.facebook_friend_ids = '#{j @facebook_friend_ids}';
+ VK.ref_code = '#{j @signer_code.code}';
+ VK.admin_email = '#{Settings.organization.email}';
+ VK.support_email = '#{Settings.site.email}';
-#We only want to run this experiment if we're using the recommendation dialog
- if facebook_sharing_option == 'facebook_recommendation'
@@ -12,7 +12,7 @@ Greetings VictoryKit team member. When you change this template, please test it
<table width="180"style="width:180px;max-width:180px;">
<tr>
<td style="font-weight:bold;margin-bottom:15px;">
- <%=@short_summary %>
+ <%= @short_summary %>
</td>
</tr>
<tr>
@@ -56,21 +56,21 @@ Greetings VictoryKit team member. When you change this template, please test it
</tr>
</table>
<div>
- <p>Dear <%=@member.full_name%>,</p>
+ <p>Dear <%= @member.full_name %>,</p>
<p>
- <%=sanitize(@petition.description_lsub("<b><a href='#{@petition_link}'>Click here to sign -- it just takes a second.</a></b>"))%>
+ <%= sanitize(@petition.description_lsub("<b><a href='#{@petition_link}'>Click here to sign -- it just takes a second.</a></b>")) %>
</p>
- <p><b><a style="font-size:125%" href="<%=@petition_link%>">Click here to sign -- it just takes a second.</a></b></p>
+ <p><b><a style="font-size:125%" href="<%= @petition_link %>">Click here to sign -- it just takes a second.</a></b></p>
<p>Thanks,<br/>
- -- The folks at Watchdog.net</p>
+ <%= t("site.email_signature") %></p>
- <p>P.S. If the other links aren't working for you, please go here to sign: <a href="<%=@petition_link%>"><%=@petition_link%></a></p>
+ <p>P.S. If the other links aren't working for you, please go here to sign: <a href="<%= @petition_link %>"><%=@petition_link%></a></p>
</div>
</div>
<hr style="clear:both;"/>
-<p style="font-size:50%">This email was sent by watchdog.net. To remove yourself from this list, <a href="<%=@unsubscribe_link%>">click here</a>.</p>
+<p style="font-size:50%">This email was sent by <%= Settings.site.name %>. To remove yourself from this list, <a href="<%= @unsubscribe_link %>">click here</a>.</p>
-<img src="<%=@tracking_url%>" />
+<img src="<%= @tracking_url %>" />
@@ -1,12 +1,12 @@
-Dear <%=@member.full_name%>,
+Dear <%= @member.full_name %>,
-<%=@petition.plain_text_description.html_safe%>
+<%= @petition.plain_text_description.html_safe %>
-Please, sign this petition at <%=@petition_link%>
+Please, sign this petition at <%= @petition_link %>
Thanks,
- -- The folks at Watchdog.net
+ <%= t("site.email_signature") %>
-----------------------------
-To stop receiving emails from us, go to: <%=@unsubscribe_link%>
+To stop receiving emails from us, go to: <%= @unsubscribe_link %>
@@ -6,7 +6,8 @@
%span.icon-bar
%span.icon-bar
- = link_to 'WATCHDOG.NET', '/', class: 'logo'
+ = link_to root_path, class: 'logo' do
+ = image_tag Settings.organization.logo, style: "height: 40px; vertical-align: top"
.nav-collapse.in.collapse
%ul.nav.pull-right
- if is_admin
@@ -12,5 +12,5 @@
&nbsp;
%p
- %a{href: "https://act.demandprogress.org/unsubscribe/unsubscribe?source=watchdog"}
- To unsubscribe from all emails from Demand Progress, click here.
+ %a{href: Settings.organization.unsubscribe_url}
+ To unsubscribe from all emails from #{Settings.organization.name}, click here.
View
@@ -7,6 +7,7 @@ en:
refine: "Optionally, select a list of specific locations."
site:
privacy_policy: "We don't share your email address without your permission. We will send you updates on important campaigns by email, but you can unsubscribe at any time."
+ email_signature: "-- The folks at Watchdog.net"
activerecord:
attributes:
user:
View
@@ -16,3 +16,14 @@ dp_connection:
database: OVERRIDE_ME
cloudmailin:
token: <%= ENV["CLOUDMAILIN_TOKEN"] %>
+organization:
+ name: "Demand Progress"
+ email: "info@demandprogress.org"
+ unsubscribe_url: "https://act.demandprogress.org/unsubscribe/unsubscribe?source=watchdog"
+ logo: 'logo.png'
+site:
+ name: "Watchdog.net"
+ email: "support@watchdog.net"
+ hostname: "act.watchdog.net"
+ feedback_email: info+watchdog@demandprogress.org
+ list_unsubscribe: "unsubscribe@appmail.watchdog.net"
View
@@ -1,24 +0,0 @@
-id: 164da6d0-6c66-012f-a3f5-12313d2df0b0
-setup:
- commands:
- - bundle install --without development production
- - bundle exec rake db:migrate
-test:
- commands:
- - bundle exec rails s -d
- - bundle exec rake
-deploy:
- branch: master
- heroku:
- staging:
- name: actwatchdog-staging
- restore_production: true
- migrate: true
- branch: master
- production:
- name: actwatchdog
- backup: true
- migrate: true
- branch: master
-ruby_versions:
- - 1.9.3
@@ -1,8 +0,0 @@
-#!/bin/sh
-heroku create --stack cedar --remote testserver
-git push testserver master
-heroku addons:add pgbackups --remote testserver
-heroku pgbackups:restore DATABASE `heroku pgbackups:url --app actwatchdog` --remote testserver
-heroku run rake db:migrate --remote testserver
-heroku addons:add redistogo:nano --remote testserver
-heroku open --remote testserver
@@ -1,14 +1,15 @@
describe 'dashboard' do
-
+
context 'an admin' do
let(:user) { create :admin_user }
it 'should see stats for a petition', js: true, driver: :webkit do
login user.email, user.password do
visit '/admin/petitions'
+ sleep 60
wait_until do
not find('tbody').text.empty?
- end
+ end
end
end
end
@@ -8,7 +8,7 @@
end
it "sends feedback to aaron" do
- mail.header[:to].to_s.should == "me+watchdog@aaronsw.com"
+ mail.header[:to].to_s.should == Settings.site.feedback_email
end
it "should include the user's email in the subject" do
Oops, something went wrong.

0 comments on commit 80f1930

Please sign in to comment.