aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Alert.pm4
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm23
-rw-r--r--perllib/FixMyStreet/Cobrand/FiksGataMi.pm17
3 files changed, 42 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm
index c1b164a7c..b1856b22c 100644
--- a/perllib/FixMyStreet/App/Controller/Alert.pm
+++ b/perllib/FixMyStreet/App/Controller/Alert.pm
@@ -317,11 +317,11 @@ sub generate_council_and_ward_options : Private {
foreach (values %{ $c->stash->{all_councils} }) {
if ($councils{$_->{type}}) {
$council = $_;
- $council->{short_name} = Page::short_name( $council );
+ $council->{short_name} = $c->cobrand->short_name( $council );
( $council->{id_name} = $council->{short_name} ) =~ tr/+/_/;
} else {
$ward = $_;
- $ward->{short_name} = Page::short_name( $ward );
+ $ward->{short_name} = $c->cobrand->short_name( $ward );
( $ward->{id_name} = $ward->{short_name} ) =~ tr/+/_/;
}
}
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 260be07a5..8b2ff1b9c 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -611,5 +611,28 @@ sub remove_redundant_councils {
if $all_councils->{2391};
}
+=item short_name
+
+Renove extra information from council names for tidy URIs
+
+=cut
+
+sub short_name {
+ my $self = shift;
+ my ($area, $info) = @_;
+ # Special case Durham as it's the only place with two councils of the same name
+ return 'Durham+County' if $area->{name} eq 'Durham County Council';
+ return 'Durham+City' if $area->{name} eq 'Durham City Council';
+
+ my $name = $area->{name};
+ $name =~ s/ (Borough|City|District|County) Council$//;
+ $name =~ s/ Council$//;
+ $name =~ s/ & / and /;
+ $name = URI::Escape::uri_escape_utf8($name);
+ $name =~ s/%20/+/g;
+ return $name;
+
+}
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
index d733ba8f0..3981192c8 100644
--- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
+++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
@@ -60,4 +60,21 @@ sub remove_redundant_councils {
if $all_councils->{3};
}
+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 $name = $area->{name};
+ $name =~ s/ & / and /;
+ $name = URI::Escape::uri_escape_utf8($name);
+ $name =~ s/%20/+/g;
+ return $name;
+
+}
+
1;