aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf/httpd.conf2
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm34
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Questionnaire.pm4
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm30
-rw-r--r--perllib/FixMyStreet/Map.pm21
-rw-r--r--perllib/FixMyStreet/Map/Bing.pm4
-rw-r--r--perllib/FixMyStreet/Map/BingOL.pm4
-rw-r--r--perllib/FixMyStreet/Map/Google.pm4
-rw-r--r--perllib/FixMyStreet/Map/OSM.pm4
-rw-r--r--perllib/FixMyStreet/Map/OSM/StreetView.pm4
-rw-r--r--perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm4
-rw-r--r--perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm4
-rw-r--r--perllib/FixMyStreet/Map/Tilma/Original.pm4
-rw-r--r--t/app/controller/around.t12
-rwxr-xr-xtemplates/web/default/around/display_location.html31
-rw-r--r--templates/web/default/report/new/fill_in_details.html19
16 files changed, 73 insertions, 112 deletions
diff --git a/conf/httpd.conf b/conf/httpd.conf
index 8d70c475d..84d24bb4a 100644
--- a/conf/httpd.conf
+++ b/conf/httpd.conf
@@ -118,6 +118,8 @@ RewriteRule ^/test(.*) /test.cgi$1 [L]
RewriteRule ^/tms-signup(.*) /tms-signup.cgi$1 [L]
RewriteRule ^/upload(.*) /upload.cgi$1 [L]
+RewriteRule ^/jslib(.*) /jslib$1 [L,PT]
+
# trap anything that reaches us here and send it to the Catalyst app - this is
# so that we can gradually move functionality into the app without having to
# touch the existing code.
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index cc7e84706..f8befcef7 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -167,11 +167,6 @@ sub display_location : Private {
# Deal with pin hiding/age
my $all_pins = $c->req->param('all_pins') ? 1 : undef;
$c->stash->{all_pins} = $all_pins;
-
- # Setup some bits of text
- my $all_link = $c->req->uri_with( { no_pins => undef, all_pins => undef } );
- my $all_text =
- $all_pins ? _('Hide stale reports') : _('Include stale reports');
my $interval = $all_pins ? undef : $c->cobrand->on_map_default_max_pin_age;
# get the map features
@@ -191,35 +186,6 @@ sub display_location : Private {
} @$on_map_all, @$around_map;
{ # FIXME - ideally this indented code should be in the templates
- my $no_pins = $c->req->param('no_pins') || '';
- my $toggle_pins_link =
- $c->req->uri_with( { no_pins => $no_pins ? 0 : 1 } );
- my $toggle_pins_text = $no_pins ? _('Show pins') : _('Hide pins');
-
- my $map_links =
- "<p id='sub_map_links'>"
- . " <a id='hide_pins_link' rel='nofollow' href='$toggle_pins_link'>"
- . " $toggle_pins_text" #
- . " </a>";
-
- $map_links .= #
- " | " #
- . "<a id='all_pins_link' rel='nofollow' href='$all_link'>" #
- . " $all_text" #
- . "</a>"
- if mySociety::Config::get('COUNTRY') eq 'GB';
-
- $map_links .= "</p>";
-
- $map_links .= #
- "<input type='hidden' id='all_pins' name='all_pins' value='" #
- . ( $all_pins || '' ) #
- . "'>"
- if mySociety::Config::get('COUNTRY') eq 'GB';
-
- $map_links .= "</p>";
- $c->stash->{map_links} = $map_links;
-
$c->stash->{map_html} = FixMyStreet::Map::display_map(
$c->fake_q,
latitude => $latitude,
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
index 986543e9d..c5258e7d0 100755
--- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm
+++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
@@ -198,6 +198,10 @@ sub display : Private {
my $problem = $c->stash->{questionnaire}->problem;
+ ( $c->stash->{short_latitude}, $c->stash->{short_longitude} ) =
+ map { Utils::truncate_coordinate($_) }
+ ( $problem->latitude, $problem->longitude );
+
my $problem_text = ''; # Page::display_problem_text($c->fake_q, $problem); # FIXME This needs to be in the template
$c->stash->{updates} = ''; # FIXME Should be database ResultSet of problem's pdates
$c->stash->{map_start_html} = FixMyStreet::Map::display_map(
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 5a33718da..180d2198d 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -894,35 +894,15 @@ sub generate_map : Private {
my $latitude = $c->stash->{latitude};
my $longitude = $c->stash->{longitude};
+ ( $c->stash->{short_latitude}, $c->stash->{short_longitude} ) =
+ map { Utils::truncate_coordinate($_) }
+ ( $c->stash->{latitude}, $c->stash->{longitude} );
+
# Forms that allow photos need a different enctype
my $allow_photo_upload = $c->cobrand->allow_photo_upload;
# Don't do anything if the user skipped the map
- if ( $c->req->param('skipped') ) {
-
- my $enctype =
- $allow_photo_upload
- ? ' enctype="multipart/form-data"'
- : '';
-
- my $cobrand_form_elements =
- $c->cobrand->form_elements('mapSkippedForm');
-
- my $form_action = $c->uri_for('');
- my $pc = encode_entities( $c->stash->{pc} );
-
- $c->stash->{map_html} = <<"END_MAP_HTML";
-<form action="$form_action" method="post" name="mapSkippedForm"$enctype>
-<input type="hidden" name="latitude" value="$latitude">
-<input type="hidden" name="longitude" value="$longitude">
-<input type="hidden" name="pc" value="$pc">
-<input type="hidden" name="skipped" value="1">
-$cobrand_form_elements
-<div>
-END_MAP_HTML
-
- }
- else {
+ unless ( $c->req->param('skipped') ) {
my $map_type = $allow_photo_upload ? 2 : 1;
$c->stash->{map_html} = FixMyStreet::Map::display_map(
diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm
index 1d9ce1527..279f799e4 100644
--- a/perllib/FixMyStreet/Map.pm
+++ b/perllib/FixMyStreet/Map.pm
@@ -63,27 +63,6 @@ sub display_map {
return $map_class->display_map(@_);
}
-sub header {
- my ( $q, $type ) = @_;
- return '' unless $type;
-
- my $cobrand = Page::get_cobrand($q);
- my $cobrand_form_elements =
- Cobrand::form_elements( $cobrand, 'mapForm', $q );
- my $form_action = Cobrand::url( $cobrand, '/report/new', $q );
- my $encoding = '';
- $encoding = ' enctype="multipart/form-data"' if $type == 2;
- my $pc = ent($q->param('pc') || '');
- my $map = ent($q->param('map') || '');
- return <<EOF;
-<form action="$form_action" method="post" name="mapForm" id="mapForm"$encoding>
-<input type="hidden" name="submit_map" value="1">
-<input type="hidden" name="map" value="$map">
-<input type="hidden" name="pc" value="$pc">
-$cobrand_form_elements
-EOF
-}
-
sub map_features {
my ( $q, $lat, $lon, $interval ) = @_;
diff --git a/perllib/FixMyStreet/Map/Bing.pm b/perllib/FixMyStreet/Map/Bing.pm
index 3d3f4bb09..4b15b4a76 100644
--- a/perllib/FixMyStreet/Map/Bing.pm
+++ b/perllib/FixMyStreet/Map/Bing.pm
@@ -36,12 +36,10 @@ sub display_map {
}
my $pins_js = join(",\n", @pins);
- my $out = FixMyStreet::Map::header($q, $params{type});
+ my $out = '';
my $copyright = _('Map contains Ordnance Survey data &copy; Crown copyright and database right 2010.');
my $key = mySociety::Config::get('BING_MAPS_API_KEY');
$out .= <<EOF;
-<input type="hidden" name="latitude" id="fixmystreet.latitude" value="$params{latitude}">
-<input type="hidden" name="longitude" id="fixmystreet.longitude" value="$params{longitude}">
<script type="text/javascript">
var fixmystreet = {
'key': '$key',
diff --git a/perllib/FixMyStreet/Map/BingOL.pm b/perllib/FixMyStreet/Map/BingOL.pm
index 41b7c1051..39ac2781a 100644
--- a/perllib/FixMyStreet/Map/BingOL.pm
+++ b/perllib/FixMyStreet/Map/BingOL.pm
@@ -38,11 +38,9 @@ sub display_map {
}
my $pins_js = join(",\n", @pins);
- my $out = FixMyStreet::Map::header($q, $params{type});
+ my $out = '';
my $copyright = _('Map contains Ordnance Survey data &copy; Crown copyright and database right 2010. Microsoft');
$out .= <<EOF;
-<input type="hidden" name="latitude" id="fixmystreet.latitude" value="$params{latitude}">
-<input type="hidden" name="longitude" id="fixmystreet.longitude" value="$params{longitude}">
<script type="text/javascript">
var fixmystreet = {
'latitude': $params{latitude},
diff --git a/perllib/FixMyStreet/Map/Google.pm b/perllib/FixMyStreet/Map/Google.pm
index f51cae43d..d74f5eb2d 100644
--- a/perllib/FixMyStreet/Map/Google.pm
+++ b/perllib/FixMyStreet/Map/Google.pm
@@ -36,11 +36,9 @@ sub display_map {
}
my $pins_js = join(",\n", @pins);
- my $out = FixMyStreet::Map::header($q, $params{type});
+ my $out = '';
my $copyright = _('Map contains Ordnance Survey data &copy; Crown copyright and database right 2010.');
$out .= <<EOF;
-<input type="hidden" name="latitude" id="fixmystreet.latitude" value="$params{latitude}">
-<input type="hidden" name="longitude" id="fixmystreet.longitude" value="$params{longitude}">
<script type="text/javascript">
var fixmystreet = {
'latitude': $params{latitude},
diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm
index 028b48125..292ad4ed7 100644
--- a/perllib/FixMyStreet/Map/OSM.pm
+++ b/perllib/FixMyStreet/Map/OSM.pm
@@ -71,13 +71,11 @@ sub display_map {
} else {
$img_type = '<img';
}
- my $out = FixMyStreet::Map::header($q, $params{type});
+ my $out = '';
my $copyright = _('Map &copy; <a id="osm_link" href="http://www.openstreetmap.org/">OpenStreetMap</a> and contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>');
my $compass = compass($q, $x_tile, $y_tile, $zoom);
my $map_type = $self->map_type();
$out .= <<EOF;
-<input type="hidden" name="latitude" id="fixmystreet.latitude" value="$params{latitude}">
-<input type="hidden" name="longitude" id="fixmystreet.longitude" value="$params{longitude}">
<input type="hidden" name="zoom" value="$zoom">
<script type="text/javascript">
var fixmystreet = {
diff --git a/perllib/FixMyStreet/Map/OSM/StreetView.pm b/perllib/FixMyStreet/Map/OSM/StreetView.pm
index 5cc1ed5ba..9849c1ed5 100644
--- a/perllib/FixMyStreet/Map/OSM/StreetView.pm
+++ b/perllib/FixMyStreet/Map/OSM/StreetView.pm
@@ -37,11 +37,9 @@ sub display_map {
}
my $pins_js = join(",\n", @pins);
- my $out = FixMyStreet::Map::header($q, $params{type});
+ my $out = '';
my $copyright = _('Map contains Ordnance Survey data &copy; Crown copyright and database right 2010.');
$out .= <<EOF;
-<input type="hidden" name="latitude" id="fixmystreet.latitude" value="$params{latitude}">
-<input type="hidden" name="longitude" id="fixmystreet.longitude" value="$params{longitude}">
<script type="text/javascript">
var fixmystreet = {
'latitude': $params{latitude},
diff --git a/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm b/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm
index 785c8eafe..d8ce80fab 100644
--- a/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm
+++ b/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm
@@ -43,14 +43,12 @@ sub display_map {
}
my $pins_js = join(",\n", @pins);
- my $out = FixMyStreet::Map::header($q, $params{type});
+ my $out = '';
my $tile_width = TILE_WIDTH;
my $tile_type = TILE_TYPE;
my $sf = SCALE_FACTOR / TILE_WIDTH;
my $copyright = _('&copy; Crown copyright. All rights reserved. Ministry of Justice 100037819&nbsp;2008.');
$out .= <<EOF;
-<input type="hidden" name="latitude" id="fixmystreet.latitude" value="$params{latitude}">
-<input type="hidden" name="longitude" id="fixmystreet.longitude" value="$params{longitude}">
<script type="text/javascript">
var fixmystreet = {
'tilewidth': $tile_width,
diff --git a/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm b/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm
index 632e75e39..74dd315bb 100644
--- a/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm
+++ b/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm
@@ -43,14 +43,12 @@ sub display_map {
}
my $pins_js = join(",\n", @pins);
- my $out = FixMyStreet::Map::header($q, $params{type});
+ my $out = '';
my $tile_width = TILE_WIDTH;
my $tile_type = TILE_TYPE;
my $sf = SCALE_FACTOR / TILE_WIDTH;
my $copyright = _('Map contains Ordnance Survey data &copy; Crown copyright and database right 2010.');
$out .= <<EOF;
-<input type="hidden" name="latitude" id="fixmystreet.latitude" value="$params{latitude}">
-<input type="hidden" name="longitude" id="fixmystreet.longitude" value="$params{longitude}">
<script type="text/javascript">
var fixmystreet = {
'tilewidth': $tile_width,
diff --git a/perllib/FixMyStreet/Map/Tilma/Original.pm b/perllib/FixMyStreet/Map/Tilma/Original.pm
index 20fc79a60..bf55e51eb 100644
--- a/perllib/FixMyStreet/Map/Tilma/Original.pm
+++ b/perllib/FixMyStreet/Map/Tilma/Original.pm
@@ -96,14 +96,12 @@ sub display_map {
my $cobrand = Page::get_cobrand($q);
my $root_path_js = Cobrand::root_path_js($cobrand, $q);
- my $out = FixMyStreet::Map::header($q, $params{type});
+ my $out = '';
my $img_type;
if ($params{type}) {
$out .= <<EOF;
<input type="hidden" name="x" id="formX" value="$x">
<input type="hidden" name="y" id="formY" value="$y">
-<input type="hidden" name="latitude" value="$params{latitude}">
-<input type="hidden" name="longitude" value="$params{longitude}">
EOF
$img_type = '<input type="image"';
} else {
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index 12b26cec7..33c959b48 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -78,18 +78,18 @@ foreach my $test (
foreach my $test (
{
pc => 'SW1A 1AA',
- latitude => '51.5010096115539',
- longitude => '-0.141587067110009',
+ latitude => '51.50101',
+ longitude => '-0.141587',
},
{
pc => 'Manchester',
- latitude => '53.4807125',
- longitude => '-2.2343765',
+ latitude => '53.480713',
+ longitude => '-2.234376',
},
{
pc => 'Glenthorpe Rd, Merton, Greater London SM4 4, UK',
- latitude => '51.3937997',
- longitude => '-0.2209596',
+ latitude => '51.3938',
+ longitude => '-0.22096',
},
)
{
diff --git a/templates/web/default/around/display_location.html b/templates/web/default/around/display_location.html
index 61d31e5a5..b46b242d6 100755
--- a/templates/web/default/around/display_location.html
+++ b/templates/web/default/around/display_location.html
@@ -34,8 +34,37 @@
robots => 'noindex,nofollow';
%]
+<form action="[% c.uri_for('/report/new') %]" method="post" name="mapForm" id="mapForm">
+<input type="hidden" name="submit_map" value="1">
+<input type="hidden" name="map" value="[% c.req.params.map | html %]">
+<input type="hidden" name="pc" value="[% pc | html %]">
+[% c.cobrand.form_elements('mapForm') %]
+
+<input type="hidden" name="latitude" id="fixmystreet.latitude" value="[% short_latitude | html %]">
+<input type="hidden" name="longitude" id="fixmystreet.longitude" value="[% short_longitude | html %]">
+
[% map_html %]
-[% map_links %]
+
+<p id='sub_map_links'>
+ [% IF c.req.params.no_pins %]
+ <a id='hide_pins_link' rel='nofollow' href='[% c.uri_with( { no_pins => 0 } ) %]'>[% loc('Show pins') %]</a>
+ [% ELSE %]
+ <a id='hide_pins_link' rel='nofollow' href='[% c.uri_with( { no_pins => 1 } ) %]'>[% loc('Hide pins') %]</a>
+ [% END %]
+ [% IF c.config.COUNTRY == 'GB' %]
+ |
+ [% IF c.req.params.all_pins %]
+ <a id='all_pins_link' rel='nofollow' href='[% c.uri_with( { no_pins => undef, all_pins => undef } ) %]'>[% loc('Hide stale reports') %]</a>
+ [% ELSE %]
+ <a id='all_pins_link' rel='nofollow' href='[% c.uri_with( { no_pins => undef, all_pins => 1 } ) %]'>[% loc('Include stale reports') %]</a>
+ [% END %]
+ [% END %]
+</p>
+
+[% IF c.config.COUNTRY == 'GB' %]
+<input type='hidden' id='all_pins' name='all_pins' value='[% all_pins | html %]'>
+[% END %]
+
</div>
<div id="side">
diff --git a/templates/web/default/report/new/fill_in_details.html b/templates/web/default/report/new/fill_in_details.html
index 1384bd7e5..1016a1ede 100644
--- a/templates/web/default/report/new/fill_in_details.html
+++ b/templates/web/default/report/new/fill_in_details.html
@@ -1,8 +1,25 @@
[% INCLUDE 'header.html', title => loc('Reporting a problem') %]
+[% IF report.used_map %]
+<form action="[% c.uri_for('/report/new') %]" method="post" name="mapForm" id="mapForm"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %]>
+<input type="hidden" name="submit_map" value="1">
+<input type="hidden" name="map" value="[% c.req.params.map | html %]">
+<input type="hidden" name="pc" value="[% pc | html %]">
+[% c.cobrand.form_elements('mapForm') %]
+[% ELSE %]
+<form action="[% c.uri_for('/report/new') %]" method="post" name="mapSkippedForm"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %]>
+<input type="hidden" name="pc" value="[% pc | html %]">
+<input type="hidden" name="skipped" value="1">
+[% c.cobrand.form_elements('mapSkippedForm') %]
+[% END %]
+
+<input type="hidden" name="latitude" id="fixmystreet.latitude" value="[% short_latitude | html %]">
+<input type="hidden" name="longitude" id="fixmystreet.longitude" value="[% short_longitude | html %]">
+
[% map_html %]
-</div>
+
[% IF report.used_map %]
+</div>
<div id="side">
[% ELSE %]
<div id="skipped-map">