diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/Cobrands/Barnet/Util.pm | 4 | ||||
-rw-r--r-- | perllib/Cobrands/Fiksgatami/Util.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/Alert.pm | 15 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/OSM.pm | 2 | ||||
-rw-r--r-- | perllib/Page.pm | 12 | ||||
-rw-r--r-- | perllib/Problems.pm | 3 |
7 files changed, 25 insertions, 20 deletions
diff --git a/perllib/Cobrands/Barnet/Util.pm b/perllib/Cobrands/Barnet/Util.pm index eb8b91649..0e5ddcf68 100644 --- a/perllib/Cobrands/Barnet/Util.pm +++ b/perllib/Cobrands/Barnet/Util.pm @@ -54,7 +54,7 @@ sub site_title { sub enter_postcode_text { my ($self,$q) = @_; - return 'Enter a Barnet postcode, or street name and area:'; + return 'Enter a Barnet postcode, or street name and area'; } =item council_check COUNCILS QUERY CONTEXT @@ -79,7 +79,7 @@ sub council_check { } my $url = 'http://www.fixmystreet.com/'; $url .= 'alert' if $context eq 'alert'; - $url .= '?pc=' . URI::Escape::uri_escape($q->param('pc')) if $q->param('pc'); + $url .= '?pc=' . URI::Escape::uri_escape_utf8($q->param('pc')) if $q->param('pc'); my $error_msg = "That location is not covered by Barnet. Please visit <a href=\"$url\">the main FixMyStreet site</a>."; return (0, $error_msg); diff --git a/perllib/Cobrands/Fiksgatami/Util.pm b/perllib/Cobrands/Fiksgatami/Util.pm index 9fb448be5..38366f0e1 100644 --- a/perllib/Cobrands/Fiksgatami/Util.pm +++ b/perllib/Cobrands/Fiksgatami/Util.pm @@ -24,7 +24,7 @@ sub set_lang_and_domain { sub enter_postcode_text { my ($self, $q) = @_; - return _('Enter a nearby postcode, or street name and area:'); + return _('Enter a nearby postcode, or street name and area'); } # Is also adding language parameter @@ -34,6 +34,12 @@ sub disambiguate_location { return $s; } +sub geocoded_string_check { + my ($self, $s) = @_; + return 1 if $s =~ /, Norge/; + return 0; +} + sub area_types { return ( 'NKO', 'NFY' ); } diff --git a/perllib/FixMyStreet/Alert.pm b/perllib/FixMyStreet/Alert.pm index 6b50e62e6..29932a0a5 100644 --- a/perllib/FixMyStreet/Alert.pm +++ b/perllib/FixMyStreet/Alert.pm @@ -253,12 +253,10 @@ sub generate_rss ($$$;$$$$) { throw FixMyStreet::Alert::Error('Unknown alert type') unless $alert_type; # Do our own encoding - my $rss = new XML::RSS( version => '2.0', encoding => 'UTF-8', stylesheet=> $xsl, encode_output => undef ); $rss->add_module(prefix=>'georss', uri=>'http://www.georss.org/georss'); - # XXX: Not generic # Only apply a site restriction if the alert uses the problem table $site_restriction = '' unless $alert_type->{item_table} eq 'problem'; my $query = 'select * from ' . $alert_type->{item_table} . ' where ' @@ -274,19 +272,19 @@ sub generate_rss ($$$;$$$$) { $q->execute(); } - my @months = ('', 'January','February','March','April','May','June', - 'July','August','September','October','November','December'); while (my $row = $q->fetchrow_hashref) { - # XXX: How to do this properly? name might be null in comment table, hence needing this - my $pubDate; + $row->{name} ||= 'anonymous'; - # And we want pretty dates... :-/ + + my $pubDate; if ($row->{confirmed}) { $row->{confirmed} =~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/; $pubDate = mySociety::Locale::in_gb_locale { strftime("%a, %d %b %Y %H:%M:%S %z", $6, $5, $4, $3, $2-1, $1-1900, -1, -1, 0) }; - $row->{confirmed} = ordinal($3+0) . ' ' . $months[$2]; + $row->{confirmed} = strftime("%e %B", $6, $5, $4, $3, $2-1, $1-1900, -1, -1, 0); + $row->{confirmed} =~ s/^\s+//; + $row->{confirmed} =~ s/^(\d+)/ordinal($1)/e if $mySociety::Locale::lang eq 'en-gb'; } (my $title = _($alert_type->{item_title})) =~ s/{{(.*?)}}/$row->{$1}/g; @@ -301,7 +299,6 @@ sub generate_rss ($$$;$$$$) { ); $item{pubDate} = $pubDate if $pubDate; - # XXX: Not-very-generic extensions, at all my $display_photos = Cobrand::allow_photo_display($cobrand); if ($display_photos && $row->{photo}) { $item{description} .= ent("\n<br><img src=\"". Cobrand::url($cobrand, $url, $http_q) . "/photo?id=$row->{id}\">"); diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm index 17a4d8539..803e32a85 100644 --- a/perllib/FixMyStreet/Geocode.pm +++ b/perllib/FixMyStreet/Geocode.pm @@ -106,6 +106,7 @@ sub string { || mySociety::Config::get('COUNTRY') ne 'GB'; $url .= '&sensor=false&key=' . mySociety::Config::get('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/; } diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm index 820a4ce63..7953d16e2 100644 --- a/perllib/FixMyStreet/Map/OSM.pm +++ b/perllib/FixMyStreet/Map/OSM.pm @@ -13,7 +13,7 @@ use mySociety::Web qw(ent); sub header_js { return ' -<script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script> +<script type="text/javascript" src="/jslib/OpenLayers-2.10/OpenLayers.js"></script> <script type="text/javascript" src="/js/map-OpenStreetMap.js"></script> '; } diff --git a/perllib/Page.pm b/perllib/Page.pm index 279c5a79a..2ce44f410 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -56,7 +56,7 @@ sub do_fastcgi { try { my $W = new mySociety::WatchUpdate(); - while (my $q = new mySociety::Web()) { + while (my $q = new mySociety::Web(unicode => 1)) { next if $lm && $q->Maybe304($lm); $lastmodified = $lm; microsite($q); @@ -305,7 +305,7 @@ sub footer { my ($q, %params) = @_; my $pc = $q->param('pc') || ''; - $pc = '?pc=' . URI::Escape::uri_escape($pc) if $pc; + $pc = '?pc=' . URI::Escape::uri_escape_utf8($pc) if $pc; my $creditline = _('Built by <a href="http://www.mysociety.org/">mySociety</a>, using some <a href="http://github.com/mysociety/fixmystreet">clever</a> <a href="https://secure.mysociety.org/cvstrac/dir?d=mysociety/services/TilMa">code</a>.'); if (mySociety::Config::get('COUNTRY') eq 'NO') { @@ -483,13 +483,13 @@ sub prettify_epoch { if (strftime('%Y%m%d', @s) eq strftime('%Y%m%d', @t)) { $tt = "$tt " . _('today'); } elsif (strftime('%Y %U', @s) eq strftime('%Y %U', @t)) { - $tt = "$tt, " . strftime('%A', @s); + $tt = "$tt, " . decode_utf8(strftime('%A', @s)); } elsif ($short) { - $tt = "$tt, " . strftime('%e %b %Y', @s); + $tt = "$tt, " . decode_utf8(strftime('%e %b %Y', @s)); } elsif (strftime('%Y', @s) eq strftime('%Y', @t)) { - $tt = "$tt, " . strftime('%A %e %B %Y', @s); + $tt = "$tt, " . decode_utf8(strftime('%A %e %B %Y', @s)); } else { - $tt = "$tt, " . strftime('%a %e %B %Y', @s); + $tt = "$tt, " . decode_utf8(strftime('%a %e %B %Y', @s)); } return $tt; } diff --git a/perllib/Problems.pm b/perllib/Problems.pm index 74ac34f75..111583fd5 100644 --- a/perllib/Problems.pm +++ b/perllib/Problems.pm @@ -101,7 +101,8 @@ sub recent_photos { my ($num, $lat, $lon, $dist) = @_; my $probs; if (defined $lat) { - my $key = "recent_photos:$site_key:$num:$lat:$lon:$dist"; + my $dist2 = $dist; # Create a copy of the variable to stop it being stringified into a locale in the next line! + my $key = "recent_photos:$site_key:$num:$lat:$lon:$dist2"; $probs = Memcached::get($key); unless ($probs) { $probs = mySociety::Locale::in_gb_locale { |