aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/CrossSell.pm135
-rw-r--r--perllib/Page.pm3
-rwxr-xr-xweb/alert.cgi8
-rwxr-xr-xweb/confirm.cgi6
-rwxr-xr-xweb/contact.cgi4
-rw-r--r--web/css.css7
-rwxr-xr-xweb/questionnaire.cgi5
7 files changed, 134 insertions, 34 deletions
diff --git a/perllib/CrossSell.pm b/perllib/CrossSell.pm
index 909d3b990..0955ec192 100644
--- a/perllib/CrossSell.pm
+++ b/perllib/CrossSell.pm
@@ -9,7 +9,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: CrossSell.pm,v 1.2 2007-09-25 13:30:21 matthew Exp $
+# $Id: CrossSell.pm,v 1.3 2008-01-30 18:27:47 matthew Exp $
# Config parameters site needs set to call these functions:
# OPTION_AUTH_SHARED_SECRET
@@ -23,43 +23,136 @@ $ua->timeout(5);
use URI::Escape;
use mySociety::AuthToken;
-# Force site means always display this advert
-sub display_hfymp_advert ($;$$) {
- my ($user_email, $user_name, $postcode) = @_;
- my $auth_signature = mySociety::AuthToken::sign_with_shared_secret($user_email, mySociety::Config::get('AUTH_SHARED_SECRET'));
+sub display_random_hfymp_advert {
+ my ($email, $name, $text) = @_;
+ my $auth_signature = mySociety::AuthToken::sign_with_shared_secret($email, mySociety::Config::get('AUTH_SHARED_SECRET'));
# See if already signed up
my $url = mySociety::Config::get('HEARFROMYOURMP_BASE_URL');
- my $already_signed = get($url . '/authed?email=' . uri_escape($user_email) . "&sign=" . uri_escape($auth_signature));
+ my $already_signed = get($url . '/authed?email=' . uri_escape($email) . "&sign=" . uri_escape($auth_signature));
+ # Different from PHP version; display this advert if e.g. connection problem
+ return '' if $already_signed && $already_signed eq 'already signed';
+
+ $email = ent($email);
+ $name = ent($name);
+ $auth_signature = ent($auth_signature);
+ $text =~ s#\[form\]#<form action="http://www.hearfromyourmp.com/" method="post">
+<input type="hidden" name="name" value="$name">
+<input type="hidden" name="email" value="$email">
+<input type="hidden" name="sign" value="$auth_signature">
+<h2><input style="font-size:100%" type="submit" value="#;
+ $text =~ s#\[/form\]#"></h2>#;
+
+ return '<div style="text-align:center">' . $text . '</div>';
+}
+
+sub display_random_gny_advert {
+ my ($email, $name, $text) = @_;
+ return '<div id="advert_thin">' . $text . '</div>';
+}
+
+sub display_random_twfy_alerts_advert {
+ my ($email, $name, $text) = @_;
+ my $auth_signature = mySociety::AuthToken::sign_with_shared_secret($email, mySociety::Config::get('AUTH_SHARED_SECRET'));
+ $text =~ s#\[button\]#<form action="http://www.theyworkforyou.com/alert/" method="post">
+<input type="hidden" name="email" value="$email">
+<input type="hidden" name="sign" value="$auth_signature">
+<input type="hidden" name="site" value="fms">
+<input style="font-size:150%" type="submit" value="'#;
+ $text =~ s#\[/button\]#"></p>#;
+ return '<div id="advert_thin" style="text-align:center">' . $text . '</div>';
+}
+
+sub display_hfyc_cheltenham_advert {
+ my ($email, $name) = @_;
+ my $auth_signature = mySociety::AuthToken::sign_with_shared_secret($email, mySociety::Config::get('AUTH_SHARED_SECRET'));
+
+ # See if already signed up
+ my $already_signed = get('http://cheltenham.hearfromyourcouncillor.com/authed?email=' . uri_escape($email) . "&sign=" . uri_escape($auth_signature));
# Different from PHP version; display this advert if e.g. connection problem
return '' if $already_signed && $already_signed eq 'already signed';
# If not, display advert
- $url .= '/?email=' . uri_escape($user_email) . '&sign=' . uri_escape($auth_signature);
- $url .= '&name=' . uri_escape($user_name) if $user_name;
- $url .= '&pc=' . uri_escape($postcode) if $postcode;
- return <<EOF;
-<h2 style="padding: 1em; font-size: 200%" align="center">
-Since you're interested in your local area, why not
-start a <a href="$url">long term relationship</a> with your MP?
-</h2>
+ $email = ent($email);
+ $name = ent($name);
+ $auth_signature = ent($auth_signature);
+ my $out = <<EOF;
+<form action="http://cheltenham.hearfromyourcouncillor.com/" method="post">
+<input type="hidden" name="name" value="$name">
+<input type="hidden" name="email" value="$email">
+<input type="hidden" name="sign" value="$auth_signature">
+<div id="advert_thin">
+EOF
+
+ my $rand = int(rand(2));
+ if ($rand == 0) {
+ $out .= "<h2>Cool! You're interested in Cheltenham!</h2>
+ <p>We've got an exciting new free service that works exclusively
+ for people in Cheltenham. Please sign up to help the charity
+ that runs WriteToThem, and to get a sneak preview of our new
+ service.</p>";
+ } else {
+ $out .= "<h2>Get to know your councillors.</h2>
+ <p>Local councillors are really important, but hardly anyone knows them.
+ Use our new free service to build a low-effort, long term relationship
+ with your councillor.</p>";
+ }
+ $out .= <<EOF;
+<p align="center">
+<input type="submit" value="Sign up to HearFromYourCouncillor">
+</p>
+</div>
+</form>
EOF
- return 1;
+ return ($out, "cheltenhamhfyc$rand");
}
# Choose appropriate advert and display it.
# $this_site is to stop a site advertising itself.
-sub display_advert ($;$$) {
- my ($user_email, $user_name, $postcode) = @_;
- my $out = display_hfymp_advert($user_email, $user_name, $postcode);
- # $out ||= display_twfy_alerts_advert($user_email, $postcode);
- $out ||= <<EOF;
+sub display_advert ($$;$%) {
+ my ($q, $email, $name, %data) = @_;
+
+ if (defined $data{council} && $data{council} eq '2326') {
+ my ($out, $ad) = display_hfyc_cheltenham_advert($email, $name);
+ if ($out) {
+ $q->{scratch} = $ad;
+ return $out;
+ }
+ }
+
+ my @adverts = (
+ [ 'gny', '<h2>Are you a member of a local group&hellip;</h2> &hellip;which uses the internet to coordinate itself, such as a neighbourhood watch? If so, please help the charity that runs WriteToThem by <a href="http://www.groupsnearyou.com/">adding some information about it</a> to our new site, GroupsNearYou.' ],
+ # Since you're interested in your local area, why not
+ # start a long term relationship with your MP?
+ [ 'hfymp', '<h2 style="margin-bottom:0">Get email from your MP in the future</h2> <p style="font-size:120%;margin-top:0;">and have a chance to discuss what they say in a public forum [form]Sign up to HearFromYourMP[/form]' ],
+ [ 'twfy_alerts', '<h2>Get emailed every time your MP says something in Parliament</h2> [button]Keep an eye on them for free![/button]' ],
+ );
+ while (@adverts) {
+ my $rand = int(rand(scalar @adverts));
+ my ($advert_site, $advert_text) = @{$adverts[$rand]};
+ my $func = "display_random_${advert_site}_advert";
+ no strict 'refs';
+ my $out = &$func($email, $name, $advert_text);
+ use strict 'refs';
+ if ($out) {
+ $q->{scratch} = $advert_site . $rand;
+ return $out;
+ }
+
+ my @new_adverts;
+ foreach my $advert (@adverts) {
+ push @new_adverts, $advert if $advert_site != $advert->[0];
+ }
+ @adverts = @new_adverts;
+ }
+
+ $q->{scratch} = 'pb';
+ return <<EOF;
<h2 style="padding: 1em; font-size: 200%" align="center">
If you're interested in improving your local area,
<a href="http://www.pledgebank.com/">use PledgeBank</a> to
do so with other people!</h2>
EOF
- return $out;
}
1;
diff --git a/perllib/Page.pm b/perllib/Page.pm
index 8ae6a2fe3..05324cab6 100644
--- a/perllib/Page.pm
+++ b/perllib/Page.pm
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Page.pm,v 1.72 2008-01-28 15:27:00 matthew Exp $
+# $Id: Page.pm,v 1.73 2008-01-30 18:27:47 matthew Exp $
#
package Page;
@@ -119,6 +119,7 @@ sub footer {
my ($q, $extra) = @_;
my $pc = $q->param('pc') || '';
$pc = "?pc=" . ent($pc) if $pc;
+ $extra = $q->scratch() if $q->scratch(); # Overrides
my $track = mySociety::Tracking::code($q, $extra);
return <<EOF;
</div></div>
diff --git a/web/alert.cgi b/web/alert.cgi
index 31a4cbe83..3f721e971 100755
--- a/web/alert.cgi
+++ b/web/alert.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: alert.cgi,v 1.23 2008-01-28 15:27:00 matthew Exp $
+# $Id: alert.cgi,v 1.24 2008-01-30 18:27:48 matthew Exp $
use strict;
use Standard;
@@ -305,7 +305,7 @@ sub alert_signed_input {
my $alert_id = mySociety::Alert::create($email, 'new_updates', $id);
mySociety::Alert::confirm($alert_id);
$out = $q->p(_('You have successfully subscribed to that alert.'));
- $out .= CrossSell::display_advert($email);
+ $out .= CrossSell::display_advert($q, $email);
} else {
$out = $q->p(_('We could not validate that alert.'));
}
@@ -321,11 +321,11 @@ sub alert_token {
if ($type eq 'subscribe') {
mySociety::Alert::confirm($id);
$out = $q->p(_('You have successfully confirmed your alert.'));
- $out .= CrossSell::display_advert($email);
+ $out .= CrossSell::display_advert($q, $email);
} elsif ($type eq 'unsubscribe') {
mySociety::Alert::delete($id);
$out = $q->p(_('You have successfully deleted your alert.'));
- $out .= CrossSell::display_advert($email);
+ $out .= CrossSell::display_advert($q, $email);
}
return $out;
}
diff --git a/web/confirm.cgi b/web/confirm.cgi
index 6990e7499..cae90154d 100755
--- a/web/confirm.cgi
+++ b/web/confirm.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: confirm.cgi,v 1.32 2008-01-28 16:29:46 matthew Exp $
+# $Id: confirm.cgi,v 1.33 2008-01-30 18:27:48 matthew Exp $
use strict;
use Standard;
@@ -72,7 +72,7 @@ sub confirm_update {
$out = '<form action="/alert" method="post">';
$out .= $q->p(sprintf(_('You have successfully confirmed your update and you can now <a href="%s">view it on the site</a>.'), "/?id=$problem_id#update_$id"));
if ($fixed) {
- $out .= CrossSell::display_advert($email, $name);
+ $out .= CrossSell::display_advert($q, $email, $name);
} else {
$out .= advertise_updates($q, $problem_id, $email);
}
@@ -152,7 +152,7 @@ sub add_questionnaire {
ms_current_timestamp(), ?, 'confirmed', 'fixed');", {}, $problem_id, $reported)
unless $already;
my $out = $q->p(sprintf('Thank you &mdash; you can <a href="%s">view your updated problem</a> on the site.', "/?id=$problem_id"));
- $out .= CrossSell::display_advert($email, $name);
+ $out .= CrossSell::display_advert($q, $email, $name);
return $out;
}
diff --git a/web/contact.cgi b/web/contact.cgi
index cfbf952da..4979f7344 100755
--- a/web/contact.cgi
+++ b/web/contact.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: contact.cgi,v 1.26 2008-01-28 15:27:00 matthew Exp $
+# $Id: contact.cgi,v 1.27 2008-01-30 18:27:48 matthew Exp $
use strict;
use Standard;
@@ -67,7 +67,7 @@ sub contact_submit {
my $result = mySociety::EmailUtil::send_email($email, $input{em}, mySociety::Config::get('CONTACT_EMAIL'));
if ($result == mySociety::EmailUtil::EMAIL_SUCCESS) {
my $out = $q->p("Thanks for your feedback. We'll get back to you as soon as we can!");
- $out .= CrossSell::display_advert($input{em}, $input{name});
+ $out .= CrossSell::display_advert($q, $input{em}, $input{name});
return $out;
} else {
return $q->p('Failed to send message. Please try again, or <a href="mailto:' . mySociety::Config::get('CONTACT_EMAIL') . '">email us</a>.');
diff --git a/web/css.css b/web/css.css
index a1d7d99a5..c45ea8be6 100644
--- a/web/css.css
+++ b/web/css.css
@@ -176,6 +176,11 @@ ul#error {
padding: 2px 4px;
}
+#advert_thin {
+ width: 50%;
+ margin: 0 auto;
+}
+
/* Front page */
#expl {
@@ -464,7 +469,7 @@ ol#current img {
margin-right: 1em;
}
-/* Printign */
+/* Printing */
@media print {
#map_box { float: none; margin: 0 auto; }
#content { max-width: none; }
diff --git a/web/questionnaire.cgi b/web/questionnaire.cgi
index 92b488b2c..4268a9eed 100755
--- a/web/questionnaire.cgi
+++ b/web/questionnaire.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: questionnaire.cgi,v 1.18 2008-01-28 15:27:00 matthew Exp $
+# $Id: questionnaire.cgi,v 1.19 2008-01-30 18:27:48 matthew Exp $
use strict;
use Standard;
@@ -128,7 +128,8 @@ EOF
my $out = <<EOF;
<p>Thank you very much for filling in our questionnaire; glad to hear it's been fixed.</p>
EOF
- $out .= CrossSell::display_advert($problem->{email}, $problem->{name});
+ $out .= CrossSell::display_advert($q, $problem->{email}, $problem->{name},
+ council => $problem->{council});
}
}