aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2011-06-07 17:50:31 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-06-07 17:50:31 +0100
commitf128b19cf7bf0da5dd445dc39d1a09e8953fc32d (patch)
treebfe7d772ece4a5725ae8389c43452c0aa0e3bb44 /perllib
parentb5a218792a7bcf477c930205b6a7c341a90d3efd (diff)
Creation of new Southampton cobrand, removal of old cobrands.
Diffstat (limited to 'perllib')
-rw-r--r--perllib/Cobrands/Barnet/Util.pm117
-rw-r--r--perllib/Cobrands/Emptyhomes/Util.pm75
-rw-r--r--perllib/Cobrands/Fiksgatami/Util.pm62
-rw-r--r--perllib/Cobrands/Southampton/Util.pm117
-rw-r--r--perllib/FixMyStreet/Cobrand/Barnet.pm7
-rw-r--r--perllib/FixMyStreet/Cobrand/FiksGataMi.pm41
-rw-r--r--perllib/FixMyStreet/Cobrand/Southampton.pm83
7 files changed, 106 insertions, 396 deletions
diff --git a/perllib/Cobrands/Barnet/Util.pm b/perllib/Cobrands/Barnet/Util.pm
deleted file mode 100644
index e4115c232..000000000
--- a/perllib/Cobrands/Barnet/Util.pm
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/perl -w
-#
-# Util.pm:
-# Barnet cobranding for FixMyStreet.
-#
-# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
-# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
-
-package Cobrands::Barnet::Util;
-use strict;
-use Carp;
-use URI::Escape;
-use mySociety::VotingArea;
-
-sub new {
- my $class = shift;
- return bless {}, $class;
-}
-
-=item site_restriction Q
-
-Return a site restriction clause and a site key.
-
-=cut
-sub site_restriction{
- return ("and council='2489'", 'barnet');
-}
-
-=item
-
-Return the base url for this cobranded site
-
-=cut
-
-sub base_url {
- my $base_url = mySociety::Config::get('BASE_URL');
- if ($base_url !~ /barnet/) {
- $base_url =~ s/http:\/\/(?!www\.)/http:\/\/barnet\./g;
- $base_url =~ s/http:\/\/www\./http:\/\/barnet\./g;
- }
- return $base_url;
-}
-
-=item site_title
-
-Return the title to be used in page heads
-
-=cut
-
-sub site_title {
- my ($self) = @_;
- return 'Barnet Council FixMyStreet';
-}
-
-sub enter_postcode_text {
- my ($self,$q) = @_;
- return 'Enter a Barnet postcode, or street name and area';
-}
-
-=item council_check COUNCILS QUERY CONTEXT
-
-Return a boolean indicating whether COUNCILS are okay for the location
-in the QUERY, and an error message appropriate to the CONTEXT.
-
-=cut
-
-sub council_check {
- my ($self, $params, $q, $context) = @_;
- my $councils;
- if ($params->{all_councils}) {
- $councils = $params->{all_councils};
- } elsif (defined $params->{lat}) {
- my $parent_types = $mySociety::VotingArea::council_parent_types;
- $councils = mySociety::MaPit::call('point', "4326/$params->{lon},$params->{lat}", type => $parent_types);
- }
- my $council_match = defined $councils->{2489};
- if ($council_match) {
- return 1;
- }
- my $url = 'http://www.fixmystreet.com/';
- $url .= 'alert' if $context eq 'alert';
- $url .= '?pc=' . URI::Escape::uri_escape_utf8($q->param('pc')) if $q->param('pc');
- my $error_msg = "That location is not covered by Barnet.
-Please visit <a href=\"$url\">the main FixMyStreet site</a>.";
- return (0, $error_msg);
-}
-
-# All reports page only has the one council.
-sub all_councils_report {
- return 0;
-}
-
-=item disambiguate_location S Q
-
-Given a string representing a location (street and area expected),
-bias the viewport to around Barnet.
-
-=cut
-
-sub disambiguate_location {
- my ($self, $s, $q) = @_;
- $s = "ll=51.612832,-0.218169&spn=0.0563,0.09&$s";
- return $s;
-}
-
-sub recent_photos {
- my ($self, $num, $lat, $lon, $dist) = @_;
- $num = 2 if $num == 3;
- return Problems::recent_photos($num, $lat, $lon, $dist);
-}
-
-sub tilma_mid_point {
- return 189;
-}
-
-1;
-
diff --git a/perllib/Cobrands/Emptyhomes/Util.pm b/perllib/Cobrands/Emptyhomes/Util.pm
deleted file mode 100644
index d23857f50..000000000
--- a/perllib/Cobrands/Emptyhomes/Util.pm
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/perl -w
-#
-# Util.pm:
-# Emptyhomes Cobranding for FixMyStreet.
-#
-# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
-# Email: louise@mysociety.org. WWW: http://www.mysociety.org
-
-package Cobrands::Emptyhomes::Util;
-use strict;
-use Carp;
-
-sub new {
- my $class = shift;
- return bless {}, $class;
-}
-
-=item
-
-Return the base url for this cobranded site
-
-=cut
-
-sub base_url {
- my $base_url = mySociety::Config::get('BASE_URL');
- if ($base_url !~ /emptyhomes/) {
- $base_url =~ s/http:\/\//http:\/\/emptyhomes\./g;
- }
- return $base_url;
-}
-
-sub admin_base_url {
- return 'https://secure.mysociety.org/admin/emptyhomes/';
-}
-
-sub area_types {
- return qw(DIS LBO MTD UTA LGD COI); # No CTY
-}
-
-=item set_lang_and_domain LANG UNICODE
-
-Set the language and text domain for the site based on the query and host.
-
-=cut
-
-sub set_lang_and_domain {
- my ($self, $lang, $unicode) = @_;
- mySociety::Locale::negotiate_language('en-gb,English,en_GB|cy,Cymraeg,cy_GB', $lang);
- mySociety::Locale::gettext_domain('FixMyStreet-EmptyHomes', $unicode);
- mySociety::Locale::change();
-}
-
-=item site_title
-
-Return the title to be used in page heads
-
-=cut
-
-sub site_title {
- my ($self) = @_;
- return _('Report Empty Homes');
-}
-
-=item feed_xsl
-
-Return the XSL file path to be used for feeds'
-
-=cut
-sub feed_xsl {
- my ($self) = @_;
- return '/xsl.eha.xsl';
-}
-
-1;
-
diff --git a/perllib/Cobrands/Fiksgatami/Util.pm b/perllib/Cobrands/Fiksgatami/Util.pm
deleted file mode 100644
index 2abc03d00..000000000
--- a/perllib/Cobrands/Fiksgatami/Util.pm
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/perl -w
-#
-# Util.pm:
-# Fiksgatami cobranding for FixMyStreet.
-#
-# Copyright (c) 2011 UK Citizens Online Democracy. All rights reserved.
-# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
-
-package Cobrands::Fiksgatami::Util;
-use strict;
-use Carp;
-
-sub new {
- my $class = shift;
- return bless {}, $class;
-}
-
-sub set_lang_and_domain {
- my ($self, $lang, $unicode) = @_;
- mySociety::Locale::negotiate_language('en-gb,English,en_GB|nb,Norwegian,nb_NO', 'nb');
- mySociety::Locale::gettext_domain('FixMyStreet', $unicode);
- mySociety::Locale::change();
-}
-
-# If lat/lon are present in the URL, OpenLayers will use that to centre the map.
-# Need to specify a zoom to stop it defaulting to null/0.
-sub url {
- my ($self, $url) = @_;
- if ($url =~ /lat=/ && $url !~ /zoom=/) {
- $url .= ';zoom=2';
- }
- return $url;
-}
-
-sub enter_postcode_text {
- my ($self, $q) = @_;
- return _('Enter a nearby postcode, or street name and area');
-}
-
-# Is also adding language parameter
-sub disambiguate_location {
- my ($self, $s, $q) = @_;
- $s = "hl=no&gl=no&$s";
- return $s;
-}
-
-sub geocoded_string_check {
- my ($self, $s) = @_;
- return 1 if $s =~ /, Norge/;
- return 0;
-}
-
-sub area_types {
- return ( 'NKO', 'NFY' );
-}
-
-sub area_min_generation {
- return '';
-}
-
-1;
-
diff --git a/perllib/Cobrands/Southampton/Util.pm b/perllib/Cobrands/Southampton/Util.pm
deleted file mode 100644
index d29b53127..000000000
--- a/perllib/Cobrands/Southampton/Util.pm
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/perl -w
-#
-# Util.pm:
-# Southampton cobranding for FixMyStreet.
-#
-# Copyright (c) 2011 UK Citizens Online Democracy. All rights reserved.
-# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
-
-package Cobrands::Southampton::Util;
-use strict;
-use Carp;
-use URI::Escape;
-use mySociety::VotingArea;
-
-sub new {
- my $class = shift;
- return bless {}, $class;
-}
-
-=item site_restriction Q
-
-Return a site restriction clause and a site key.
-
-=cut
-sub site_restriction {
- return ("and council='2567'", 'southampton');
-}
-
-=item
-
-Return the base url for this cobranded site
-
-=cut
-
-sub base_url {
- my $base_url = mySociety::Config::get('BASE_URL');
- if ($base_url !~ /southampton/) {
- $base_url =~ s/http:\/\/(?!www\.)/http:\/\/southampton\./g;
- $base_url =~ s/http:\/\/www\./http:\/\/southampton\./g;
- }
- return $base_url;
-}
-
-=item site_title
-
-Return the title to be used in page heads
-
-=cut
-
-sub site_title {
- my ($self) = @_;
- return 'Southampton City Council FixMyStreet';
-}
-
-sub enter_postcode_text {
- my ($self,$q) = @_;
- return 'Enter a Southampton postcode, or street name and area';
-}
-
-=item council_check COUNCILS QUERY CONTEXT
-
-Return a boolean indicating whether COUNCILS are okay for the location
-in the QUERY, and an error message appropriate to the CONTEXT.
-
-=cut
-
-sub council_check {
- my ($self, $params, $q, $context) = @_;
- my $councils;
- if ($params->{all_councils}) {
- $councils = $params->{all_councils};
- } elsif (defined $params->{lat}) {
- my $parent_types = $mySociety::VotingArea::council_parent_types;
- $councils = mySociety::MaPit::call('point', "4326/$params->{lon},$params->{lat}", type => $parent_types);
- }
- my $council_match = defined $councils->{2567};
- if ($council_match) {
- return 1;
- }
- my $url = 'http://www.fixmystreet.com/';
- $url .= 'alert' if $context eq 'alert';
- $url .= '?pc=' . URI::Escape::uri_escape_utf8($q->param('pc')) if $q->param('pc');
- my $error_msg = "That location is not covered by Southampton.
-Please visit <a href=\"$url\">the main FixMyStreet site</a>.";
- return (0, $error_msg);
-}
-
-# All reports page only has the one council.
-sub all_councils_report {
- return 0;
-}
-
-=item disambiguate_location S Q
-
-Given a string representing a location (street and area expected),
-bias the viewport to around Southampton.
-
-=cut
-
-sub disambiguate_location {
- my ($self, $s, $q) = @_;
- $s = "ll=50.913822,-1.400493&spn=0.084628,0.15701&$s";
- return $s;
-}
-
-sub recent_photos {
- my ($self, $num, $lat, $lon, $dist) = @_;
- $num = 2 if $num == 3;
- return Problems::recent_photos($num, $lat, $lon, $dist);
-}
-
-sub tilma_mid_point {
- return 189;
-}
-
-1;
-
diff --git a/perllib/FixMyStreet/Cobrand/Barnet.pm b/perllib/FixMyStreet/Cobrand/Barnet.pm
index 26c7c0453..f68d61256 100644
--- a/perllib/FixMyStreet/Cobrand/Barnet.pm
+++ b/perllib/FixMyStreet/Cobrand/Barnet.pm
@@ -28,12 +28,11 @@ sub site_title {
sub enter_postcode_text {
my ($self) = @_;
- return 'Enter a Barnet postcode, or street name and area:';
+ return 'Enter a Barnet postcode, or street name and area';
}
sub council_check {
my ( $self, $params, $context ) = @_;
- my $q = $self->request;
my $councils;
if ( $params->{all_councils} ) {
@@ -53,8 +52,8 @@ sub council_check {
}
my $url = 'http://www.fixmystreet.com/';
$url .= 'alert' if $context eq 'alert';
- $url .= '?pc=' . URI::Escape::uri_escape( $q->param('pc') )
- if $q->param('pc');
+ $url .= '?pc=' . URI::Escape::uri_escape( $self->{request}->param('pc') )
+ if $self->{request}->param('pc');
my $error_msg = "That location is not covered by Barnet.
Please visit <a href=\"$url\">the main FixMyStreet site</a>.";
return ( 0, $error_msg );
diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
index a5b71e46b..4dd2ef49a 100644
--- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
+++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
@@ -62,37 +62,36 @@ sub geocoded_string_check {
}
sub remove_redundant_councils {
- my $self = shift;
- my $all_councils = shift;
+ my $self = shift;
+ my $all_councils = shift;
- # Oslo is both a kommune and a fylke, we only want to show it once
- delete $all_councils->{301} #
- if $all_councils->{3};
+ # Oslo is both a kommune and a fylke, we only want to show it once
+ delete $all_councils->{301} #
+ if $all_councils->{3};
}
sub filter_all_council_ids_list {
- my $self = shift;
- my @all_councils_ids = @_;
+ my $self = shift;
+ my @all_councils_ids = @_;
- # as above we only want to show Oslo once
- return grep { $_ != 301 } @all_councils_ids;
+ # as above we only want to show Oslo once
+ return grep { $_ != 301 } @all_councils_ids;
}
sub short_name {
- my $self = shift;
- my ($area, $info) = @_;
-
- if ($area->{name} =~ /^(Os|Nes|V\xe5ler|Sande|B\xf8|Her\xf8y)$/) {
- my $parent = $info->{$area->{parent_area}}->{name};
- return URI::Escape::uri_escape_utf8("$area->{name}, $parent");
- }
+ my $self = shift;
+ my ($area, $info) = @_;
- my $name = $area->{name};
- $name =~ s/ & / and /;
- $name = URI::Escape::uri_escape_utf8($name);
- $name =~ s/%20/+/g;
- return $name;
+ if ($area->{name} =~ /^(Os|Nes|V\xe5ler|Sande|B\xf8|Her\xf8y)$/) {
+ my $parent = $info->{$area->{parent_area}}->{name};
+ return URI::Escape::uri_escape_utf8("$area->{name}, $parent");
+ }
+ my $name = $area->{name};
+ $name =~ s/ & / and /;
+ $name = URI::Escape::uri_escape_utf8($name);
+ $name =~ s/%20/+/g;
+ return $name;
}
sub council_rss_alert_options {
diff --git a/perllib/FixMyStreet/Cobrand/Southampton.pm b/perllib/FixMyStreet/Cobrand/Southampton.pm
new file mode 100644
index 000000000..aa9945c00
--- /dev/null
+++ b/perllib/FixMyStreet/Cobrand/Southampton.pm
@@ -0,0 +1,83 @@
+package FixMyStreet::Cobrand::Southampton;
+use base 'FixMyStreet::Cobrand::Default';
+
+use strict;
+use warnings;
+
+use Carp;
+use URI::Escape;
+use mySociety::VotingArea;
+
+sub site_restriction {
+ return ( "and council='2567'", 'southampton', { council => '2567' } );
+}
+
+sub base_url {
+ my $base_url = mySociety::Config::get('BASE_URL');
+ if ($base_url !~ /southampton/) {
+ $base_url =~ s{http://(?!www\.)}{http://southampton.}g;
+ $base_url =~ s{http://www\.}{http://southampton.}g;
+ }
+ return $base_url;
+}
+
+sub site_title {
+ my ( $self ) = @_;
+ return 'Southampton City Council FixMyStreet';
+}
+
+sub enter_postcode_text {
+ my ( $self ) = @_;
+ return 'Enter a Southampton postcode, or street name and area';
+}
+
+sub council_check {
+ my ( $self, $params, $context ) = @_;
+
+ my $councils;
+ if ($params->{all_councils}) {
+ $councils = $params->{all_councils};
+ } elsif (defined $params->{lat}) {
+ my $parent_types = $mySociety::VotingArea::council_parent_types;
+ $councils = mySociety::MaPit::call(
+ 'point',
+ "4326/$params->{lon},$params->{lat}",
+ type => $parent_types
+ );
+ }
+ my $council_match = defined $councils->{2567};
+ if ($council_match) {
+ return 1;
+ }
+ my $url = 'http://www.fixmystreet.com/';
+ $url .= 'alert' if $context eq 'alert';
+ $url .= '?pc=' . URI::Escape::uri_escape_utf8($self->{request}->param('pc'))
+ if $self->{request}->param('pc');
+ my $error_msg = "That location is not covered by Southampton.
+Please visit <a href=\"$url\">the main FixMyStreet site</a>.";
+ return ( 0, $error_msg );
+}
+
+# All reports page only has the one council.
+sub all_councils_report {
+ return 0;
+}
+
+sub disambiguate_location {
+ my ( $self, $s ) = @_;
+ $s = "ll=50.913822,-1.400493&spn=0.084628,0.15701&$s";
+ return $s;
+}
+
+sub recent_photos {
+ my ($self, $num, $lat, $lon, $dist) = @_;
+ $num = 2 if $num == 3;
+ return Problems::recent_photos( $num, $lat, $lon, $dist );
+}
+
+sub tilma_mid_point {
+ return 189;
+}
+
+1;
+