diff options
author | Edmund von der Burg <evdb@mysociety.org> | 2011-04-15 16:01:18 +0100 |
---|---|---|
committer | Edmund von der Burg <evdb@mysociety.org> | 2011-04-15 16:01:18 +0100 |
commit | 4cb5b632afa97850f5dda1e94dc513ee1515cd2c (patch) | |
tree | 05c4175b8582a2fe52ed74e5dc1a3e3a70506891 | |
parent | d6f984e78bba58710d03aba15b41b897aa078040 (diff) |
change cobrand url to uri and change all c.cobrand.url to c.uri_for in templates
-rw-r--r-- | perllib/FixMyStreet/App.pm | 12 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FiksGataMi.pm | 13 | ||||
-rw-r--r-- | t/app/uri_for.t | 2 | ||||
-rw-r--r-- | templates/web/default/index.html | 2 | ||||
-rw-r--r-- | templates/web/default/tokens/confirm_problem.html | 2 | ||||
-rw-r--r-- | templates/web/default/tokens/error.html | 2 |
7 files changed, 20 insertions, 19 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 { diff --git a/t/app/uri_for.t b/t/app/uri_for.t index 9a93fedea..309c3a3b2 100644 --- a/t/app/uri_for.t +++ b/t/app/uri_for.t @@ -56,7 +56,7 @@ is( # fiksgatami is( $fgm_c->uri_for( '/foo', { lat => 1.23, } ) . "", - 'http://www.fiksgatami.no/foo?lat=1.23;zoom=2', + 'http://www.fiksgatami.no/foo?lat=1.23&zoom=2', 'FiksGataMi url with lat not zoom' ); diff --git a/templates/web/default/index.html b/templates/web/default/index.html index 1e64779e9..fa1974730 100644 --- a/templates/web/default/index.html +++ b/templates/web/default/index.html @@ -43,7 +43,7 @@ || loc("Enter a nearby GB postcode, or street name and area"); %] -<form action="[% c.cobrand.url('/around') %]" method="get" name="postcodeForm" id="postcodeForm"> +<form action="[% c.uri_for('/around') %]" method="get" name="postcodeForm" id="postcodeForm"> <label for="pc">[% question %]:</label> <input type="text" name="pc" value="" id="pc" size="10" maxlength="200"> <input type="submit" value="[% loc('Go') %]" id="submit"> diff --git a/templates/web/default/tokens/confirm_problem.html b/templates/web/default/tokens/confirm_problem.html index aeff2cc9c..cc3fb6400 100644 --- a/templates/web/default/tokens/confirm_problem.html +++ b/templates/web/default/tokens/confirm_problem.html @@ -12,7 +12,7 @@ tprintf( loc( '. You can <a href="%s">view the problem on this site</a>.' ), - c.cobrand.url( '/report/' _ problem.id ) + c.uri_for( '/report', problem.id ) ); %] </p> diff --git a/templates/web/default/tokens/error.html b/templates/web/default/tokens/error.html index 76e22c119..e3fa6c170 100644 --- a/templates/web/default/tokens/error.html +++ b/templates/web/default/tokens/error.html @@ -2,7 +2,7 @@ <h1>[% loc('Error') %]</h1> -[% contact_url = c.cobrand.url('/contact'); %] +[% contact_url = c.uri_for('/contact'); %] <p>[% tprintf( loc('Thank you for trying to confirm your update or problem. We seem to have an error ourselves though, so <a href="%s">please let us know what went on</a> and we\'ll look into it.'), contact_url ) %]</p> |