diff options
Diffstat (limited to 'web')
-rwxr-xr-x | web/ajax.cgi | 2 | ||||
-rwxr-xr-x | web/alert.cgi | 45 | ||||
-rwxr-xr-x | web/contact.cgi | 10 | ||||
-rw-r--r-- | web/css/cobrands/emptyhomes/emptyhomes.css | 4 | ||||
-rw-r--r-- | web/css/core.css | 12 | ||||
-rw-r--r-- | web/css/emptyhomes.css | 182 | ||||
-rw-r--r-- | web/i/eha-logo.jpeg | bin | 0 -> 14680 bytes | |||
-rwxr-xr-x | web/index.cgi | 76 | ||||
-rw-r--r-- | web/js.js | 64 | ||||
-rwxr-xr-x | web/questionnaire.cgi | 1 | ||||
-rwxr-xr-x | web/reports.cgi | 62 | ||||
-rwxr-xr-x | web/rss.cgi | 37 | ||||
-rw-r--r-- | web/xsl.eha.xsl | 2 |
13 files changed, 161 insertions, 336 deletions
diff --git a/web/ajax.cgi b/web/ajax.cgi index 1b3ff5cf8..fff437846 100755 --- a/web/ajax.cgi +++ b/web/ajax.cgi @@ -19,7 +19,7 @@ sub main { my %input = map { $_ => $q->param($_) || '' } @vars; my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars; - # Our current X/Y bottom left of visible map + # Our current X/Y middle of visible map my $x = $input{x}; my $y = $input{y}; $x ||= 0; $x += 0; diff --git a/web/alert.cgi b/web/alert.cgi index 59b6607a4..5a7aef1fc 100755 --- a/web/alert.cgi +++ b/web/alert.cgi @@ -104,13 +104,12 @@ sub alert_list { my @types = (@$mySociety::VotingArea::council_parent_types, @$mySociety::VotingArea::council_child_types); my %councils = map { $_ => 1 } @$mySociety::VotingArea::council_parent_types; - my $areas = mySociety::MaPit::get_voting_areas_by_location({easting=>$e, northing=>$n}, 'polygon', \@types); + my $areas = mySociety::MaPit::call('point', "27700/$e,$n", type => \@types); my $cobrand = Page::get_cobrand($q); my ($success, $error_msg) = Cobrand::council_check($cobrand, $areas, $q, 'alert'); if (!$success){ return alert_front_page($q, $error_msg); } - $areas = mySociety::MaPit::get_voting_areas_info([ keys %$areas ]); return alert_front_page($q, _('That location does not appear to be covered by a council, perhaps it is offshore - please try somewhere more specific.')) if keys %$areas == 0; @@ -126,9 +125,9 @@ sub alert_list { $ward = $_; } } - push @options, [ 'council', $council->{area_id}, Page::short_name($council->{name}), + push @options, [ 'council', $council->{id}, Page::short_name($council->{name}), sprintf(_("Problems within %s"), $council->{name}) ]; - push @options, [ 'ward', $council->{area_id}.':'.$ward->{area_id}, Page::short_name($council->{name}) . '/' + push @options, [ 'ward', $council->{id}.':'.$ward->{id}, Page::short_name($council->{name}) . '/' . Page::short_name($ward->{name}), sprintf(_("Problems within %s ward"), $ward->{name}) ]; $options_start = "<div><ul id='rss_feed'>"; @@ -142,7 +141,7 @@ sub alert_list { foreach (values %$areas) { $council = $_; } - push @options, [ 'council', $council->{area_id}, Page::short_name($council->{name}), + push @options, [ 'council', $council->{id}, Page::short_name($council->{name}), sprintf(_("Problems within %s"), $council->{name}) ]; $options_start = "<div><ul id='rss_feed'>"; @@ -165,24 +164,24 @@ sub alert_list { } } push @options, - [ 'area', $district->{area_id}, Page::short_name($district->{name}), $district->{name} ], - [ 'area', $district->{area_id}.':'.$d_ward->{area_id}, Page::short_name($district->{name}) . '/' + [ 'area', $district->{id}, Page::short_name($district->{name}), $district->{name} ], + [ 'area', $district->{id}.':'.$d_ward->{id}, Page::short_name($district->{name}) . '/' . Page::short_name($d_ward->{name}), "$d_ward->{name} ward, $district->{name}" ], - [ 'area', $county->{area_id}, Page::short_name($county->{name}), $county->{name} ], - [ 'area', $county->{area_id}.':'.$c_ward->{area_id}, Page::short_name($county->{name}) . '/' + [ 'area', $county->{id}, Page::short_name($county->{name}), $county->{name} ], + [ 'area', $county->{id}.':'.$c_ward->{id}, Page::short_name($county->{name}) . '/' . Page::short_name($c_ward->{name}), "$c_ward->{name} ward, $county->{name}" ]; $options_start = '<div id="rss_list">'; $options = $q->p($q->strong(_('Problems within the boundary of:'))) . $q->ul(alert_list_options($q, @options)); @options = (); push @options, - [ 'council', $district->{area_id}, Page::short_name($district->{name}), $district->{name} ], - [ 'ward', $district->{area_id}.':'.$d_ward->{area_id}, Page::short_name($district->{name}) . '/' . Page::short_name($d_ward->{name}), + [ 'council', $district->{id}, Page::short_name($district->{name}), $district->{name} ], + [ 'ward', $district->{id}.':'.$d_ward->{id}, Page::short_name($district->{name}) . '/' . Page::short_name($d_ward->{name}), "$district->{name}, within $d_ward->{name} ward" ]; if ($q->{site} ne 'emptyhomes') { push @options, - [ 'council', $county->{area_id}, Page::short_name($county->{name}), $county->{name} ], - [ 'ward', $county->{area_id}.':'.$c_ward->{area_id}, Page::short_name($county->{name}) . '/' + [ 'council', $county->{id}, Page::short_name($county->{name}), $county->{name} ], + [ 'ward', $county->{id}.':'.$c_ward->{id}, Page::short_name($county->{name}) . '/' . Page::short_name($c_ward->{name}), "$county->{name}, within $c_ward->{name} ward" ]; $options .= $q->p($q->strong(_('Or problems reported to:'))) . $q->ul(alert_list_options($q, @options)); @@ -206,7 +205,7 @@ for the county council.'))) . '</div><div id="rss_buttons">'; $dist = $dist / 10.0; my $checked = ''; - $checked = ' checked' if $q->param('feed') && $q->param('feed') eq "local:$x:$y"; + $checked = ' checked' if $q->param('feed') && $q->param('feed') eq "local:$e:$n"; my $cobrand_form_elements = Cobrand::form_elements($cobrand, 'alerts', $q); my $pics = Cobrand::recent_photos($cobrand, 5, $e, $n, $dist); $pics = '<div id="alert_photos">' . $q->h2(_('Photos of recent nearby reports')) . $pics . '</div>' if $pics; @@ -234,20 +233,20 @@ feed, or enter your email address to subscribe to an email alert.')); my $rss_label = sprintf(_('Problems within %skm of this location'), $dist); $out .= <<EOF; <p id="rss_local"> -<input type="radio" name="feed" id="local:$x:$y" value="local:$x:$y"$checked> -<label for="local:$x:$y">$rss_label</label> +<input type="radio" name="feed" id="local:$e:$n" value="local:$e:$n"$checked> +<label for="local:$e:$n">$rss_label</label> EOF - my $rss_feed = Cobrand::url($cobrand, "/rss/$x,$y", $q); - my $default_link = Cobrand::url($cobrand, "/alert?type=local;feed=local:$x:$y", $q); + my $rss_feed = Cobrand::url($cobrand, "/rss/n/$e,$n", $q); + my $default_link = Cobrand::url($cobrand, "/alert?type=local;feed=local:$e:$n", $q); my $rss_details = _('(a default distance which covers roughly 200,000 people)'); $out .= $rss_details; $out .= " <a href='$rss_feed'><img src='/i/feed.png' width='16' height='16' title='" . _('RSS feed of nearby problems') . "' alt='" . _('RSS feed') . "' border='0'></a>"; $out .= '</p> <p id="rss_local_alt">' . _('(alternatively the RSS feed can be customised, within'); - my $rss_feed_2k = Cobrand::url($cobrand, "/rss/$x,$y/2", $q); - my $rss_feed_5k = Cobrand::url($cobrand, "/rss/$x,$y/5", $q); - my $rss_feed_10k = Cobrand::url($cobrand, "/rss/$x,$y/10", $q); - my $rss_feed_20k = Cobrand::url($cobrand, "/rss/$x,$y/20", $q); + my $rss_feed_2k = Cobrand::url($cobrand, "/rss/n/$e,$n/2", $q); + my $rss_feed_5k = Cobrand::url($cobrand, "/rss/n/$e,$n/5", $q); + my $rss_feed_10k = Cobrand::url($cobrand, "/rss/n/$e,$n/10", $q); + my $rss_feed_20k = Cobrand::url($cobrand, "/rss/n/$e,$n/20", $q); $out .= <<EOF; <a href="$rss_feed_2k">2km</a> / <a href="$rss_feed_5k">5km</a> / <a href="$rss_feed_10k">10km</a> / <a href="$rss_feed_20k">20km</a>) @@ -375,7 +374,7 @@ sub alert_rss { print $q->redirect($url); return; } elsif ($feed =~ /^local:(\d+):(\d+)$/) { - $url = $base_url . '/rss/' . $1 . ',' . $2; + $url = $base_url . '/rss/n/' . $1 . ',' . $2; $url .= "?" . $extra_params if ($extra_params); print $q->redirect($url); return; diff --git a/web/contact.cgi b/web/contact.cgi index bb4ed4913..6b82422a1 100755 --- a/web/contact.cgi +++ b/web/contact.cgi @@ -110,12 +110,12 @@ sub contact_details { <div class="contact-details"> <p>$sitename is a service provided by mySociety, which is the project of a registered charity. The charity is called UK Citizens Online Democracy and is charity number 1076346.</p> -<p>mySociety can be contacted by email at <a href="mailto:team\@mysociety.org">team\@mysociety.org</a>, +<p>mySociety can be contacted by email at <a href="mailto:hello@mysociety.org">hello@mysociety.org</a>, or by post at:</p> -<p>mySociety.org<br> -12 Duke's Road<br> -London<br> -WC1H 9AD<br> +<p>mySociety<br> +PO Box 839<br> +Oxford<br> +OX1 9LG<br> UK</p> </div> EOF diff --git a/web/css/cobrands/emptyhomes/emptyhomes.css b/web/css/cobrands/emptyhomes/emptyhomes.css index 121242415..293cb271c 100644 --- a/web/css/cobrands/emptyhomes/emptyhomes.css +++ b/web/css/cobrands/emptyhomes/emptyhomes.css @@ -81,6 +81,10 @@ blockquote { float: left; } +#header img { + margin-left: 0.5em; +} + #content { width: 100%; /* Must specify a width or IE goes crazy wrong! */ position: relative; diff --git a/web/css/core.css b/web/css/core.css index 4eb8496e2..5c8dad666 100644 --- a/web/css/core.css +++ b/web/css/core.css @@ -100,6 +100,7 @@ p#expl { margin: 1em auto; padding: 1em; -moz-border-radius: 1em; + -webkit-border-radius: 1em; border-radius: 1em; } @@ -126,6 +127,7 @@ p#expl { text-align: center; width: 5.5em; -moz-border-radius: 0.5em; + -webkit-border-radius: 0.5em; border-radius: 0.5em; float: left; margin: 0 1em 1em; @@ -191,7 +193,7 @@ fieldset div, #fieldset div { #map_box { float: right; - width: 510px; + width: 502px; /* Two pixels more than width of #map */ position: relative; padding-left: 20px; background-color: #ffffff; @@ -205,8 +207,8 @@ p#copyright { #map { border: solid 1px #000000; - width: 508px; - height: 508px; + width: 500px; /* Twice a tile width */ + height: 500px; overflow: hidden; position: relative; background-color: #f1f1f1; @@ -214,8 +216,8 @@ p#copyright { #drag { position: absolute; - width: 508px; - height: 508px; + width: 500px; + height: 500px; right: 0; top: 0; } diff --git a/web/css/emptyhomes.css b/web/css/emptyhomes.css deleted file mode 100644 index 0f608bd3a..000000000 --- a/web/css/emptyhomes.css +++ /dev/null @@ -1,182 +0,0 @@ -/* Smaller map */ -/* -#map_box { - width: 380px; -} -#map, #drag { - width: 378px; - height: 378px; -} -#watermark { - background: url("/i/mojwatermark-378.png"); - height: 84px; - width: 171px; - position: absolute; - bottom: 0; - right: 0; -} - -p#fixed, p#unknown { - margin-right: 400px; - width: auto; -} -*/ - -/* Generics */ - -body { - font-family: Geneva, Helvetica, Arial, sans-serif; - margin: 0; - padding: 0; - /* color: #a9aeb0; */ -} - -h1 { - margin: 0; - font-size: 165%; - padding: 3px; - color: #FFFFFF; - background-color: #9999CC; - background-color: #30517A; - -} -h2 { - font-size: 140%; - background-color: #B1BECF; - color: #30517A; - padding: 3px; -} - -h3 { - color: #30517A; -} - -select, input, textarea { - font-size: 99%; -} - -a:link { - color: #30517A; -} -a:visited { - color: #354664; -} -a:hover, a:active { - background-color: #B1BECF; -} - -blockquote { - border-left: solid 4px #013B63; -} - -.a { - color: #000000; - background-color: #DCDCED; /* #427499; */ - background-color: #B1BECF; -} - -/* Site layout */ - -#header { - font-size: 200%; - font-weight: bold; - margin: 0; - padding: 5px 0; - float: left; -} - -#content { - width: 100%; /* Must specify a width or IE goes crazy wrong! */ - position: relative; - margin: 0 auto; - max-width: 60em; -} - -/* Can't put the margin in #content because of above IE craziness */ -#wrapper { - clear: both; - margin: 0 2em 2em; - padding-top: 0.5em; -} - -#navigation { - float: right; - padding: 0; - margin: 0; - list-style-type: none; - font-size: 83%; -} -#navigation ul { - padding: 0; - margin: 0; -} -#navigation li { - display: inline; - padding: 0; - margin: 0; -} - -#navigation a { - display: -moz-inline-box; - display: inline-block; - padding: 0.5em 0.5em; -} -#navigation a:link, #navigation a:visited { - color: #30517A; -} -#navigation a:hover, #navigation a:active { - background-color: #DCDCED; - background-color: #9999CC; - background-color: #B1BECF; - - color: #ffffff; - color: #30517A; -} - -#nav_new a { - background-image: url("/i/new.png"); - background-repeat: no-repeat; - background-position: 100% 0; -} - -#logo { - border: none; - position: absolute; - top: 4em; - right: 10px; -} - -#footer { - clear: both; - font-size: 83%; - border-top: solid 2em #ffffff; - background-color: #80AE7D; - color: #FFFFFF; - margin: 2em 0 1em 0; - padding: 20px; -} -#footer a { - color: #FFFFFF; -} - -#postcodeForm { - background-color: #80AE7D; - color: #000000; - font-size: 130%; -} - -#front_stats div { - background-color: #80AE7D; - color: #000000; - /*padding: 0.5em 0; */ - width: 9em; -} - -#problem_form { - clear: both; -} - -#alert_links_area { - margin-top: 1px; -} - diff --git a/web/i/eha-logo.jpeg b/web/i/eha-logo.jpeg Binary files differnew file mode 100644 index 000000000..250be8502 --- /dev/null +++ b/web/i/eha-logo.jpeg diff --git a/web/index.cgi b/web/index.cgi index e39dd8921..a3ac1296c 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -1,12 +1,10 @@ #!/usr/bin/perl -w -I../perllib - +# # index.cgi: # Main code for FixMyStreet # # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org -# -# $Id: index.cgi,v 1.334 2010-01-15 16:55:26 matthew Exp $ use strict; use Standard; @@ -306,16 +304,13 @@ sub submit_problem { my $areas; if ($input{easting} && $input{northing}) { - $areas = mySociety::MaPit::get_voting_areas_by_location( - { easting=>$input{easting}, northing=>$input{northing} }, - 'polygon', [qw(WMC CTY CED DIS DIW MTD MTW COI COP LGD LGE UTA UTE UTW LBO LBW LAC SPC WAC NIE)] - ); + $areas = mySociety::MaPit::call('point', "27700/$input{easting},$input{northing}"); if ($input{council} =~ /^[\d,]+(\|[\d,]+)?$/) { my $no_details = $1 || ''; my %va = map { $_ => 1 } @$mySociety::VotingArea::council_parent_types; my %councils; foreach (keys %$areas) { - $councils{$_} = 1 if $va{$areas->{$_}}; + $councils{$_} = 1 if $va{$areas->{$_}->{type}}; } my @input_councils = split /,|\|/, $input{council}; foreach (@input_councils) { @@ -481,8 +476,8 @@ sub display_form { # Map was clicked on $pin_x = Page::click_to_tile($pin_tile_x, $pin_x); $pin_y = Page::click_to_tile($pin_tile_y, $pin_y, 1); - $input{x} ||= int($pin_x) - 1; - $input{y} ||= int($pin_y) - 1; + $input{x} ||= int($pin_x); + $input{y} ||= int($pin_y); $px = Page::tile_to_px($pin_x, $input{x}); $py = Page::tile_to_px($pin_y, $input{y}, 1); $easting = Page::tile_to_os($pin_x); @@ -515,12 +510,10 @@ sub display_form { $parent_types = [qw(DIS LBO MTD UTA LGD COI)] # No CTY if $q->{site} eq 'emptyhomes'; # XXX: I think we want in_gb_locale around the next line, needs testing - my $all_councils = mySociety::MaPit::get_voting_areas_by_location( - { easting => $easting, northing => $northing }, - 'polygon', $parent_types); + my $all_councils = mySociety::MaPit::call('point', "27700/$easting,$northing", type => $parent_types); # Let cobrand do a check - my ($success, $error_msg) = Cobrand::council_check($cobrand, $all_councils, $q, 'submit_problem'); + my ($success, $error_msg) = Cobrand::council_check($cobrand, $all_councils, $q, 'submit_problem'); if (!$success){ return front_page($q, $error_msg); } @@ -531,17 +524,15 @@ sub display_form { # Norwich is responsible for everything in its areas, no Norfolk delete $all_councils->{2233} if $all_councils->{2391}; - $all_councils = [ keys %$all_councils ]; return display_location($q, _('That spot does not appear to be covered by a council. If you have tried to report an issue past the shoreline, for example, -please specify the closest point on land.')) unless @$all_councils; - my $areas_info = mySociety::MaPit::get_voting_areas_info($all_councils); +please specify the closest point on land.')) unless %$all_councils; # Look up categories for this council or councils my $category = ''; my (%council_ok, @categories); my $categories = select_all("select area_id, category from contacts - where deleted='f' and area_id in (" . join(',', @$all_councils) . ')'); + where deleted='f' and area_id in (" . join(',', keys %$all_councils) . ')'); if ($q->{site} ne 'emptyhomes') { @$categories = sort { $a->{category} cmp $b->{category} } @$categories; foreach (@$categories) { @@ -574,7 +565,7 @@ please specify the closest point on land.')) unless @$all_councils; # Work out what help text to show, depending on whether we have council details my @councils = keys %council_ok; my $details; - if (@councils == @$all_councils) { + if (@councils == scalar keys %$all_councils) { $details = 'all'; } elsif (@councils == 0) { $details = 'none'; @@ -629,7 +620,7 @@ If this is not the correct location, simply click on the map again. ')); $vars{page_heading} = $q->h1(_('Reporting a problem')); if ($details eq 'all') { - my $council_list = join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @$all_councils); + my $council_list = join('</strong> or <strong>', map { $_->{name} } values %$all_councils); if ($q->{site} eq 'emptyhomes'){ $vars{text_help} = '<p>' . sprintf(_('All the information you provide here will be sent to <strong>%s</strong>. On the site, we will show the subject and details of the problem, plus your @@ -639,18 +630,18 @@ name if you give us permission.'), $council_list); The subject and details of the problem will be public, plus your name if you give us permission.'), $council_list); } - $vars{text_help} .= '<input type="hidden" name="council" value="' . join(',',@$all_councils) . '">'; + $vars{text_help} .= '<input type="hidden" name="council" value="' . join(',', keys %$all_councils) . '">'; } elsif ($details eq 'some') { my $e = Cobrand::contact_email($cobrand); my %councils = map { $_ => 1 } @councils; my @missing; - foreach (@$all_councils) { + foreach (keys %$all_councils) { push @missing, $_ unless $councils{$_}; } my $n = @missing; - my $list = join(' or ', map { $areas_info->{$_}->{name} } @missing); + my $list = join(' or ', map { $all_councils->{$_}->{name} } @missing); $vars{text_help} = '<p>All the information you provide here will be sent to <strong>' - . join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @councils) + . join('</strong> or <strong>', map { $all_councils->{$_}->{name} } @councils) . '</strong>. The subject and details of the problem will be public, plus your name if you give us permission.'; $vars{text_help} .= ' We do <strong>not</strong> yet have details for the other council'; @@ -661,8 +652,8 @@ problems for $list and emailing it to us at <a href='mailto:$e'>$e</a>."; . '|' . join(',', @missing) . '">'; } else { my $e = Cobrand::contact_email($cobrand); - my $list = join(' or ', map { $areas_info->{$_}->{name} } @$all_councils); - my $n = @$all_councils; + my $list = join(' or ', map { $_->{name} } values %$all_councils); + my $n = scalar keys %$all_councils; if ($q->{site} ne 'emptyhomes') { $vars{text_help} = '<p>We do not yet have details for the council'; $vars{text_help} .= ($n>1) ? 's that cover' : ' that covers'; @@ -810,17 +801,18 @@ sub display_location { } return Page::geocode_choice($error, '/', $q) if (ref($error) eq 'ARRAY'); return front_page($q, $error) if ($error); - my $parent_types = $mySociety::VotingArea::council_parent_types; - if ($easting && $northing) { - my $all_councils = mySociety::MaPit::get_voting_areas_by_location( - { easting => $easting, northing => $northing }, - 'polygon', $parent_types); - my ($success, $error_msg) = Cobrand::council_check($cobrand, $all_councils, $q, 'display_location'); - if (!$success){ - return front_page($q, $error_msg); - } + + if (!$easting || !$northing) { + $easting = Page::tile_to_os($x); + $northing = Page::tile_to_os($y); } + # Check this location is okay to be displayed for the cobrand + my $parent_types = $mySociety::VotingArea::council_parent_types; + my $all_councils = mySociety::MaPit::call('point', "27700/$easting,$northing", type => $parent_types); + my ($success, $error_msg) = Cobrand::council_check($cobrand, $all_councils, $q, 'display_location'); + return front_page($q, $error_msg) unless $success; + # Deal with pin hiding/age my ($hide_link, $hide_text, $all_link, $all_text, $interval); if ($input{all_pins}) { @@ -874,8 +866,8 @@ sub display_location { 'map' => Page::display_map($q, x => $x, 'y' => $y, type => 1, pins => $pins, post => $map_links ), map_end => Page::display_map_end(1), url_home => Cobrand::url($cobrand, '/', $q), - url_rss => Cobrand::url($cobrand, NewURL($q, -retain => 1, -url=> "/rss/$x,$y", pc => undef, x => undef, 'y' => undef), $q), - url_email => Cobrand::url($cobrand, NewURL($q, -retain => 1, pc => undef, -url=>'/alert', x=>$x, 'y'=>$y, feed=>"local:$x:$y"), $q), + url_rss => Cobrand::url($cobrand, NewURL($q, -retain => 1, -url=> "/rss/n/$easting,$northing", pc => undef, x => undef, 'y' => undef), $q), + url_email => Cobrand::url($cobrand, NewURL($q, -retain => 1, pc => undef, -url=>'/alert', x=>$x, 'y'=>$y, feed=>"local:$easting:$northing"), $q), url_skip => $url_skip, email_me => _('Email me new local problems'), rss_alt => _('RSS feed'), @@ -895,7 +887,7 @@ sub display_location { ); my %params = ( - rss => [ _('Recent local problems, FixMyStreet'), "/rss/$x,$y" ] + rss => [ _('Recent local problems, FixMyStreet'), "/rss/n/$easting,$northing" ] ); return (Page::template_include('map', $q, Page::template_root($q), %vars), %params); @@ -936,12 +928,12 @@ sub display_problem { my ($x, $y, $x_tile, $y_tile, $px, $py) = Page::os_to_px_with_adjust($q, $problem->{easting}, $problem->{northing}, $input{x}, $input{y}); # Try and have pin near centre of map - if (!$input{x} && $x - $x_tile < 0.5) { - $x_tile -= 1; + if (!$input{x} && $x - $x_tile > 0.5) { + $x_tile += 1; $px = Page::os_to_px($problem->{easting}, $x_tile); } - if (!$input{y} && $y - $y_tile < 0.5) { - $y_tile -= 1; + if (!$input{y} && $y - $y_tile > 0.5) { + $y_tile += 1; $py = Page::os_to_px($problem->{northing}, $y_tile, 1); } @@ -31,14 +31,14 @@ YAHOO.util.Event.onContentReady('compass', function() { if (document.getElementById('map').offsetWidth > 510) return; var points = this.getElementsByTagName('a'); - YAHOO.util.Event.addListener(points[1], 'click', compass_pan, { x:0, y:tileheight }); - YAHOO.util.Event.addListener(points[3], 'click', compass_pan, { x:tilewidth, y:0 }); - YAHOO.util.Event.addListener(points[5], 'click', compass_pan, { x:-tilewidth, y:0 }); - YAHOO.util.Event.addListener(points[7], 'click', compass_pan, { x:0, y:-tileheight }); - YAHOO.util.Event.addListener(points[0], 'click', compass_pan, { x:tilewidth, y:tileheight }); - YAHOO.util.Event.addListener(points[2], 'click', compass_pan, { x:-tilewidth, y:tileheight }); - YAHOO.util.Event.addListener(points[6], 'click', compass_pan, { x:tilewidth, y:-tileheight }); - YAHOO.util.Event.addListener(points[8], 'click', compass_pan, { x:-tilewidth, y:-tileheight }); + YAHOO.util.Event.addListener(points[1], 'click', compass_pan, { x:0, y:fixmystreet.tileheight }); + YAHOO.util.Event.addListener(points[3], 'click', compass_pan, { x:fixmystreet.tilewidth, y:0 }); + YAHOO.util.Event.addListener(points[5], 'click', compass_pan, { x:-fixmystreet.tilewidth, y:0 }); + YAHOO.util.Event.addListener(points[7], 'click', compass_pan, { x:0, y:-fixmystreet.tileheight }); + YAHOO.util.Event.addListener(points[0], 'click', compass_pan, { x:fixmystreet.tilewidth, y:fixmystreet.tileheight }); + YAHOO.util.Event.addListener(points[2], 'click', compass_pan, { x:-fixmystreet.tilewidth, y:fixmystreet.tileheight }); + YAHOO.util.Event.addListener(points[6], 'click', compass_pan, { x:fixmystreet.tilewidth, y:-fixmystreet.tileheight }); + YAHOO.util.Event.addListener(points[8], 'click', compass_pan, { x:-fixmystreet.tilewidth, y:-fixmystreet.tileheight }); YAHOO.util.Event.addListener(points[4], 'click', compass_pan, { home:1, orig_x:drag_x, orig_y:drag_y }); }); @@ -47,7 +47,7 @@ YAHOO.util.Event.onContentReady('map', function() { // if (document.getElementById('mapForm') && (/safari/.test(ua) || /Konqueror/.test(ua))) return; if (document.getElementById('map').offsetWidth > 510) return; new YAHOO.util.DDMap('map'); - update_tiles(start_x, start_y, true); + update_tiles(fixmystreet.start_x, fixmystreet.start_y, true); }); @@ -57,8 +57,8 @@ YAHOO.util.Event.onContentReady('mapForm', function() { this.onsubmit = function() { return false; }; } - this.x.value = fms_x + 2; - this.y.value = fms_y + 2; + this.x.value = fixmystreet.x + 3; + this.y.value = fixmystreet.y + 3; /* if (swfu && swfu.getStats().files_queued > 0) { swfu.startUpload(); @@ -142,21 +142,21 @@ YAHOO.util.Event.addListener('all_pins_link', 'click', function(e) { if (this.innerHTML == 'Include stale reports') { this.innerHTML = 'Hide stale reports'; document.getElementById('all_pins').value = '1'; - load_pins(fms_x, fms_y); + load_pins(fixmystreet.x, fixmystreet.y); } else if (this.innerHTML == 'Cynnwys hen adroddiadau') { this.innerHTML = 'Cuddio hen adroddiadau'; document.getElementById('all_pins').value = '1'; welsh = 1; - load_pins(fms_x, fms_y); + load_pins(fixmystreet.x, fixmystreet.y); } else if (this.innerHTML == 'Cuddio hen adroddiadau') { this.innerHTML = 'Cynnwys hen adroddiadau'; welsh = 1; document.getElementById('all_pins').value = ''; - load_pins(fms_x, fms_y); + load_pins(fixmystreet.x, fixmystreet.y); } else if (this.innerHTML == 'Hide stale reports') { this.innerHTML = 'Include stale reports'; document.getElementById('all_pins').value = ''; - load_pins(fms_x, fms_y); + load_pins(fixmystreet.x, fixmystreet.y); } if (welsh) { document.getElementById('hide_pins_link').innerHTML = 'Cuddio pinnau'; @@ -254,8 +254,6 @@ var swfu_settings = { // I love the global var tile_x = 0; var tile_y = 0; -var tilewidth = 254; -var tileheight = 254; var myAnim; function pan(x, y) { @@ -285,22 +283,22 @@ function update_tiles(dx, dy, force) { drag.style.left = drag_x + 'px'; drag.style.top = drag_y + 'px'; - var horizontal = Math.floor(old_drag_x/tilewidth) - Math.floor(drag_x/tilewidth); - var vertical = Math.floor(old_drag_y/tileheight) - Math.floor(drag_y/tileheight); + var horizontal = Math.floor(old_drag_x/fixmystreet.tilewidth) - Math.floor(drag_x/fixmystreet.tilewidth); + var vertical = Math.floor(old_drag_y/fixmystreet.tileheight) - Math.floor(drag_y/fixmystreet.tileheight); if (!horizontal && !vertical && !force) return; - fms_x += horizontal; + fixmystreet.x += horizontal; tile_x += horizontal; - fms_y -= vertical; + fixmystreet.y -= vertical; tile_y += vertical; - var url = [ root_path + '/tilma/tileserver/10k-full/', fms_x, '-', (fms_x+5), ',', fms_y, '-', (fms_y+5), '/JSON' ].join(''); + var url = [ root_path + '/tilma/tileserver/' + fixmystreet.tile_type + '/', fixmystreet.x, '-', (fixmystreet.x+5), ',', fixmystreet.y, '-', (fixmystreet.y+5), '/JSON' ].join(''); YAHOO.util.Connect.asyncRequest('GET', url, { success: urls_loaded, failure: urls_not_loaded, argument: [tile_x, tile_y] }); if (force) return; - load_pins(fms_x, fms_y); + load_pins(fixmystreet.x, fixmystreet.y); } function load_pins(x, y) { @@ -311,8 +309,8 @@ function load_pins(x, y) { } var ajax_params = [ 'sx=' + document.getElementById('formX').value, 'sy=' + document.getElementById('formY').value, - 'x=' + (x+2), - 'y=' + (y+2), + 'x=' + (x+3), + 'y=' + (y+3), 'all_pins=' + all_pins ]; if (document.getElementById('extra_param')) { @@ -349,8 +347,8 @@ function urls_loaded(o) { if (tiles[i][j] == null) continue; var jj = (j + o.argument[0]); var id = [ 't', ii, '.', jj ].join(''); - var xx = fms_x+j; - var yy = fms_y+5-i; + var xx = fixmystreet.x+j; + var yy = fixmystreet.y+5-i; var img = document.getElementById(id); if (img) { if (!img.galleryimg) { img.galleryimg = false; } @@ -359,15 +357,15 @@ function urls_loaded(o) { continue; } img = cloneNode(); - img.style.top = ((ii-2)*tileheight) + 'px'; - img.style.left = ((jj-2)*tilewidth) + 'px'; + img.style.top = ((ii-2)*fixmystreet.tileheight) + 'px'; + img.style.left = ((jj-2)*fixmystreet.tilewidth) + 'px'; img.name = [ 'tile_', xx, '.', yy ].join('') img.id = id; if (browser) { img.style.visibility = 'hidden'; img.onload=function() { this.style.visibility = 'visible'; } } - img.src = 'http://tilma.mysociety.org/tileserver/10k-full/' + tiles[i][j]; + img.src = 'http://tilma.mysociety.org/tileserver/' + fixmystreet.tile_type + '/' + tiles[i][j]; tileCache[id] = { x: xx, y: yy, t: img }; drag.appendChild(img); } @@ -387,8 +385,8 @@ function cloneNode() { } img.onclick = drag_check; img.style.position = 'absolute'; - img.style.width = tilewidth + 'px'; - img.style.height = tileheight + 'px'; + img.style.width = fixmystreet.tilewidth + 'px'; + img.style.height = fixmystreet.tileheight + 'px'; img.galleryimg = false; img.alt = 'Loading...'; } else { @@ -400,7 +398,7 @@ function cloneNode() { var tileCache=[]; function cleanCache() { for (var i in tileCache) { - if (tileCache[i].x < fms_x || tileCache[i].x > fms_x+5 || tileCache[i].y < fms_y || tileCache[i].y > fms_y+5) { + if (tileCache[i].x < fixmystreet.x || tileCache[i].x > fixmystreet.x+5 || tileCache[i].y < fixmystreet.y || tileCache[i].y > fixmystreet.y+5) { var t = tileCache[i].t; t.parentNode.removeChild(t); // de-leak? delete tileCache[i]; diff --git a/web/questionnaire.cgi b/web/questionnaire.cgi index f7b7df0e1..1da410b80 100755 --- a/web/questionnaire.cgi +++ b/web/questionnaire.cgi @@ -14,7 +14,6 @@ use Error qw(:try); use CrossSell; use mySociety::AuthToken; use mySociety::Locale; -use mySociety::MaPit; use mySociety::Web qw(ent); sub main { diff --git a/web/reports.cgi b/web/reports.cgi index 6c5796079..bc418db7c 100755 --- a/web/reports.cgi +++ b/web/reports.cgi @@ -33,28 +33,31 @@ sub main { my ($one_council, $area_type, $area_name); if ($q_council =~ /^(\d\d)([a-z]{2})?([a-z]{2})?$/i) { - my $va_info = mySociety::MaPit::get_voting_area_info(uc $q_council); + my $va_info = mySociety::MaPit::call('area', uc $q_council); + if ($va_info->{error}) { # Given a bad/old ONS code + print $q->redirect($base_url . '/reports'); + return; + } $area_name = Page::short_name($va_info->{name}); if (length($q_council) == 6) { - $va_info = mySociety::MaPit::get_voting_area_info($va_info->{parent_area_id}); + $va_info = mySociety::MaPit::call('area', $va_info->{parent_area}); $area_name = Page::short_name($va_info->{name}) . '/' . $area_name; } $rss = '/rss' if $rss; print $q->redirect($base_url . $rss . '/reports/' . $area_name); return; } elsif ($q_council =~ /\D/) { - (my $qc = $q_council) =~ s/ and / & /; - my $areas = mySociety::MaPit::get_voting_area_by_name($qc, $mySociety::VotingArea::council_parent_types, 10); + my $areas = mySociety::MaPit::call('areas', $q_council, type => $mySociety::VotingArea::council_parent_types, min_generation=>10 ); if (keys %$areas == 1) { ($one_council) = keys %$areas; $area_type = $areas->{$one_council}->{type}; $area_name = $areas->{$one_council}->{name}; } else { foreach (keys %$areas) { - if ($areas->{$_}->{name} =~ /^\Q$qc\E (Borough|City|District|County) Council$/) { + if ($areas->{$_}->{name} =~ /^\Q$q_council\E (Borough|City|District|County) Council$/) { $one_council = $_; $area_type = $areas->{$_}->{type}; - $area_name = $qc; + $area_name = $q_council; } } } @@ -63,7 +66,7 @@ sub main { return; } } elsif ($q_council =~ /^\d+$/) { - my $va_info = mySociety::MaPit::get_voting_area_info($q_council); + my $va_info = mySociety::MaPit::call('area', $q_council); $area_name = $va_info->{name}; print $q->redirect($base_url . '/reports/' . Page::short_name($area_name)); return; @@ -74,9 +77,9 @@ sub main { my $q_ward = $q->param('ward') || ''; my $ward; if ($one_council && $q_ward) { - my $qw = mySociety::MaPit::get_voting_area_by_name($q_ward, $mySociety::VotingArea::council_child_types, 10); + my $qw = mySociety::MaPit::call('areas', $q_ward, type => $mySociety::VotingArea::council_child_types, min_generation => 10); foreach my $id (sort keys %$qw) { - if ($qw->{$id}->{parent_area_id} == $one_council) { + if ($qw->{$id}->{parent_area} == $one_council) { $ward = $id; last; } @@ -116,21 +119,21 @@ sub main { return; } - my %councils; + my $areas_info; if ($one_council) { - %councils = ( $one_council => 1 ); + $areas_info = mySociety::MaPit::call('areas', $one_council); } else { # Show all councils on main report page my $ignore = 'LGD'; $ignore .= '|CTY' if $q->{site} eq 'emptyhomes'; my @types = grep { !/$ignore/ } @$mySociety::VotingArea::council_parent_types; - %councils = map { $_ => 1 } @{mySociety::MaPit::get_areas_by_type(\@types, 10)}; + $areas_info = mySociety::MaPit::call('areas', [ @types ], min_generation=>10 ); } my $problems = Problems::council_problems($ward, $one_council); my (%fixed, %open); - my $re_councils = join('|', keys %councils); + my $re_councils = join('|', keys %$areas_info); foreach my $row (@$problems) { if (!$row->{council}) { # Problem was not sent to any council, add to possible councils @@ -148,7 +151,6 @@ sub main { } } - my $areas_info = mySociety::MaPit::get_voting_areas_info([keys %councils]); if (!$one_council) { print Page::header($q, title=>_('Summary reports'), expires=>'+1h'); print $q->p( @@ -162,7 +164,7 @@ sub main { print '<th>' . _('Old problems,<br>state unknown') . '</th>'; } print '<th>' . _('Recently fixed') . '</th><th>' . _('Older fixed') . '</th></tr>'; - foreach (sort { $areas_info->{$a}->{name} cmp $areas_info->{$b}->{name} } keys %councils) { + foreach (sort { $areas_info->{$a}->{name} cmp $areas_info->{$b}->{name} } keys %$areas_info) { print '<tr align="center"'; ++$c; if ($areas_info->{$_}->{generation_high}==10) { @@ -227,7 +229,7 @@ sub main { } if ($open{$one_council}) { - my $col = list_problems($q, _('New problems'), $open{$one_council}{new}, $all); + my $col = list_problems($q, _('New problems'), $open{$one_council}{new}, $all, 0); my $old = []; if ($q->{site} eq 'emptyhomes') { push @$old, @{$open{$one_council}{older}} if $open{$one_council}{older}; @@ -235,15 +237,15 @@ sub main { } else { $old = $open{$one_council}{older}; } - $col .= list_problems($q, _('Older problems'), $old, $all); + $col .= list_problems($q, _('Older problems'), $old, $all, 0); if ($q->{site} ne 'emptyhomes') { - $col .= list_problems($q, _('Old problems, state unknown'), $open{$one_council}{unknown}, $all); + $col .= list_problems($q, _('Old problems, state unknown'), $open{$one_council}{unknown}, $all, 0); } $vars{col_problems} = $col; } if ($fixed{$one_council}) { - my $col = list_problems($q, _('Recently fixed'), $fixed{$one_council}{new}, $all); - $col .= list_problems($q, _('Old fixed'), $fixed{$one_council}{old}, $all); + my $col = list_problems($q, _('Recently fixed'), $fixed{$one_council}{new}, $all, 1); + $col .= list_problems($q, _('Old fixed'), $fixed{$one_council}{old}, $all, 1); $vars{col_fixed} = $col; } print Page::header($q, context => 'reports', title=>sprintf(_('%s - Summary reports'), $name), rss => [ sprintf(_('Problems within %s, FixMyStreet'), $name), Cobrand::url($cobrand, $rss_url, $q) ]); @@ -261,11 +263,11 @@ sub add_row { my $type = ($row->{duration} > 2 * $fourweeks) ? 'unknown' : ($row->{age} > $fourweeks ? 'older' : 'new'); - my $entry = [ $row->{id}, $row->{title}, $row->{detail}, $councils ]; + $row->{councils} = $councils; #Fixed problems are either old or new - push @{$fixed->{$council}{$duration}}, $entry if $row->{state} eq 'fixed'; + push @{$fixed->{$council}{$duration}}, $row if $row->{state} eq 'fixed'; # Open problems are either unknown, older, or new - push @{$open->{$council}{$type}}, $entry if $row->{state} eq 'confirmed'; + push @{$open->{$council}{$type}}, $row if $row->{state} eq 'confirmed'; } sub summary_cell { @@ -276,18 +278,18 @@ sub summary_cell { } sub list_problems { - my ($q, $title, $problems, $all) = @_; + my ($q, $title, $problems, $all, $fixed) = @_; return '' unless $problems; my $cobrand = Page::get_cobrand($q); my $out = "<h3>$title</h3>\n<ul>"; - foreach (@$problems) { - my $url = Cobrand::url($cobrand, "/report/" . $_->[0], $q); + foreach (sort { $fixed ? ($a->{duration} <=> $b->{duration}) : ($a->{age} <=> $b->{age}) } @$problems) { + my $url = Cobrand::url($cobrand, "/report/" . $_->{id}, $q); $out .= '<li><a href="' . $url . '">'; - $out .= ent($_->[1]); + $out .= ent($_->{title}); $out .= '</a>'; - $out .= ' <small>(sent to both)</small>' if $_->[3]>1; - $out .= ' <small>(not sent to council)</small>' if $_->[3]==0 && $q->{site} ne 'emptyhomes'; - $out .= '<br><small>' . ent($_->[2]) . '</small>' if $all; + $out .= ' <small>(sent to both)</small>' if $_->{councils}>1; + $out .= ' <small>(not sent to council)</small>' if $_->{councils}==0 && $q->{site} ne 'emptyhomes'; + $out .= '<br><small>' . ent($_->{detail}) . '</small>' if $all; $out .= '</li>'; } $out .= '</ul>'; diff --git a/web/rss.cgi b/web/rss.cgi index a2810aee8..a2d9bcb4f 100755 --- a/web/rss.cgi +++ b/web/rss.cgi @@ -25,13 +25,13 @@ sub main { my $out; if ($type eq 'local_problems') { $out = rss_local_problems($q); - return unless $out; + return unless $out; } elsif ($type eq 'new_updates') { my $id = $q->param('id'); my $problem = Problems::fetch_problem($id); if (!$problem) { - print $q->header(-status=>'404 Not Found',-type=>'text/html'); - return; + print $q->header(-status=>'404 Not Found',-type=>'text/html'); + return; } my $qs = 'report/' . $id; $out = mySociety::Alert::generate_rss($type, $xsl, $qs, [$id], undef, $cobrand, $q); @@ -43,7 +43,7 @@ sub main { $out = mySociety::Alert::generate_rss($type, $xsl, $qs, [$id], undef, $cobrand. $q); } elsif ($type eq 'area_problems') { my $id = $q->param('id'); - my $va_info = mySociety::MaPit::get_voting_area_info($id); + my $va_info = mySociety::MaPit::call('area', $id); my $qs = '/'.$id; $out = mySociety::Alert::generate_rss($type, $xsl, $qs, [$id], { NAME => $va_info->{name} }, $cobrand, $q); } elsif ($type eq 'all_problems') { @@ -65,18 +65,30 @@ sub rss_local_problems { my $y = $q->param('y'); my $lat = $q->param('lat'); my $lon = $q->param('lon'); + my $e = $q->param('e'); + my $n = $q->param('n'); + my $d = $q->param('d') || ''; + $d = '' unless $d =~ /^\d+$/; + my $d_str = ''; + $d_str = "/$d" if $d; + my $cobrand = Page::get_cobrand($q); my $base = Cobrand::base_url($cobrand); - my ($e, $n); if ($lat) { # In the UK, it'll never be 0 :) ($e, $n) = mySociety::GeoUtil::wgs84_to_national_grid($lat, $lon, 'G'); + $e = int($e + 0.5); + $n = int($n + 0.5); + print $q->redirect(-location => "$base/rss/n/$e,$n$d_str"); + return ''; + } elsif ($x && $y) { + # 5000/31 as initial scale factor for these RSS feeds, now variable so redirect. + $e = int( ($x * 5000/31) + 0.5 ); + $n = int( ($y * 5000/31) + 0.5 ); + print $q->redirect(-location => "$base/rss/n/$e,$n$d_str"); + return ''; + } elsif ($e && $n) { $x = int(Page::os_to_tile($e)); $y = int(Page::os_to_tile($n)); - print $q->redirect(-location => "$base/rss/$x/$y"); - return ''; - } elsif ($x && $y) { - $e = Page::tile_to_os($x); - $n = Page::tile_to_os($y); ($lat, $lon) = mySociety::GeoUtil::national_grid_to_wgs84($e, $n, 'G'); } elsif ($pc) { my $error; @@ -86,14 +98,13 @@ sub rss_local_problems { $error = shift; }; unless ($error) { - print $q->redirect(-location => "$base/rss/$x/$y"); + print $q->redirect(-location => "$base/rss/n/$e,$n$d_str"); } return ''; } else { - die "Missing x/y, lat/lon, or postcode parameter in RSS feed"; + die "Missing E/N, x/y, lat/lon, or postcode parameter in RSS feed"; } my $qs = "?x=$x;y=$y"; - my $d = $q->param('d'); if ($d) { $qs .= ";d=$d"; $d = 100 if $d > 100; diff --git a/web/xsl.eha.xsl b/web/xsl.eha.xsl index b79abb9f5..6c66037d7 100644 --- a/web/xsl.eha.xsl +++ b/web/xsl.eha.xsl @@ -8,7 +8,7 @@ <head> <title><xsl:value-of select="$title"/> RSS Feed</title> <link rel="stylesheet" href="/css/core.css"/> - <link rel="stylesheet" href="/css/emptyhomes.css"/> + <link rel="stylesheet" href="/css/cobrands/emptyhomes/emptyhomes.css"/> </head> <body> <div id="header"><a href="http://www.emptyhomes.com/"><img border="0" src="/i/eha.png" alt="Empty Homes Agency" width="272" height="71"/></a></div> |