diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-11-01 12:07:01 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-11-01 12:07:01 +0000 |
commit | b3bb51dab4f620463c551e7bbe6814d415ebf227 (patch) | |
tree | 6bf8e6fcf20cf75aec1fa527a07381ff3d4c77c9 /perllib/FixMyStreet/App/View/Web.pm | |
parent | c9f11046146f48206f0d75399aeffcc34bfc3c20 (diff) | |
parent | 3e6dd24bc0bdff1392596a81bbe6b78bad51b245 (diff) |
Merge branch '1544-category-change-leave-update'
Diffstat (limited to 'perllib/FixMyStreet/App/View/Web.pm')
-rw-r--r-- | perllib/FixMyStreet/App/View/Web.pm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm index ae06181c8..f0bcad0be 100644 --- a/perllib/FixMyStreet/App/View/Web.pm +++ b/perllib/FixMyStreet/App/View/Web.pm @@ -22,6 +22,7 @@ __PACKAGE__->config( FILTERS => { add_links => \&add_links, escape_js => \&escape_js, + markup => [ \&markup_factory, 1 ], }, COMPILE_EXT => '.ttc', STAT_TTL => FixMyStreet->config('STAGING_SITE') ? 1 : 86400, @@ -98,6 +99,23 @@ sub _space_slash { return $t; } +=head2 markup_factory + +This returns a function that will allow updates to have markdown-style italics. +Pass in the user that wrote the text, so we know whether it can be privileged. + +=cut + +sub markup_factory { + my ($c, $user) = @_; + return sub { + my $text = shift; + return $text unless $user && ($user->from_body || $user->is_superuser); + $text =~ s{\*(\S.*?\S)\*}{<i>$1</i>}; + $text; + } +} + =head2 escape_js Used to escape strings that are going to be put inside JavaScript. |