Skip to content
This repository has been archived by the owner on Mar 20, 2018. It is now read-only.

Commit

Permalink
Attempting to extract direct references to DP and Watchdog and other …
Browse files Browse the repository at this point in the history
…URLs to external settings.
  • Loading branch information
bguthrie committed Aug 6, 2013
1 parent 3bbeddf commit 80f1930
Show file tree
Hide file tree
Showing 20 changed files with 112 additions and 106 deletions.
Binary file added app/assets/images/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 10 additions & 5 deletions app/assets/javascripts/donation.js
@@ -1,7 +1,12 @@
var donation = (function() { 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, { $.post(VK.donation_tracking_url, {
petition_id: VK.petition_id, petition_id: VK.petition_id,
referral_code: VK.ref_code, referral_code: VK.ref_code,
signature_id: VK.signature_id signature_id: VK.signature_id
}, function() { }, function() {
Expand All @@ -12,10 +17,10 @@ var donation = (function() {
function buildPaypalUrl() { function buildPaypalUrl() {
var params = [ var params = [
'cmd=_donations', 'cmd=_donations',
'business=info@demandprogress.org', 'business=' + VK.contact_email,
'item_name=' + VK.support_email.replace(/@/, "%20"),
'item_number=' + $.cookie('member_id'),
'lc=US', 'lc=US',
'item_name=Support%20Watchdog.net',
'item_number='+$.cookie('member_id'),
'no_note=1', 'no_note=1',
'no_shipping=1', 'no_shipping=1',
'currency_code=USD', 'currency_code=USD',
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/application_controller.rb
Expand Up @@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base
include Whiplash include Whiplash
extend Memoist extend Memoist
helper_method :win!, :spin!, :spin_if_cool_browser!, :measure!, :is_admin helper_method :win!, :spin!, :spin_if_cool_browser!, :measure!, :is_admin

protect_from_forgery protect_from_forgery
before_filter :add_environment_to_title, :stash_http_referer, :add_contact_url_to_footer before_filter :add_environment_to_title, :stash_http_referer, :add_contact_url_to_footer


Expand All @@ -15,10 +15,10 @@ def retrieve_http_referer
end end


def add_environment_to_title def add_environment_to_title
@title = "Watchdog.net" @title = Settings.site.name
@title << " - #{Rails.env}" unless Rails.env.production? @title << " - #{Rails.env}" unless Rails.env.production?
end end

def add_contact_url_to_footer def add_contact_url_to_footer
@contact_url = contact_path @contact_url = contact_path
end end
Expand Down Expand Up @@ -51,14 +51,14 @@ def current_user
@current_user ||= User.find_by_id(session[:user_id]) if session[:user_id] @current_user ||= User.find_by_id(session[:user_id]) if session[:user_id]
end end
helper_method :current_user helper_method :current_user

def require_login def require_login
if current_user.nil? if current_user.nil?
session['redirect_url'] = request.url session['redirect_url'] = request.url
redirect_to login_path redirect_to login_path
end end
end end

def require_admin def require_admin
if current_user.nil? #@@ is there some way to DRY this with the function above? if current_user.nil? #@@ is there some way to DRY this with the function above?
session['redirect_url'] = request.url session['redirect_url'] = request.url
Expand All @@ -71,7 +71,7 @@ def require_admin
def render_403 def render_403
render :file => "#{Rails.root}/public/403", :formats => [:html], :status => 403 render :file => "#{Rails.root}/public/403", :formats => [:html], :status => 403
end end

def is_admin def is_admin
current_user && (current_user.is_super_user || current_user.is_admin) current_user && (current_user.is_super_user || current_user.is_admin)
end end
Expand Down
8 changes: 6 additions & 2 deletions app/mailers/scheduled_mailer.rb
Expand Up @@ -45,9 +45,9 @@ def petition_link petition, email, is_preview=false
end end
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 #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_hash = email.to_hash
email_experiment = EmailExperiments.new(email) email_experiment = EmailExperiments.new(email)


Expand All @@ -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}" @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 @image_url = email_experiment.image_url
@short_summary = email_experiment.petition_short_summary @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" headers["List-Unsubscribe"] = "mailto:unsubscribe+" + email_hash + "@appmail.watchdog.net"


mail = mail( mail = mail(
Expand Down
12 changes: 7 additions & 5 deletions app/mailers/user_feedback_mailer.rb
@@ -1,10 +1,12 @@
class UserFeedbackMailer < ActionMailer::Base class UserFeedbackMailer < ActionMailer::Base
def new_message(feedback) def new_message(feedback)
@feedback = feedback @feedback = feedback
mail({
from: "#{feedback.name} <info@watchdog.net>", mail(
subject: "Feedback from #{feedback.email || feedback.name || 'anon'} about act.watchdog.net", from: "#{feedback.name} <#{Settings.site.email}>",
to: "me+watchdog@aaronsw.com", subject: "Feedback from #{feedback.email || feedback.name || 'anon'} about #{Settings.site.name}",
template_name: 'new_message'}).deliver to: Settings.site.feedback_email,
template_name: 'new_message'
).deliver
end end
end end
4 changes: 3 additions & 1 deletion app/models/statistics.rb
Expand Up @@ -142,8 +142,10 @@ def strip_chart gauge, averaging_window, thresholds=[]
from = "1#{timeframe}" from = "1#{timeframe}"
main = "movingAverage(#{gauge}, #{averaging_window})" main = "movingAverage(#{gauge}, #{averaging_window})"
timeshift = "timeShift(#{main}, '#{from}')" timeshift = "timeShift(#{main}, '#{from}')"

baseUri = "http://#{$statsd.hostname}/render"
u = <<-url u = <<-url
http://graphite.watchdog.net/render?\ #{baseUri}?\
target=color(lineWidth(#{timeshift}, 2), 'dddddd')&\ target=color(lineWidth(#{timeshift}, 2), 'dddddd')&\
target=color(lineWidth(#{main}, 2), 'blue')&\ target=color(lineWidth(#{main}, 2), 'blue')&\
#{thresholds.join('&')}&\ #{thresholds.join('&')}&\
Expand Down
51 changes: 26 additions & 25 deletions app/views/admin/dashboard/index.html.haml
Expand Up @@ -166,31 +166,32 @@
.span7 .span7
#charts #charts
%span - unless Rails.env.test?
= link_to_self_with_param :t, Statistics::TIMEFRAMES, " | " %span
%span{style:"padding-left:350px"} = link_to_self_with_param :t, Statistics::TIMEFRAMES, " | "
%span{style:"color:blue;font-weight:bold"} %span{style:"padding-left:350px"}
&#x2015; %span{style:"color:blue;font-weight:bold"}
%span &#x2015;
current %span
%span{style:"color:#dddddd;font-weight:bold"} current
&#x2015; %span{style:"color:#dddddd;font-weight:bold"}
%span &#x2015;
prior %span
%h3 NPS prior
%iframe{ src: nps_chart, style: "border:none", height: "180px" } %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 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 Facebook Referrals

%iframe{ src: facebook_referrals_chart, style: "border:none", height: "180px" }
%h3 Unsubscribed
%iframe{ src: unsubscribes_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" } %h3 Sent
%iframe{ src: emails_sent_chart, style: "border:none", height: "180px" }


- content_for :javascripts do - content_for :javascripts do
$(document).ready(setInterval(function(){$('#dashboard').load(window.location.href + ' #dashboard');}, 60000)); $(document).ready(setInterval(function(){$('#dashboard').load(window.location.href + ' #dashboard');}, 60000));
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.haml
Expand Up @@ -34,7 +34,7 @@
.container .container
.span12 .span12
.copyright .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 = javascript_include_tag :application
%script{type: "text/javascript"} %script{type: "text/javascript"}
Expand Down
18 changes: 10 additions & 8 deletions app/views/petitions/_javascript_content.html.haml
@@ -1,16 +1,18 @@
= javascript_include_tag "http://connect.facebook.net/en_US/all.js#xfbml=1" = javascript_include_tag "http://connect.facebook.net/en_US/all.js#xfbml=1"
- content_for :javascripts do - content_for :javascripts do
- @modal_coloring = spin! "modal coloring", :share, ["white-box-on-blackout", "white-box-on-dark"] - @modal_coloring = spin! "modal coloring", :share, ["white-box-on-blackout", "white-box-on-dark"]
VK.modal_coloring = '#{@modal_coloring}'; VK.modal_coloring = '#{@modal_coloring}';
VK.signing_from_email = '#{@signing_from_email}'; VK.signing_from_email = '#{@signing_from_email}';
VK.petition_id = '#{@petition.id}'; VK.petition_id = '#{@petition.id}';
VK.petition_title = '#{j @petition.title}'; VK.petition_title = '#{j @petition.title}';
VK.signature_id = '#{@signature.id}'; VK.signature_id = '#{@signature.id}';
VK.social_tracking_url = '#{social_tracking_url}'; VK.social_tracking_url = '#{social_tracking_url}';
VK.donation_tracking_url = '#{donation_tracking_url}'; VK.donation_tracking_url = '#{donation_tracking_url}';
VK.facebook_sharing_type = '#{facebook_sharing_option}'; VK.facebook_sharing_type = '#{facebook_sharing_option}';
VK.facebook_friend_ids = '#{j @facebook_friend_ids}'; VK.facebook_friend_ids = '#{j @facebook_friend_ids}';
VK.ref_code = '#{j @signer_code.code}'; 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 -#We only want to run this experiment if we're using the recommendation dialog
- if facebook_sharing_option == 'facebook_recommendation' - if facebook_sharing_option == 'facebook_recommendation'
Expand Down
16 changes: 8 additions & 8 deletions app/views/scheduled_mailer/new_petition.html.erb
Expand Up @@ -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;"> <table width="180"style="width:180px;max-width:180px;">
<tr> <tr>
<td style="font-weight:bold;margin-bottom:15px;"> <td style="font-weight:bold;margin-bottom:15px;">
<%=@short_summary %> <%= @short_summary %>
</td> </td>
</tr> </tr>
<tr> <tr>
Expand Down Expand Up @@ -56,21 +56,21 @@ Greetings VictoryKit team member. When you change this template, please test it
</tr> </tr>
</table> </table>
<div> <div>
<p>Dear <%=@member.full_name%>,</p> <p>Dear <%= @member.full_name %>,</p>


<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>
<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/> <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>
</div> </div>


<hr style="clear:both;"/> <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 %>" />
10 changes: 5 additions & 5 deletions app/views/scheduled_mailer/new_petition.text.erb
@@ -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, 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 %>
3 changes: 2 additions & 1 deletion app/views/shared/_navigation.html.haml
Expand Up @@ -6,7 +6,8 @@
%span.icon-bar %span.icon-bar
%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 .nav-collapse.in.collapse
%ul.nav.pull-right %ul.nav.pull-right
- if is_admin - if is_admin
Expand Down
4 changes: 2 additions & 2 deletions app/views/unsubscribes/new.html.haml
Expand Up @@ -12,5 +12,5 @@
&nbsp; &nbsp;


%p %p
%a{href: "https://act.demandprogress.org/unsubscribe/unsubscribe?source=watchdog"} %a{href: Settings.organization.unsubscribe_url}
To unsubscribe from all emails from Demand Progress, click here. To unsubscribe from all emails from #{Settings.organization.name}, click here.
1 change: 1 addition & 0 deletions config/locales/en.yml
Expand Up @@ -7,6 +7,7 @@ en:
refine: "Optionally, select a list of specific locations." refine: "Optionally, select a list of specific locations."
site: 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." 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: activerecord:
attributes: attributes:
user: user:
Expand Down
11 changes: 11 additions & 0 deletions config/settings.yml
Expand Up @@ -16,3 +16,14 @@ dp_connection:
database: OVERRIDE_ME database: OVERRIDE_ME
cloudmailin: cloudmailin:
token: <%= ENV["CLOUDMAILIN_TOKEN"] %> 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"
24 changes: 0 additions & 24 deletions railsonfire.yml

This file was deleted.

8 changes: 0 additions & 8 deletions script/create_test_server

This file was deleted.

5 changes: 3 additions & 2 deletions spec/features/dashboard_spec.rb
@@ -1,14 +1,15 @@
describe 'dashboard' do describe 'dashboard' do

context 'an admin' do context 'an admin' do
let(:user) { create :admin_user } let(:user) { create :admin_user }


it 'should see stats for a petition', js: true, driver: :webkit do it 'should see stats for a petition', js: true, driver: :webkit do
login user.email, user.password do login user.email, user.password do
visit '/admin/petitions' visit '/admin/petitions'
sleep 60
wait_until do wait_until do
not find('tbody').text.empty? not find('tbody').text.empty?
end end
end end
end end
end end
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/user_feedback_mailer_spec.rb
Expand Up @@ -8,7 +8,7 @@
end end


it "sends feedback to aaron" do 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 end


it "should include the user's email in the subject" do it "should include the user's email in the subject" do
Expand Down

0 comments on commit 80f1930

Please sign in to comment.