aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-12-09 12:40:06 +0000
committerMatthew Somerville <matthew@mysociety.org>2015-12-09 14:16:22 +0000
commitafad42bf0227966dedfdbd7272e8cf7fc5e53cc0 (patch)
treec38a876558adb2a526ad5bac0a7771b2a4b77d7e
parentb064b041675c907a5646487985825f078208f4d4 (diff)
Switch template plugin for nice numbers.
Template::Plugin::Number::Format works internationally, whilst Template::Plugin::Comma does not.
-rw-r--r--cpanfile2
-rw-r--r--cpanfile.snapshot16
-rw-r--r--t/app/01app.t19
-rw-r--r--templates/web/base/front/stats.html17
-rw-r--r--templates/web/emptyhomes/front/stats.html3
5 files changed, 40 insertions, 17 deletions
diff --git a/cpanfile b/cpanfile
index 25c63c736..eae53fcb1 100644
--- a/cpanfile
+++ b/cpanfile
@@ -80,7 +80,7 @@ requires 'Regexp::Common';
requires 'Scalar::Util';
requires 'Statistics::Distributions';
requires 'Storable';
-requires 'Template::Plugin::Comma';
+requires 'Template::Plugin::Number::Format';
requires 'Text::CSV';
requires 'URI';
requires 'URI::Escape';
diff --git a/cpanfile.snapshot b/cpanfile.snapshot
index b1afdc867..7bf4bc0a7 100644
--- a/cpanfile.snapshot
+++ b/cpanfile.snapshot
@@ -4382,6 +4382,14 @@ DISTRIBUTIONS
requirements:
ExtUtils::MakeMaker 0
Test::More 0
+ Number-Format-1.75
+ pathname: W/WR/WRW/Number-Format-1.75.tar.gz
+ provides:
+ Number::Format 1.75
+ requirements:
+ Carp 0
+ ExtUtils::MakeMaker 0
+ POSIX 0
Number-Tolerant-1.703
pathname: R/RJ/RJBS/Number-Tolerant-1.703.tar.gz
provides:
@@ -5172,14 +5180,14 @@ DISTRIBUTIONS
Scalar::Util 1.14
Test::More 0.42
perl 5.005
- Template-Plugin-Comma-0.04
- pathname: M/MI/MIYAGAWA/Template-Plugin-Comma-0.04.tar.gz
+ Template-Plugin-Number-Format-1.06
+ pathname: D/DA/DARREN/Template-Plugin-Number-Format-1.06.tar.gz
provides:
- Template::Plugin::Comma 0.04
+ Template::Plugin::Number::Format 1.06
requirements:
ExtUtils::MakeMaker 0
+ Number::Format 0
Template 2.07
- Test::More 0.32
Template-Timer-1.00
pathname: P/PE/PETDANCE/Template-Timer-1.00.tar.gz
provides:
diff --git a/t/app/01app.t b/t/app/01app.t
index 02ffcd217..eb98b6319 100644
--- a/t/app/01app.t
+++ b/t/app/01app.t
@@ -1,10 +1,27 @@
#!/usr/bin/env perl
+
use strict;
use warnings;
-use Test::More;
+package FixMyStreet::Cobrand::Tester;
+use parent 'FixMyStreet::Cobrand::FiksGataMi';
+sub front_stats_data { { new => 0, fixed => 0, updates => 12345 } }
+
+package main;
+
+use Test::More;
use Catalyst::Test 'FixMyStreet::App';
+use charnames ':full';
+use Encode qw(encode);
ok( request('/')->is_success, 'Request should succeed' );
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'tester' ],
+}, sub {
+ my $page = get('/');
+ my $num = encode('UTF-8', "12\N{NO-BREAK SPACE}345");
+ like $page, qr/$num/;
+};
+
done_testing();
diff --git a/templates/web/base/front/stats.html b/templates/web/base/front/stats.html
index 5367f1118..eb671137b 100644
--- a/templates/web/base/front/stats.html
+++ b/templates/web/base/front/stats.html
@@ -1,8 +1,4 @@
-[%
- USE Comma;
- # Note - if we want to i18n the commas we should try
- # 'Template::Plugin::Number::Format'
-%]
+[% USE Number.Format %]
[%
stats = c.cobrand.front_stats_data();
@@ -31,13 +27,16 @@
"<big>%s</big> updates on reports",
stats.updates
);
-
+
+ new_n = stats.new | format_number;
+ fixed_n = stats.fixed | format_number;
+ updates_n = stats.updates | format_number;
%]
<div id="front_stats">
- <div>[% tprintf( new_text, stats.new ) | comma %]</div>
- <div>[% tprintf( fixed_text, stats.fixed ) | comma %]</div>
+ <div>[% tprintf( new_text, decode(new_n) ) %]</div>
+ <div>[% tprintf( fixed_text, decode(fixed_n) ) %]</div>
[% IF c.cobrand.moniker != 'zurich' %]
- <div>[% tprintf( updates_text, stats.updates ) | comma %]</div>
+ <div>[% tprintf( updates_text, decode(updates_n) ) %]</div>
[% END %]
</div>
diff --git a/templates/web/emptyhomes/front/stats.html b/templates/web/emptyhomes/front/stats.html
index c956b0e2e..5ecc415bf 100644
--- a/templates/web/emptyhomes/front/stats.html
+++ b/templates/web/emptyhomes/front/stats.html
@@ -1,8 +1,7 @@
-[% USE Comma %]
[% stats = c.cobrand.front_stats_data %]
<div id="front_stats">
- <div>[% tprintf( loc("<big>%s</big> reports"), stats ) | comma %]</div>
+ <div>[% tprintf( loc("<big>%s</big> reports"), stats ) %]</div>
<!-- <div><a href="/local/">[% loc('Find latest local and national news') %]</a></div> -->
<div id="eha-app-link"><a href="https://itunes.apple.com/gb/app/empty-homes-spotter/id482550587?mt=8">Get the Empty Homes Spotter App for iPhone</a></div>
</div>