aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
authorEdmund von der Burg <evdb@mysociety.org>2011-04-15 16:01:18 +0100
committerEdmund von der Burg <evdb@mysociety.org>2011-04-15 16:01:18 +0100
commit4cb5b632afa97850f5dda1e94dc513ee1515cd2c (patch)
tree05c4175b8582a2fe52ed74e5dc1a3e3a70506891 /perllib/FixMyStreet
parentd6f984e78bba58710d03aba15b41b897aa078040 (diff)
change cobrand url to uri and change all c.cobrand.url to c.uri_for in templates
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App.pm12
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm6
-rw-r--r--perllib/FixMyStreet/Cobrand/FiksGataMi.pm13
3 files changed, 16 insertions, 15 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index a5ba6bc5d..ea22179b7 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -11,6 +11,9 @@ use mySociety::Email;
use FixMyStreet::Map;
use FixMyStreet::FakeQ;
+use URI;
+use URI::QueryParam;
+
use Catalyst (
'Static::Simple', #
'Unicode',
@@ -315,13 +318,10 @@ sub uri_for {
my $uri = $c->next::method(@args);
- # Currently the cobrand expect and return the url as a string.
- my $cobranded_uri = $c->cobrand->url( $uri->as_string );
+ my $cobranded_uri = $c->cobrand->uri($uri);
- # check to see if the returned string looks like a url (cities does not)
- return $cobranded_uri =~ m{^https?://}
- ? URI->new($cobranded_uri)
- : $cobranded_uri;
+ # note that the returned uri may be a string not an object (eg cities)
+ return $cobranded_uri;
}
=head2 uri_for_email
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 097ce3ef7..e3a1aa8ee 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -357,7 +357,7 @@ produced on the page returned by that query.
=cut
-sub extra_params { '' }
+sub extra_params { return {} }
=head2 extra_problem_meta_text
@@ -375,14 +375,14 @@ Returns any extra text to be displayed with an UPDATE.
sub extra_update_meta_text { '' }
-=head2 url
+=head2 uri
Given a URL ($_[1]), QUERY, EXTRA_DATA, return a URL with any extra params
needed appended to it.
=cut
-sub url { $_[1] }
+sub uri { $_[1] } # passthrough unchanged
=head2 header_params
diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
index 00655afc9..1b9a1fab7 100644
--- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
+++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
@@ -36,12 +36,13 @@ sub area_min_generation {
# 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 uri {
+ my ( $self, $uri ) = @_;
+
+ $uri->query_param( zoom => 2 )
+ if $uri->query_param('lat') && !$uri->query_param('zoom');
+
+ return $uri;
}
sub geocoded_string_check {