diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/View/Web.pm | 8 | ||||
-rw-r--r-- | templates/web/base/my/my.html | 2 | ||||
-rw-r--r-- | templates/web/base/questionnaire/index.html | 2 | ||||
-rw-r--r-- | templates/web/base/report/_main.html | 2 | ||||
-rw-r--r-- | templates/web/base/report/update.html | 4 | ||||
-rw-r--r-- | templates/web/zurich/report/_main.html | 2 | ||||
-rw-r--r-- | templates/web/zurich/report/updates.html | 2 |
8 files changed, 12 insertions, 11 deletions
@@ -82,6 +82,7 @@ web-based cross-browser testing tools for this project. - Tests can run multiple times simultaneously. #1477 - Don’t cache geocoder results when STAGING_SITE is 1. #1447 - Make UPLOAD_DIR/GEO_CACHE relative to project root. #1474 + - Change add_links from a function to a filter. #1487 - Vagrant installation improvements: - Improve error handling. - Don't add a symlink if it is to the same place. diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm index d43d3af7e..63f21ff91 100644 --- a/perllib/FixMyStreet/App/View/Web.pm +++ b/perllib/FixMyStreet/App/View/Web.pm @@ -18,9 +18,10 @@ __PACKAGE__->config( render_die => 1, expose_methods => [ 'loc', 'nget', 'tprintf', 'prettify_dt', - 'add_links', 'version', 'decode', + 'version', 'decode', ], FILTERS => { + add_links => \&add_links, escape_js => \&escape_js, html => \&html_filter, }, @@ -105,15 +106,14 @@ sub prettify_dt { =head2 add_links - [% add_links( text ) | html_para %] + [% text | add_links | html_para %] Add some links to some text (and thus HTML-escapes the other text. =cut sub add_links { - my ( $self, $c, $text ) = @_; - + my $text = shift; $text =~ s/\r//g; $text = ent($text); $text =~ s{(https?://)([^\s]+)}{"<a href='$1$2'>$1" . _space_slash($2) . '</a>'}ge; diff --git a/templates/web/base/my/my.html b/templates/web/base/my/my.html index 9ba9533f8..69f686f68 100644 --- a/templates/web/base/my/my.html +++ b/templates/web/base/my/my.html @@ -56,7 +56,7 @@ <div class="item-list__update-wrap"> [% INCLUDE 'report/photo.html' object=u %] <div class="item-list__update-text"> - [% add_links( u.text ) | html_para %] + [% u.text | add_links | html_para %] <p class="meta-2"> [% tprintf( loc("Added %s"), prettify_dt( u.confirmed, 'date' ) ) %] diff --git a/templates/web/base/questionnaire/index.html b/templates/web/base/questionnaire/index.html index 312300b9d..b4595bbcd 100644 --- a/templates/web/base/questionnaire/index.html +++ b/templates/web/base/questionnaire/index.html @@ -25,7 +25,7 @@ <strong>Last update</strong> <a href="/report/[% problem.id %]">Show all updates</a> </p> - <p class="questionnaire-report-reminder__last-update">“[% add_links( updates.last.text ) %]”</p> + <p class="questionnaire-report-reminder__last-update">“[% updates.last.text | add_links %]”</p> [% END %] </div> diff --git a/templates/web/base/report/_main.html b/templates/web/base/report/_main.html index e536d3f33..dfcfb8ce4 100644 --- a/templates/web/base/report/_main.html +++ b/templates/web/base/report/_main.html @@ -58,7 +58,7 @@ [% INCLUDE 'report/photo.html' object=problem %] <div class="moderate-display"> - [% add_links( problem.detail ) | html_para %] + [% problem.detail | add_links | html_para %] </div> [% IF moderating %] diff --git a/templates/web/base/report/update.html b/templates/web/base/report/update.html index 93d03c75d..55fdeb3b1 100644 --- a/templates/web/base/report/update.html +++ b/templates/web/base/report/update.html @@ -31,7 +31,7 @@ [% INCLUDE 'report/photo.html' object=update %] <div class="item-list__update-text"> <div class="moderate-display"> - [% add_links( update.text ) | html_para %] + [% update.text | add_links | html_para %] </div> [% IF moderating %] <div class="moderate-edit"> @@ -39,7 +39,7 @@ <label><input type="checkbox" name="update_revert_detail" class="revert-textarea"> Revert to original</label> [% END %] - <textarea name="update_detail">[% add_links( update.text ) %]</textarea> + <textarea name="update_detail">[% update.text | add_links %]</textarea> </div> [% END %] diff --git a/templates/web/zurich/report/_main.html b/templates/web/zurich/report/_main.html index 34aa71590..c1e4d15e6 100644 --- a/templates/web/zurich/report/_main.html +++ b/templates/web/zurich/report/_main.html @@ -9,7 +9,7 @@ [% IF c.cobrand.allow_photo_display(problem) %] [% INCLUDE 'report/photo.html' object=problem %] [% END %] - [% add_links( problem.detail ) | html_para %] + [% problem.detail | add_links | html_para %] [% ELSE %] [% loc('This report is awaiting moderation.') %] [% END %] diff --git a/templates/web/zurich/report/updates.html b/templates/web/zurich/report/updates.html index 63f39d8f7..4489fea34 100644 --- a/templates/web/zurich/report/updates.html +++ b/templates/web/zurich/report/updates.html @@ -8,7 +8,7 @@ [%# XXX following should honour zurich_closed_states instead? %] [% IF problem.state == 'fixed - council' || ( problem.external_body AND problem.state == 'closed' ) %] - [% add_links( problem.extra.public_response ) | html_para %] + [% problem.extra.public_response | add_links | html_para %] [% END %] </div> </div> |