diff options
29 files changed, 487 insertions, 219 deletions
diff --git a/conf/httpd.conf-example b/conf/httpd.conf-example index 54c4b90ac..8abb13831 100644 --- a/conf/httpd.conf-example +++ b/conf/httpd.conf-example @@ -56,6 +56,9 @@ RewriteRule ^/alerts/?$ /alert [R=permanent,L] RewriteRule /tilma/(.*) http://tilma.mysociety.org/$1 [P,L] ProxyPassReverse /tilma/ http://tilma.mysociety.org/ +RewriteRule /mapit/(.*) http://mapit.mysociety.org/$1 [P,L] +ProxyPassReverse /mapit/ http://mapit.mysociety.org/ + # serve static files directly RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f RewriteRule /(.+) /$1 [L] diff --git a/perllib/Catalyst/Plugin/Session/State/Cookie.pm b/perllib/Catalyst/Plugin/Session/State/Cookie.pm index 7ffc77f1f..c4b61123b 100644 --- a/perllib/Catalyst/Plugin/Session/State/Cookie.pm +++ b/perllib/Catalyst/Plugin/Session/State/Cookie.pm @@ -127,6 +127,8 @@ sub set_session_cookie_expire { else { delete $c->session->{__cookie_expires}; } + # Force the cookie to be regenerated + $c->set_session_id( $c->sessionid ); return 1; } diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm index 47b290eff..90f1f24bc 100644 --- a/perllib/FixMyStreet/App.pm +++ b/perllib/FixMyStreet/App.pm @@ -51,8 +51,7 @@ __PACKAGE__->config( 'Plugin::Session' => { # Catalyst::Plugin::Session::Store::DBIC dbic_class => 'DB::Session', - expires => 3600 * 24 * 7 * 6, # 6 months - cookie_expires => 0 + expires => 3600 * 24 * 7 * 4, # 4 weeks }, 'Plugin::Authentication' => { @@ -181,7 +180,8 @@ sub setup_request { Memcached::set_namespace( FixMyStreet->config('BCI_DB_NAME') . ":" ); - FixMyStreet::Map::set_map_class( $c->request->param('map') ); + my $map = $host =~ /^osm\./ ? 'OSM' : $c->req->param('map'); + FixMyStreet::Map::set_map_class( $map ); return $c; } diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index ec1fde4e4..4ca559fad 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -196,6 +196,7 @@ sub display_location : Private { } @$on_map_all, @$around_map; } + $c->stash->{page} = 'around'; # So the map knows to make clickable pins, update on pan FixMyStreet::Map::display_map( $c, latitude => $latitude, @@ -234,31 +235,19 @@ the map. sub ajax : Path('/ajax') { my ( $self, $c ) = @_; - # Our current X/Y middle of visible map - my $x = ( $c->req->param('x') || 0 ) + 0; - my $y = ( $c->req->param('y') || 0 ) + 0; - - # Where we started as that's the (0,0) we have to work to - my $sx = ( $c->req->param('sx') || 0 ) + 0; - my $sy = ( $c->req->param('sy') || 0 ) + 0; - # how far back should we go? my $all_pins = $c->req->param('all_pins') ? 1 : undef; my $interval = $all_pins ? undef : $c->cobrand->on_map_default_max_pin_age; # extract the data from the map my ( $pins, $on_map, $around_map, $dist ) = - FixMyStreet::Map::map_pins( $c, $x, $y, $sx, $sy, $interval ); + FixMyStreet::Map::map_pins( $c, $interval ); # render templates to get the html - # my $on_map_list_html = $c->forward( - # "View::Web", "render", my $on_map_list_html = $c->view('Web') ->render( $c, 'around/on_map_list_items.html', { on_map => $on_map } ); - # my $around_map_list_html = $c->forward( - # "View::Web", "render", my $around_map_list_html = $c->view('Web')->render( $c, 'around/around_map_list_items.html', @@ -278,8 +267,12 @@ sub ajax : Path('/ajax') { $c->res->content_type('text/javascript; charset=utf-8'); $c->res->header( 'Cache_Control' => 'max-age=0' ); - # Set the body - note that the js needs the surrounding brackets. - $c->res->body("($body)"); + if ( $c->req->param('bbox') ) { + $c->res->body($body); + } else { + # The JS needs the surrounding brackets for Tilma + $c->res->body("($body)"); + } } __PACKAGE__->meta->make_immutable; diff --git a/perllib/FixMyStreet/App/Controller/Auth.pm b/perllib/FixMyStreet/App/Controller/Auth.pm index 8aed746ec..ebb3510d0 100644 --- a/perllib/FixMyStreet/App/Controller/Auth.pm +++ b/perllib/FixMyStreet/App/Controller/Auth.pm @@ -71,7 +71,11 @@ sub sign_in : Private { return 1; } - $c->stash->{sign_in_error} = 1; + $c->stash( + sign_in_error => 1, + email => $email, + remember_me => $remember_me, + ); return; } diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm index a146b85ce..90674b294 100755 --- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm +++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm @@ -19,24 +19,17 @@ Deals with report questionnaires. =cut -=head2 load_questionnaire +=head2 check_questionnaire -Loads the questionnaire from the database, and checks it still needs answering -and is in the right state. Also finds out if this user has answered the -"ever reported" question before. +Checks the questionnaire still needs answering and is in the right state. Also +finds out if this user has answered the "ever reported" question before. =cut -sub load_questionnaire : Private { +sub check_questionnaire : Private { my ( $self, $c ) = @_; - my $questionnaire = $c->model('DB::Questionnaire')->find( - { id => $c->stash->{id} }, - { prefetch => 'problem' } - ); - $c->detach('missing_problem') unless $questionnaire; - - $c->stash->{questionnaire} = $questionnaire; + my $questionnaire = $c->stash->{questionnaire}; my $problem_id = $questionnaire->problem_id; @@ -155,8 +148,8 @@ sub submit_creator_fixed : Private { sub submit_standard : Private { my ( $self, $c ) = @_; - $c->forward( '/tokens/load_questionnaire_id', [ $c->req->params->{token} ] ); - $c->forward( 'load_questionnaire' ); + $c->forward( '/tokens/load_questionnaire', [ $c->req->params->{token} ] ); + $c->forward( 'check_questionnaire' ); $c->forward( 'process_questionnaire' ); my $problem = $c->stash->{problem}; @@ -270,7 +263,7 @@ sub process_questionnaire : Private { # Sent here from email token action. Simply load and display questionnaire. sub index : Private { my ( $self, $c ) = @_; - $c->forward( 'load_questionnaire' ); + $c->forward( 'check_questionnaire' ); $c->forward( 'display' ); } diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 4488ce8cd..3a7d18a1c 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -71,10 +71,6 @@ phone partial -=head2 can be ignored - -all_pins: related to map display - not relevant to creation of a new report - =cut sub report_new : Path : Args(0) { diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index fc8c4cd0e..9cec0fdfe 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -93,10 +93,36 @@ sub ward : Path : Args(2) { $c->forward( 'load_and_group_problems' ); $c->forward( 'sort_problems' ); - $c->stash->{rss_url} = '/rss/reports/' - . $c->cobrand->short_name( $c->stash->{council}, $c->stash->{areas_info} ); + my $council_short = $c->cobrand->short_name( $c->stash->{council}, $c->stash->{areas_info} ); + $c->stash->{rss_url} = '/rss/reports/' . $council_short; $c->stash->{rss_url} .= '/' . $c->cobrand->short_name( $c->stash->{ward} ) if $c->stash->{ward}; + + $c->stash->{council_url} = '/reports/' . $council_short; + + my $pins = $c->stash->{pins}; + + # Even though front end doesn't yet have it, have it on this page, it's better! + FixMyStreet::Map::set_map_class( 'FMS' ); + FixMyStreet::Map::display_map( + $c, + latitude => @$pins ? $pins->[0]{latitude} : 0, + longitude => @$pins ? $pins->[0]{longitude} : 0, + area => $c->stash->{ward} ? $c->stash->{ward}->{id} : $c->stash->{council}->{id}, + pins => $pins, + any_zoom => 1, + ); + + # List of wards + unless ($c->stash->{ward}) { + my $children = mySociety::MaPit::call('area/children', $c->stash->{council}->{id} ); + foreach (values %$children) { + $_->{url} = $c->uri_for( $c->stash->{council_url} + . '/' . $c->cobrand->short_name( $_ ) + ); + } + $c->stash->{children} = $children; + } } sub rss_council : Regex('^rss/(reports|area)$') : Args(1) { @@ -258,41 +284,41 @@ sub load_parent : Private { sub load_and_group_problems : Private { my ( $self, $c ) = @_; + my $page = $c->req->params->{p} || 1; + my $where = { state => [ FixMyStreet::DB::Result::Problem->visible_states() ] }; - my @extra_cols = (); if ($c->stash->{ward}) { $where->{areas} = { 'like', '%' . $c->stash->{ward}->{id} . '%' }; # FIXME Check this is secure - push @extra_cols, 'title', 'detail'; } elsif ($c->stash->{council}) { $where->{areas} = { 'like', '%' . $c->stash->{council}->{id} . '%' }; - push @extra_cols, 'title', 'detail'; } my $problems = $c->cobrand->problems->search( $where, { columns => [ - 'id', 'council', 'state', 'areas', + 'id', 'council', 'state', 'areas', 'latitude', 'longitude', 'title', { duration => { extract => "epoch from current_timestamp-lastupdate" } }, { age => { extract => "epoch from current_timestamp-confirmed" } }, - @extra_cols, ], - order_by => { -desc => 'id' }, + order_by => { -desc => 'lastupdate' }, + rows => 100, } - ); + )->page( $page ); + $c->stash->{pager} = $problems->pager; $problems = $problems->cursor; # Raw DB cursor for speed - my ( %fixed, %open ); + my ( %fixed, %open, @pins ); my $re_councils = join('|', keys %{$c->stash->{areas_info}}); - my @cols = ( 'id', 'council', 'state', 'areas', 'duration', 'age', 'title', 'detail' ); + my @cols = ( 'id', 'council', 'state', 'areas', 'latitude', 'longitude', 'title', 'duration', 'age' ); while ( my @problem = $problems->next ) { my %problem = zip @cols, @problem; if ( !$problem{council} ) { # Problem was not sent to any council, add to possible councils $problem{councils} = 0; while ($problem{areas} =~ /,($re_councils)(?=,)/g) { - add_row( \%problem, $1, \%fixed, \%open ); + add_row( \%problem, $1, \%fixed, \%open, \@pins ); } } else { # Add to councils it was sent to @@ -301,13 +327,16 @@ sub load_and_group_problems : Private { $problem{councils} = scalar @council; foreach ( @council ) { next if $c->stash->{council} && $_ != $c->stash->{council}->{id}; - add_row( \%problem, $_, \%fixed, \%open ); + add_row( \%problem, $_, \%fixed, \%open, \@pins ); } } } - $c->stash->{fixed} = \%fixed; - $c->stash->{open} = \%open; + $c->stash( + fixed => \%fixed, + open => \%open, + pins => \@pins, + ); return 1; } @@ -348,7 +377,7 @@ sub redirect_area : Private { my $fourweeks = 4*7*24*60*60; sub add_row { - my ( $problem, $council, $fixed, $open ) = @_; + my ( $problem, $council, $fixed, $open, $pins ) = @_; my $duration_str = ( $problem->{duration} > 2 * $fourweeks ) ? 'old' : 'new'; my $type = ( $problem->{duration} > 2 * $fourweeks ) ? 'unknown' @@ -359,6 +388,14 @@ sub add_row { # Open problems are either unknown, older, or new push @{$open->{$council}{$type}}, $problem if exists FixMyStreet::DB::Result::Problem->open_states->{$problem->{state}}; + + push @$pins, { + latitude => $problem->{latitude}, + longitude => $problem->{longitude}, + colour => $problem->{state} eq 'fixed' ? 'green' : 'red', + id => $problem->{id}, + title => $problem->{title}, + }; } =head1 AUTHOR diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm index c9c9f3ab7..1fef0f07e 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -154,7 +154,7 @@ sub confirm_update : Path('/C') { return 1; } -sub load_questionnaire_id : Private { +sub load_questionnaire : Private { my ( $self, $c, $token_code ) = @_; # Set up error handling @@ -164,11 +164,21 @@ sub load_questionnaire_id : Private { my $auth_token = $c->forward( 'load_auth_token', [ $token_code, 'questionnaire' ] ); $c->stash->{id} = $auth_token->data; $c->stash->{token} = $token_code; + + my $questionnaire = $c->model('DB::Questionnaire')->find( + { id => $c->stash->{id} }, + { prefetch => 'problem' } + ); + $c->detach('/questionnaire/missing_problem') unless $questionnaire; + $c->stash->{questionnaire} = $questionnaire; } sub questionnaire : Path('/Q') : Args(1) { my ( $self, $c, $token_code ) = @_; - $c->forward( 'load_questionnaire_id', [ $token_code ] ); + $c->forward( 'load_questionnaire', [ $token_code ] ); + + $c->authenticate( { email => $c->stash->{questionnaire}->problem->user->email }, 'no_password' ); + $c->set_session_cookie_expire(0); $c->forward( '/questionnaire/index'); } diff --git a/perllib/FixMyStreet/Cobrand/Barnet.pm b/perllib/FixMyStreet/Cobrand/Barnet.pm index bccd27885..9496570ea 100644 --- a/perllib/FixMyStreet/Cobrand/Barnet.pm +++ b/perllib/FixMyStreet/Cobrand/Barnet.pm @@ -63,9 +63,11 @@ sub all_councils_report { } sub disambiguate_location { - my ( $self, $s ) = @_; - $s = "ll=51.612832,-0.218169&spn=0.0563,0.09&$s"; - return $s; + return { + centre => '51.612832,-0.218169', + span => '0.0563,0.09', + bounds => [ '51.584682,-0.263169', '51.640982,-0.173169' ], + }; } sub recent_photos { diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index d8cd426ba..29061ebd8 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -303,12 +303,15 @@ sub front_stats_data { =head2 disambiguate_location -Given a STRING ($_[1]) representing a location and a QUERY, return a string that -includes any disambiguating information available +Returns disambiguating information available =cut -sub disambiguate_location { "$_[1]&gl=uk" } +sub disambiguate_location { + return { + country => 'uk', + }; +} =head2 form_elements diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm index 29d2ec867..3d855cf8e 100644 --- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm +++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm @@ -28,9 +28,10 @@ sub enter_postcode_text { # Is also adding language parameter sub disambiguate_location { - my ( $self, $s ) = @_; - $s = "hl=no&gl=no&$s"; - return $s; + return { + lang => 'no', + country => 'no', + }; } sub area_types { diff --git a/perllib/FixMyStreet/Cobrand/Southampton.pm b/perllib/FixMyStreet/Cobrand/Southampton.pm index 6b4aae742..abf6e3082 100644 --- a/perllib/FixMyStreet/Cobrand/Southampton.pm +++ b/perllib/FixMyStreet/Cobrand/Southampton.pm @@ -63,9 +63,11 @@ sub all_councils_report { } sub disambiguate_location { - my ( $self, $s ) = @_; - $s = "ll=50.913822,-1.400493&spn=0.084628,0.15701&$s"; - return $s; + return { + centre => '50.913822,-1.400493', + span => '0.084628,0.15701', + bounds => [ '50.871508,-1.478998', '50.956136,-1.321988' ], + }; } sub recent_photos { diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm index d5cc7f1d3..286a10105 100644 --- a/perllib/FixMyStreet/Geocode.pm +++ b/perllib/FixMyStreet/Geocode.pm @@ -16,21 +16,15 @@ use LWP::Simple; use Digest::MD5 qw(md5_hex); use URI::Escape; -use mySociety::Config; use mySociety::Locale; use mySociety::MaPit; use mySociety::PostcodeUtil; use mySociety::Web qw(NewURL); -BEGIN { - (my $dir = __FILE__) =~ s{/[^/]*?$}{}; - mySociety::Config::set_file("$dir/../../conf/general"); -} - -# lookup STRING QUERY +# lookup STRING CONTEXT # Given a user-inputted string, try and convert it into co-ordinates using either # MaPit if it's a postcode, or Google Maps API otherwise. Returns an array of -# data, including an error if there is one (which includes a location being in +# data, including an error if there is one (which includes a location being in # Northern Ireland). The information in the query may be used by cobranded versions # of the site to diambiguate locations. sub lookup { @@ -58,57 +52,49 @@ sub lookup { unless ($error || defined $latitude) { ($latitude, $longitude, $error) = FixMyStreet::Geocode::string($s, $c); } - return ($latitude, $longitude, $error); -} - -sub geocoded_string_coordinates { - my ( $c, $js ) = @_; - my ($latitude, $longitude, $error); - my ($accuracy) = $js =~ /"Accuracy" *: *(\d)/; - if ($accuracy < 4) { - $error = _('Sorry, that location appears to be too general; please be more specific.'); - } elsif ( $js =~ /"coordinates" *: *\[ *(.*?), *(.*?),/ ) { - $longitude = $1; - $latitude = $2; + unless ($error || defined $latitude) { + $error = _('Sorry, we could not find that location.'); } return ($latitude, $longitude, $error); } -sub results_check { - my $c = shift; - my ($error, @valid_locations); - foreach (@_) { - next unless /"address" *: *"(.*?)"/s; - my $address = $1; - next unless $c->cobrand->geocoded_string_check( $address ); - next if $address =~ /BT\d/; - push (@$error, $address); - push (@valid_locations, $_); - } - if (scalar @valid_locations == 1) { - return geocoded_string_coordinates( $c, $valid_locations[0] ); - } - $error = _('Sorry, we could not find that location.') unless $error; - return (undef, undef, $error); -} - -# string STRING QUERY -# Canonicalises, looks up on Google Maps API, and caches, a user-inputted location. -# Returns array of (LAT, LON, ERROR), where ERROR is either undef, a string, or -# an array of matches if there are more than one. The information in the query -# may be used to disambiguate the location in cobranded versions of the site. +# string STRING CONTEXT +# Canonicalises, and then passes to some external API to look stuff up. sub string { my ($s, $c) = @_; $s = lc($s); $s =~ s/[^-&\w ']/ /g; $s =~ s/\s+/ /g; $s = URI::Escape::uri_escape_utf8($s); - $s = $c->cobrand->disambiguate_location( "q=$s" ); $s =~ s/%20/+/g; - my $url = 'http://maps.google.com/maps/geo?' . $s; - my $cache_dir = mySociety::Config::get('GEO_CACHE'); + my $params = $c->cobrand->disambiguate_location(); + if ( FixMyStreet->config('BING_MAPS_API_KEY') ) { + my $lookup = FixMyStreet::Geocode::string_bing($s, $c, $params); + return ( $lookup->{latitude}, $lookup->{longitude}, $lookup->{error} ); + } + if ( FixMyStreet->config('GOOGLE_MAPS_API_KEY') ) { + my $lookup = FixMyStreet::Geocode::string_google($s, $c, $params); + return ( $lookup->{latitude}, $lookup->{longitude}, $lookup->{error} ); + } +} + +# string_google STRING CONTEXT +# Looks up on Google Maps API, and caches, a user-inputted location. +# Returns array of (LAT, LON, ERROR), where ERROR is either undef, a string, or +# an array of matches if there are more than one. The information in the query +# may be used to disambiguate the location in cobranded versions of the site. +sub string_google { + my ( $s, $c, $params ) = @_; + + my $url = 'http://maps.google.com/maps/geo?q=' . $s; + $url .= '&ll=' . $params->{centre} if $params->{centre}; + $url .= '&spn=' . $params->{span} if $params->{span}; + $url .= '&gl=' . $params->{country} if $params->{country}; + $url .= '&hl=' . $params->{lang} if $params->{lang}; + + my $cache_dir = FixMyStreet->config('GEO_CACHE') . 'google/'; my $cache_file = $cache_dir . md5_hex($url); - my ($js, $error); + my $js; if (-s $cache_file) { $js = File::Slurp::read_file($cache_file); } else { @@ -126,25 +112,86 @@ sub string { $url .= ',+UK'; } } - $url .= '&sensor=false&key=' . mySociety::Config::get('GOOGLE_MAPS_API_KEY'); + $url .= '&sensor=false&key=' . FixMyStreet->config('GOOGLE_MAPS_API_KEY'); $js = LWP::Simple::get($url); $js = encode_utf8($js) if utf8::is_utf8($js); File::Path::mkpath($cache_dir); File::Slurp::write_file($cache_file, $js) if $js && $js !~ /"code":6[12]0/; } + if (!$js) { - $error = _('Sorry, we could not parse that location. Please try again.'); - } elsif ($js !~ /"code" *: *200/) { - $error = _('Sorry, we could not find that location.'); - } elsif ($js =~ /}, *{/) { # Multiple - return results_check($c, (split /}, *{/, $js)); + return { error => _('Sorry, we could not parse that location. Please try again.') }; } elsif ($js =~ /BT\d/) { # Northern Ireland, hopefully - $error = _("We do not cover Northern Ireland, I'm afraid, as our licence doesn't include any maps for the region."); + return { error => _("We do not cover Northern Ireland, I'm afraid, as our licence doesn't include any maps for the region.") }; + } + + $js = JSON->new->utf8->allow_nonref->decode($js); + if ($js->{Status}->{code} ne '200') { + return { error => _('Sorry, we could not find that location.') }; + } + + my $results = $js->{Placemark}; + my ( $error, @valid_locations, $latitude, $longitude ); + foreach (@$results) { + next unless $_->{AddressDetails}->{Accuracy} >= 4; + my $address = $_->{address}; + next unless $c->cobrand->geocoded_string_check( $address ); + ( $longitude, $latitude ) = @{ $_->{Point}->{coordinates} }; + push (@$error, $address); + push (@valid_locations, $_); + } + return { latitude => $latitude, longitude => $longitude } if scalar @valid_locations == 1; + return { error => $error }; +} + +# string_bing STRING CONTEXT +# Looks up on Bing Maps API, and caches, a user-inputted location. +# Returns array of (LAT, LON, ERROR), where ERROR is either undef, a string, or +# an array of matches if there are more than one. The information in the query +# may be used to disambiguate the location in cobranded versions of the site. +sub string_bing { + my ( $s, $c, $params ) = @_; + my $url = "http://dev.virtualearth.net/REST/v1/Locations?q=$s&c=en-GB"; # FIXME nb-NO for Norway + $url .= '&mapView=' . $params->{bounds}[0] . ',' . $params->{bounds}[1] + if $params->{bounds}; + $url .= '&userLocation=' . $params->{centre} if $params->{centre}; + + my $cache_dir = FixMyStreet->config('GEO_CACHE') . 'bing/'; + my $cache_file = $cache_dir . md5_hex($url); + my $js; + if (-s $cache_file) { + $js = File::Slurp::read_file($cache_file); } else { - return results_check($c, $js); + $url .= '&key=' . FixMyStreet->config('BING_MAPS_API_KEY'); + $js = LWP::Simple::get($url); + $js = encode_utf8($js) if utf8::is_utf8($js); + File::Path::mkpath($cache_dir); + File::Slurp::write_file($cache_file, $js) if $js; + } + + if (!$js) { + return { error => _('Sorry, we could not parse that location. Please try again.') }; + } elsif ($js =~ /BT\d/) { + return { error => _("We do not cover Northern Ireland, I'm afraid, as our licence doesn't include any maps for the region.") }; + } + + $js = JSON->new->utf8->allow_nonref->decode($js); + if ($js->{statusCode} ne '200') { + return { error => _('Sorry, we could not find that location.') }; + } + + my $results = $js->{resourceSets}->[0]->{resources}; + my ( $error, @valid_locations, $latitude, $longitude ); + foreach (@$results) { + my $address = $_->{name}; + next unless $_->{address}->{countryRegion} eq 'United Kingdom'; # FIXME This is UK only + ( $latitude, $longitude ) = @{ $_->{point}->{coordinates} }; + push (@$error, $address); + push (@valid_locations, $_); } - return (undef, undef, $error); + return { latitude => $latitude, longitude => $longitude } if scalar @valid_locations == 1; + return { error => $error }; } sub mapit_check_error { diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm index 125aca9e6..6b5a811a6 100644 --- a/perllib/FixMyStreet/Map.pm +++ b/perllib/FixMyStreet/Map.pm @@ -68,12 +68,29 @@ sub map_features { # use deltas that are roughly 500m in the UK - so we get a 1 sq km search box my $lat_delta = 0.00438; my $lon_delta = 0.00736; + return _map_features( + $c, $lat, $lon, + $lon - $lon_delta, $lat - $lat_delta, + $lon + $lon_delta, $lat + $lat_delta, + $interval + ); +} + +sub map_features_bounds { + my ( $c, $min_lon, $min_lat, $max_lon, $max_lat, $interval ) = @_; - my $min_lat = $lat - $lat_delta; - my $max_lat = $lat + $lat_delta; + my $lat = ( $max_lat + $min_lat ) / 2; + my $lon = ( $max_lon + $min_lon ) / 2; + return _map_features( + $c, $lat, $lon, + $min_lon, $min_lat, + $max_lon, $max_lat, + $interval + ); +} - my $min_lon = $lon - $lon_delta; - my $max_lon = $lon + $lon_delta; +sub _map_features { + my ( $c, $lat, $lon, $min_lon, $min_lat, $max_lon, $max_lat, $interval ) = @_; # list of problems around map can be limited, but should show all pins my $around_limit = $c->cobrand->on_map_list_limit || undef; diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm index 9b968b4f6..05dc6ad39 100644 --- a/perllib/FixMyStreet/Map/OSM.pm +++ b/perllib/FixMyStreet/Map/OSM.pm @@ -95,6 +95,32 @@ sub display_map { }; } +sub map_pins { + my ($self, $c, $interval) = @_; + + my $bbox = $c->req->param('bbox'); + my ( $min_lon, $min_lat, $max_lon, $max_lat ) = split /,/, $bbox; + + my ( $around_map, $around_map_list, $nearby, $dist ) = + FixMyStreet::Map::map_features_bounds( $c, $min_lon, $min_lat, $max_lon, $max_lat, $interval ); + + # create a list of all the pins + my @pins = map { + # Here we might have a DB::Problem or a DB::Nearby, we always want the problem. + my $p = (ref $_ eq 'FixMyStreet::App::Model::DB::Nearby') ? $_->problem : $_; + #{ + # latitude => $p->latitude, + # longitude => $p->longitude, + # colour => $p->state eq 'fixed' ? 'green' : 'red', + # id => $p->id, + # title => $p->title, + #} + [ $p->latitude, $p->longitude, $p->state eq 'fixed' ? 'green' : 'red', $p->id, $p->title ] + } @$around_map, @$nearby; + + return (\@pins, $around_map_list, $nearby, $dist); +} + sub compass { my ( $x, $y, $z ) = @_; return { diff --git a/perllib/FixMyStreet/Map/Tilma/Original.pm b/perllib/FixMyStreet/Map/Tilma/Original.pm index 8fd835265..46cf3ad40 100644 --- a/perllib/FixMyStreet/Map/Tilma/Original.pm +++ b/perllib/FixMyStreet/Map/Tilma/Original.pm @@ -96,7 +96,15 @@ sub display_pin { } sub map_pins { - my ($self, $c, $x, $y, $sx, $sy, $interval) = @_; + my ($self, $c, $interval) = @_; + + # Our current X/Y middle of visible map + my $x = ( $c->req->param('x') || 0 ) + 0; + my $y = ( $c->req->param('y') || 0 ) + 0; + + # Where we started as that's the (0,0) we have to work to + my $sx = ( $c->req->param('sx') || 0 ) + 0; + my $sy = ( $c->req->param('sy') || 0 ) + 0; my $e = tile_to_os($x); my $n = tile_to_os($y); diff --git a/t/00-check-we-are-staging.t b/t/00-check-we-are-staging.t new file mode 100644 index 000000000..a1da68798 --- /dev/null +++ b/t/00-check-we-are-staging.t @@ -0,0 +1,24 @@ +use strict; +use warnings; + +use Test::More; + +use FixMyStreet; + +# check that all the fields listed in general-example are also present in +# general - helps prevent later test failures due to un-noticed additions to the +# config file. + +# This code will bail_out to prevent the test suite proceeding to save time if +# issues are found. + +# load the config file and store the contents in a readonly hash + +mySociety::Config::set_file( FixMyStreet->path_to("conf/general") ); + +BAIL_OUT( "Test suite modifies databases so should not be run on live servers" ) + unless mySociety::Config::get('STAGING_SITE', undef); + +ok mySociety::Config::get('STAGING_SITE', undef), 'staging server'; + +done_testing(); diff --git a/t/app/controller/around.t b/t/app/controller/around.t index ba0dfe1b4..0060e957c 100644 --- a/t/app/controller/around.t +++ b/t/app/controller/around.t @@ -41,21 +41,6 @@ foreach my $test ( pc_alternatives => [], }, { - pc => 'glenthorpe', - errors => [], - pc_alternatives => [ - 'Glenthorpe Crescent, Leeds LS9 7', - 'Glenthorpe Rd, Merton, Greater London SM4 4', - 'Glenthorpe Ave, Leeds LS9 7', - 'Glenthorne Rd, Hammersmith, Greater London W6 0', - 'Glenthorne Ave, Yeovil, Somerset BA21 4', - 'Glenthorne Rd, Kenwyn, Cornwall TR3 6', - 'Glenthorne Dr, Cheslyn Hay, Staffordshire WS6 7', - 'Glenthorne Gardens, Ilford, Greater London IG5 0', - 'Glenthorne Ave, Croydon, Greater London CR0 7', - ], - }, - { pc => 'Glenthorpe Ct, Katy, TX 77494, USA', errors => ['Sorry, we could not find that location.'], @@ -81,16 +66,6 @@ foreach my $test ( latitude => '51.50101', longitude => '-0.141587', }, - { - pc => 'Manchester', - latitude => '53.480713', - longitude => '-2.234376', - }, - { - pc => 'Glenthorpe Rd, Merton, Greater London SM4 4, UK', - latitude => '51.3938', - longitude => '-0.22096', - }, ) { subtest "check lat/lng for '$test->{pc}'" => sub { diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t index 1a16457f9..fef45ac90 100644 --- a/t/app/controller/auth.t +++ b/t/app/controller/auth.t @@ -197,12 +197,10 @@ foreach my $remember_me ( '1', '0' ) { ); is $mech->uri->path, '/my', "redirected to correct page"; - # check that the cookie has no expiry set my $expiry = $mech->session_cookie_expiry; - is( $expiry, 0, "no expiry time" ); - #$remember_me - # ? cmp_ok( $expiry, '>', 86400, "long expiry time" ) - # : is( $expiry, 0, "no expiry time" ); + $remember_me + ? cmp_ok( $expiry, '>', 86400, "long expiry time" ) + : is( $expiry, 0, "no expiry time" ); # logout $mech->log_out_ok; diff --git a/templates/web/default/around/display_location.html b/templates/web/default/around/display_location.html index aa1dc86d6..529c12eec 100755 --- a/templates/web/default/around/display_location.html +++ b/templates/web/default/around/display_location.html @@ -61,10 +61,6 @@ [% END %] </p> -[% IF c.cobrand.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/auth/general.html b/templates/web/default/auth/general.html index ffc85b3dc..5f9a09199 100644 --- a/templates/web/default/auth/general.html +++ b/templates/web/default/auth/general.html @@ -39,7 +39,7 @@ </p> <p> - <input type="checkbox" name="remember_me" value='1'[% ' checked' IF remember_me %]> + <input type="checkbox" id="remember_me" name="remember_me" value='1'[% ' checked' IF remember_me %]> <label class="n" for="remember_me"> [% loc('Keep me signed in on this computer') %] </label> diff --git a/templates/web/default/maps/openlayers.html b/templates/web/default/maps/openlayers.html index 7da732913..45551c3d5 100644 --- a/templates/web/default/maps/openlayers.html +++ b/templates/web/default/maps/openlayers.html @@ -7,8 +7,14 @@ <input type="hidden" name="zoom" value="[% map.zoom %]"> <script type="text/javascript"> var fixmystreet = { + 'page': '[% page %]', + 'area': '[% map.area %]', + 'all_pins': [% all_pins || "''" | html %], 'latitude': [% map.latitude %], 'longitude': [% map.longitude %], +[% IF map.any_zoom -%] + 'zoomToBounds': 1, +[%- END %] [% IF map.zoom -%] 'zoom': [% map.zoom %], [%- END %] diff --git a/templates/web/default/maps/tilma/original.html b/templates/web/default/maps/tilma/original.html index e02a974f8..5a07683ac 100644 --- a/templates/web/default/maps/tilma/original.html +++ b/templates/web/default/maps/tilma/original.html @@ -22,6 +22,7 @@ <script type="text/javascript"> [% c.cobrand.root_path_js %] var fixmystreet = { + 'all_pins': [% all_pins || "''" | html %], 'x': [% map.x - 3 %], 'y': [% map.y - 3 %], 'start_x': [% map.px %], diff --git a/templates/web/default/report/display.html b/templates/web/default/report/display.html index 92ca7ff34..a9ce12dd4 100644 --- a/templates/web/default/report/display.html +++ b/templates/web/default/report/display.html @@ -156,7 +156,7 @@ </p> <p> - <input type="checkbox" name="remember_me" value='1'[% ' checked' IF remember_me %]> + <input type="checkbox" id="remember_me" name="remember_me" value='1'[% ' checked' IF remember_me %]> <label class="n" for="remember_me"> [% loc('Keep me signed in on this computer') %] </label> diff --git a/templates/web/default/report/new/fill_in_details.html b/templates/web/default/report/new/fill_in_details.html index 68443770d..32d4a733b 100644 --- a/templates/web/default/report/new/fill_in_details.html +++ b/templates/web/default/report/new/fill_in_details.html @@ -159,7 +159,7 @@ </p> <p> - <input type="checkbox" name="remember_me" value='1'[% ' checked' IF remember_me %]> + <input type="checkbox" id="remember_me" name="remember_me" value='1'[% ' checked' IF remember_me %]> <label class="n" for="remember_me"> [% loc('Keep me signed in on this computer') %] </label> diff --git a/templates/web/default/reports/council.html b/templates/web/default/reports/council.html index 1c35481e7..d2578f9f2 100755 --- a/templates/web/default/reports/council.html +++ b/templates/web/default/reports/council.html @@ -8,12 +8,29 @@ %] [% END %] -[% INCLUDE 'header.html', +[% + PROCESS "maps/${map.type}.html"; + INCLUDE 'header.html', title = tprintf(loc('%s - Summary reports'), name) context = 'reports' rss = [ tprintf(loc('Problems within %s, FixMyStreet'), name), rss_url ] %] +[% map_html %] + +[% IF children %] +<h2 style="clear:right">[% loc('Wards of this council') %]</h2> +<p>[% loc('Follow a ward link to view only reports within that ward.') %]</p> +<ul> +[% FOR c IN children.values.sort('name') %] +<li><a href="[% c.url %]">[% c.name %]</a></p> +[% END %] +</ul> +[% END %] + +</div> +<div id="side"> + <p><a href="[% rss_url %]"><img align="right" src="/i/feed.png" width="16" height="16" title="[% loc('RSS feed') %]" alt="[% tprintf(loc('RSS feed of problems in this %s'), thing) %]" border="0" hspace="4"></a> [% IF c.cobrand.all_councils_report %] @@ -22,24 +39,21 @@ [% tprintf( loc('This is a summary of all reports for this %s.'), thing ) %] [% END %] -[%# FIXME: It should link to council from a ward page, and should have list of wards on a council page. And a map? - The reason c.req.base/path is used below is that passing undef to uri_with - in a template actually passes "", and so the key still appears in the URL. -%] - -[% IF c.req.parameters.all AND !c.cobrand.all_councils_report %] - [% tprintf( loc('You can <a href="%s">see less detail</a>.'), c.req.base _ c.req.path ) %] -[% ELSIF !c.cobrand.all_councils_report %] - [% tprintf( loc('You can <a href="%s">see more details</a>.'), c.req.uri_with( { all = 1 } ) ) %] -[% ELSIF c.req.parameters.all %] - [% tprintf( loc('You can <a href="%s">see less detail</a> or go back and <a href="/reports">show all councils</a>.'), c.req.base _ c.req.path ) %] +[% IF ward %] +[% tprintf( loc('You can <a href="%s">view all reports for the council</a> or <a href="/reports">show all councils</a>.'), council_url ) %] [% ELSE %] - [% tprintf( loc('You can <a href="%s">see more details</a> or go back and <a href="/reports">show all councils</a>.'), c.req.uri_with( { all = 1 } ) ) %] +[% loc('You can <a href="/reports">show all councils</a>.') %] [% END %] <h2>[% name %]</h2> -<div id="col_problems"> + [% INCLUDE 'pagination' %] + + [% INCLUDE column + title = loc('Recently fixed') + problems = fixed.${council.id}.new + %] + [% INCLUDE column title = loc('New problems') problems = open.${council.id}.new @@ -62,19 +76,13 @@ problems = open.${council.id}.unknown %] [% END %] -</div> -<div id="col_fixed"> - [% INCLUDE column - title = loc('Recently fixed') - problems = fixed.${council.id}.new - %] [% INCLUDE column title = loc('Old fixed') problems = fixed.${council.id}.old %] -</div> +</div> [% INCLUDE 'footer.html' %] [% BLOCK column %] @@ -89,7 +97,6 @@ [% IF c.cobrand.moniker != 'emptyhomes' %] [% IF problem.councils == 0 %] <small>[% loc('(not sent to council)') %]</small> [% END %] [% END %] - [% IF all %] <br><small>[% problem.detail %]</small> [% END %] </li> [% END %] </ul> @@ -97,3 +104,23 @@ [% END %] [% END %] +[% BLOCK pagination %] + [% IF pager.last_page > 1 %] + <p> + [% IF pager.previous_page %] + <a href="[% c.req.uri_with({'p' => pager.previous_page}) %]">← Previous</a> + [% ELSE %] + ← Previous + [% END %] + | + [% pager.first %] to [% pager.last %] of [% pager.total_entries %] + | + [% IF pager.next_page %] + <a href="[% c.req.uri_with({'p' => pager.next_page}) %]">Next →</a> + [% ELSE %] + Next → + [% END %] + </p> + [% END %] +[% END %] + diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 83e535f1c..821bbafc3 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -41,33 +41,87 @@ YAHOO.util.Event.onContentReady('map', function() { return false; }); - fixmystreet.markers = new OpenLayers.Layer.Markers("Markers"); - var cols = { 'red':'R', 'green':'G', 'blue':'B', 'purple':'P' }; - for (var i=0; i<fixmystreet.pins.length; i++) { - var pin = fixmystreet.pins[i]; - var src = '/i/pin' + cols[pin[2]] + '.gif'; - var size = new OpenLayers.Size(32, 59); - var offset = new OpenLayers.Pixel(-3, -size.h-2); - var icon = new OpenLayers.Icon(src, size, offset); - var loc = new OpenLayers.LonLat(pin[1], pin[0]); - loc.transform( - new OpenLayers.Projection("EPSG:4326"), - fixmystreet.map.getProjectionObject() - ); - var marker = new OpenLayers.Marker(loc, icon); - if (pin[3]) { - marker.id = pin[3]; - marker.events.register('click', marker, function(evt) { - window.location = '/report/' + this.id; - OpenLayers.Event.stop(evt); - }); - } - fixmystreet.markers.addMarker(marker); + if ( fixmystreet.area ) { + var area = new OpenLayers.Layer.Vector("KML", { + strategies: [ new OpenLayers.Strategy.Fixed() ], + protocol: new OpenLayers.Protocol.HTTP({ + url: "/mapit/area/" + fixmystreet.area + ".kml", + format: new OpenLayers.Format.KML() + }) + }); + fixmystreet.map.addLayer(area); + area.events.register('loadend', null, function(a,b,c) { + var bounds = area.getDataExtent(); + if (bounds) { fixmystreet.map.zoomToExtent( bounds ); } + }); + } + + var pin_layer_options = { + styleMap: new OpenLayers.StyleMap({ + 'default': new OpenLayers.Style({ + externalGraphic: "/i/pin${type}.gif", + graphicTitle: "${title}", + graphicWidth: 32, + graphicHeight: 59, + graphicOpacity: 1, + graphicXOffset: -1, + graphicYOffset: -59 + }) + }) + }; + if (fixmystreet.page == 'around') { + pin_layer_options.strategies = [ new OpenLayers.Strategy.BBOX() ]; + pin_layer_options.protocol = new OpenLayers.Protocol.HTTP({ + url: '/ajax', + params: fixmystreet.all_pins ? { all_pins: 1, map: 'FMS' } : { map: 'FMS' }, + format: new OpenLayers.Format.FixMyStreet() + }); + } + fixmystreet.markers = new OpenLayers.Layer.Vector("Pins", pin_layer_options); + + var markers = fms_markers_list( fixmystreet.pins, true ); + fixmystreet.markers.addFeatures( markers ); + if (fixmystreet.page == 'around') { + fixmystreet.markers.events.register( 'featureselected', fixmystreet.markers, function(evt) { + window.location = '/report/' + evt.feature.attributes.id; + OpenLayers.Event.stop(evt); + }); + var select = new OpenLayers.Control.SelectFeature( fixmystreet.markers ); + fixmystreet.map.addControl( select ); + select.activate(); } fixmystreet.map.addLayer(fixmystreet.markers); + if ( fixmystreet.zoomToBounds ) { + var bounds = fixmystreet.markers.getDataExtent(); + if (bounds) { fixmystreet.map.zoomToExtent( bounds ); } + } + }); +function fms_markers_list(pins, transform) { + var cols = { 'red':'R', 'green':'G', 'blue':'B', 'purple':'P' }; + var markers = []; + for (var i=0; i<pins.length; i++) { + var pin = pins[i]; + var loc = new OpenLayers.Geometry.Point(pin[1], pin[0]); + if (transform) { + // The Strategy does this for us, so don't do it in that case. + loc.transform( + new OpenLayers.Projection("EPSG:4326"), + fixmystreet.map.getProjectionObject() + ); + } + var marker = new OpenLayers.Feature.Vector(loc, { + type: cols[pin[2]], + id: pin[3], + title: pin[4] + }); + markers.push( marker ); + } + return markers; +} + YAHOO.util.Event.addListener('hide_pins_link', 'click', function(e) { YAHOO.util.Event.preventDefault(e); var showhide = [ @@ -86,6 +140,35 @@ YAHOO.util.Event.addListener('hide_pins_link', 'click', function(e) { } }); +YAHOO.util.Event.addListener('all_pins_link', 'click', function(e) { + YAHOO.util.Event.preventDefault(e); + fixmystreet.markers.setVisibility(true); + var welsh = 0; + var texts = [ + 'en', 'Include stale reports', 'Hide stale reports', + 'cy', 'Cynnwys hen adroddiadau', 'Cuddio hen adroddiadau' + ]; + for (var i=0; i<texts.length; i+=3) { + if (this.innerHTML == texts[i+1]) { + this.innerHTML = texts[i+2]; + fixmystreet.markers.protocol.options.params = { all_pins: 1, map: 'FMS' }; + fixmystreet.markers.refresh( { force: true } ); + lang = texts[i]; + } else if (this.innerHTML == texts[i+2]) { + this.innerHTML = texts[i+1]; + fixmystreet.markers.protocol.options.params = { map: 'FMS' }; + fixmystreet.markers.refresh( { force: true } ); + lang = texts[i]; + } + } + if (lang == 'cy') { + document.getElementById('hide_pins_link').innerHTML = 'Cuddio pinnau'; + } else { + document.getElementById('hide_pins_link').innerHTML = 'Hide pins'; + } +}); + + /* Overridding the buttonDown function of PanZoom so that it does zoomTo(0) rather than zoomToMaxExtent() */ @@ -142,6 +225,24 @@ OpenLayers.Control.PermalinkFMS = OpenLayers.Class(OpenLayers.Control.Permalink, } }); +/* Pan data handler */ +OpenLayers.Format.FixMyStreet = OpenLayers.Class(OpenLayers.Format.JSON, { + read: function(json, filter) { + if (typeof json == 'string') { + obj = OpenLayers.Format.JSON.prototype.read.apply(this, [json, filter]); + } else { + obj = json; + } + if (typeof(obj.current) != 'undefined') + document.getElementById('current').innerHTML = obj.current; + if (typeof(obj.current_near) != 'undefined') + document.getElementById('current_near').innerHTML = obj.current_near; + var markers = fms_markers_list( obj.pins, false ); + return markers; + }, + CLASS_NAME: "OpenLayers.Format.FixMyStreet" +}); + /* Click handler */ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { defaultHandlerOptions: { diff --git a/web/js/map-tilma.js b/web/js/map-tilma.js index 3c5f546e5..a6e4fa082 100644 --- a/web/js/map-tilma.js +++ b/web/js/map-tilma.js @@ -60,21 +60,21 @@ YAHOO.util.Event.addListener('all_pins_link', 'click', function(e) { var welsh = 0; if (this.innerHTML == 'Include stale reports') { this.innerHTML = 'Hide stale reports'; - document.getElementById('all_pins').value = '1'; + fixmystreet.all_pins = 1; load_pins(fixmystreet.x, fixmystreet.y); } else if (this.innerHTML == 'Cynnwys hen adroddiadau') { this.innerHTML = 'Cuddio hen adroddiadau'; - document.getElementById('all_pins').value = '1'; + fixmystreet.all_pins = 1; welsh = 1; 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 = ''; + fixmystreet.all_pins = ''; load_pins(fixmystreet.x, fixmystreet.y); } else if (this.innerHTML == 'Hide stale reports') { this.innerHTML = 'Include stale reports'; - document.getElementById('all_pins').value = ''; + fixmystreet.all_pins = ''; load_pins(fixmystreet.x, fixmystreet.y); } if (welsh) { @@ -136,15 +136,11 @@ function update_tiles(dx, dy, force) { function load_pins(x, y) { if (document.getElementById('formX') && !document.getElementById('problem_submit')) { - all_pins = ''; - if (document.getElementById('all_pins')) { - all_pins = document.getElementById('all_pins').value; - } var ajax_params = [ 'sx=' + document.getElementById('formX').value, 'sy=' + document.getElementById('formY').value, 'x=' + (x+3), 'y=' + (y+3), - 'all_pins=' + all_pins ]; + 'all_pins=' + fixmystreet.all_pins ]; var url = [ root_path , '/ajax?', ajax_params.join(';')].join(''); YAHOO.util.Connect.asyncRequest('GET', url, { |