aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/CrossSell.pm34
-rw-r--r--perllib/FixMyStreet/App/Controller/Photo.pm3
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm5
-rw-r--r--perllib/FixMyStreet/Cobrand.pm38
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm8
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm4
6 files changed, 57 insertions, 35 deletions
diff --git a/perllib/CrossSell.pm b/perllib/CrossSell.pm
index 4a0f31ea8..f9a02a61b 100644
--- a/perllib/CrossSell.pm
+++ b/perllib/CrossSell.pm
@@ -189,25 +189,25 @@ sub display_advert ($$;$%) {
#$c->stash->{scratch} = 'advert=demclub0';
#return display_democracyclub();
- return <<EOF;
-<div id="advert_thin">
-<p>Do you have an issue that&rsquo;s too big for FixMyStreet?
-It could be time to petition your council. Try our new site:
-<h2 style="margin-top:0; font-size: 150%">
-<a href="http://www.petitionyourcouncil.com/">PetitionYourCouncil</a></p>
-</h2>
-</div>
-EOF
+# return <<EOF;
+#<div id="advert_thin">
+#<p>Do you have an issue that&rsquo;s too big for FixMyStreet?
+#It could be time to petition your council. Try our new site:
+#<h2 style="margin-top:0; font-size: 150%">
+#<a href="http://www.petitionyourcouncil.com/">PetitionYourCouncil</a></p>
+#</h2>
+#</div>
+#EOF
#unless (defined $data{done_tms} && $data{done_tms}==1) {
- #$c->stash->{scratch} = 'advert=news';
- #my $auth_signature = '';
- #unless (defined $data{emailunvalidated} && $data{emailunvalidated}==1) {
- # $auth_signature = mySociety::AuthToken::sign_with_shared_secret($email, mySociety::Config::get('AUTH_SHARED_SECRET'));
- #}
- #return '<div style="margin: 0 5em; border-top: dotted 1px #666666;">'
- # . display_news_form(email => $email, name => $name, signed_email => $auth_signature)
- # . '</div>';
+ $c->stash->{scratch} = 'advert=news';
+ my $auth_signature = '';
+ unless (defined $data{emailunvalidated} && $data{emailunvalidated}==1) {
+ $auth_signature = mySociety::AuthToken::sign_with_shared_secret($email, mySociety::Config::get('AUTH_SHARED_SECRET'));
+ }
+ return '<div style="margin: 0 5em; border-top: dotted 1px #666666;">'
+ . display_news_form(email => $email, name => $name, signed_email => $auth_signature)
+ . '</div>';
#}
my @adverts = (
diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm
index 3ca7f13a9..8711b19e9 100644
--- a/perllib/FixMyStreet/App/Controller/Photo.pm
+++ b/perllib/FixMyStreet/App/Controller/Photo.pm
@@ -94,8 +94,7 @@ sub index :LocalRegex('^(c/)?(\d+)(?:\.(full|tn|fp))?\.jpeg$') {
sub output : Private {
my ( $self, $c, $photo ) = @_;
- my $dt = DateTime->now();
- $dt->set_year( $dt->year + 1 );
+ my $dt = DateTime->now()->add( years => 1 );
$c->res->content_type( 'image/jpeg' );
$c->res->header( 'expires', DateTime::Format::HTTP->format_datetime( $dt ) );
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 5d70ae113..e7620f755 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -31,8 +31,6 @@ Show the summary page of all reports.
sub index : Path : Args(0) {
my ( $self, $c ) = @_;
- $c->response->header('Cache-Control' => 'max-age=3600');
-
# Fetch all areas of the types we're interested in
my $areas_info;
eval {
@@ -73,6 +71,9 @@ sub index : Path : Args(0) {
sprintf(_('The error was: %s'), $@);
$c->stash->{template} = 'errors/generic.html';
}
+
+ # Down here so that error pages aren't cached.
+ $c->response->header('Cache-Control' => 'max-age=3600');
}
=head2 index
diff --git a/perllib/FixMyStreet/Cobrand.pm b/perllib/FixMyStreet/Cobrand.pm
index ad21820d7..647261e32 100644
--- a/perllib/FixMyStreet/Cobrand.pm
+++ b/perllib/FixMyStreet/Cobrand.pm
@@ -18,31 +18,50 @@ my @ALL_COBRAND_CLASSES = __PACKAGE__->_cobrands;
=head2 get_allowed_cobrands
-Return an array reference of allowed cobrand subdomains
+Return an array reference of allowed cobrand monikers and hostname substrings.
=cut
sub get_allowed_cobrands {
- my $allowed_cobrand_string = FixMyStreet->config('ALLOWED_COBRANDS');
- my @allowed_cobrands = split( /\|/, $allowed_cobrand_string );
+ my $class = shift;
+ my @allowed_cobrands = map {
+ ref $_ ? { moniker => keys %$_, host => values %$_ }
+ : { moniker => $_, host => $_ }
+ } @{ $class->_get_allowed_cobrands };
return \@allowed_cobrands;
}
+=head2 _get_allowed_cobrands
+
+Simply returns the config variable (so this function can be overridden in test suite).
+
+=cut
+
+sub _get_allowed_cobrands {
+ return FixMyStreet->config('ALLOWED_COBRANDS');
+}
+
=head2 available_cobrand_classes
@available_cobrand_classes =
FixMyStreet::Cobrand->available_cobrand_classes();
-Return an array of all the classes that were found and that have monikers that
-match the values from get_allowed_cobrands.
+Return an array of all the classes that were found and that have monikers
+that match the values from get_allowed_cobrands, in the order of
+get_allowed_cobrands.
=cut
sub available_cobrand_classes {
my $class = shift;
- my %allowed = map { $_ => 1 } @{ $class->get_allowed_cobrands };
- my @avail = grep { $allowed{ $_->moniker } } @ALL_COBRAND_CLASSES;
+ my %all = map { $_->moniker => $_ } @ALL_COBRAND_CLASSES;
+ my @avail;
+ foreach (@{ $class->get_allowed_cobrands }) {
+ next unless $all{$_->{moniker}};
+ $_->{class} = $all{$_->{moniker}};
+ push @avail, $_;
+ }
return @avail;
}
@@ -60,8 +79,7 @@ sub get_class_for_host {
my $host = shift;
foreach my $avail ( $class->available_cobrand_classes ) {
- my $moniker = $avail->moniker;
- return $avail if $host =~ m{$moniker};
+ return $avail->{class} if $host =~ /$avail->{host}/;
}
# if none match then use the default
@@ -81,7 +99,7 @@ sub get_class_for_moniker {
my $moniker = shift;
foreach my $avail ( $class->available_cobrand_classes ) {
- return $avail if $moniker eq $avail->moniker;
+ return $avail->{class} if $moniker eq $avail->{moniker};
}
# Special case for old blank cobrand entries in fixmystreet.com.
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index aeb956680..aacfb5e2b 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -782,28 +782,28 @@ sub council_rss_alert_options {
id => sprintf( 'area:%s:%s', $district->{id}, $district->{id_name} ),
text => $district_name,
rss_text => sprintf( _('RSS feed for %s'), $district_name ),
- uri => $c->uri_for( '/rss/areas/' . $district->{short_name} )
+ uri => $c->uri_for( '/rss/area/' . $district->{short_name} )
},
{
type => 'area',
id => sprintf( 'area:%s:%s:%s:%s', $district->{id}, $d_ward->{id}, $district->{id_name}, $d_ward->{id_name} ),
text => sprintf( _('%s ward, %s'), $d_ward_name, $district_name ),
rss_text => sprintf( _('RSS feed for %s ward, %s'), $d_ward_name, $district_name ),
- uri => $c->uri_for( '/rss/areas/' . $district->{short_name} . '/' . $d_ward->{short_name} )
+ uri => $c->uri_for( '/rss/area/' . $district->{short_name} . '/' . $d_ward->{short_name} )
},
{
type => 'area',
id => sprintf( 'area:%s:%s', $county->{id}, $county->{id_name} ),
text => $county_name,
rss_text => sprintf( _('RSS feed for %s'), $county_name ),
- uri => $c->uri_for( '/rss/areas/' . $county->{short_name} )
+ uri => $c->uri_for( '/rss/area/' . $county->{short_name} )
},
{
type => 'area',
id => sprintf( 'area:%s:%s:%s:%s', $county->{id}, $c_ward->{id}, $county->{id_name}, $c_ward->{id_name} ),
text => sprintf( _('%s ward, %s'), $c_ward_name, $county_name ),
rss_text => sprintf( _('RSS feed for %s ward, %s'), $c_ward_name, $county_name ),
- uri => $c->uri_for( '/rss/areas/' . $county->{short_name} . '/' . $c_ward->{short_name} )
+ uri => $c->uri_for( '/rss/area/' . $county->{short_name} . '/' . $c_ward->{short_name} )
};
push @reported_to_options,
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 570c90c46..b40f13d9d 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -12,6 +12,10 @@ sub site_restriction {
return ( "and council='" . $self->council_id . "'", $self->council_url, { council => sprintf('%d', $self->council_id) } );
}
+sub restriction {
+ return { cobrand => shift->moniker };
+}
+
sub problems_clause {
my $self = shift;
return { council => sprintf('%d', $self->council_id) };