X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FElements%2FMakeClicky;h=e22e75fbbbc01df491c733fdd7de34c4d1a33e32;hb=60dd95422a1ad4724e0c5d9dd7f8e8878cd96aa8;hp=2f2b8799026c687f2aa15ecaec352d7f4693cc62;hpb=fc6209f398899f0211cfcedeb81a3cd65e04a941;p=freeside.git diff --git a/rt/share/html/Elements/MakeClicky b/rt/share/html/Elements/MakeClicky index 2f2b87990..e22e75fbb 100644 --- a/rt/share/html/Elements/MakeClicky +++ b/rt/share/html/Elements/MakeClicky @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -48,22 +48,27 @@ <%ONCE> use Regexp::Common qw(URI); +my $escaper = sub { + my $content = shift; + RT::Interface::Web::EscapeUTF8( \$content ); + return $content; +}; + my %actions = ( default => sub { my %args = @_; - return $args{value}; + return $escaper->($args{value}); }, url => sub { my %args = @_; + $args{value} = $escaper->($args{value}); my $result = qq{[}. loc('Open URL') .qq{]}; return $args{value} . qq{ $result}; }, url_overwrite => sub { my %args = @_; - my $result = qq{}; - #XXX: use spaces here. ­ are not well supported :( - $args{'value'} =~ s/(\S{30})/$1 /g; - $result .= qq{$args{'value'}}; + $args{value} = $escaper->($args{value}); + my $result = qq{$args{value}}; return qq{$result}; }, ); @@ -71,12 +76,12 @@ my %actions = ( my @types = ( { name => "httpurl", - regex => qr/$RE{URI}{HTTP}{-keep}{-scheme => 'https?'}/, + regex => qr/$RE{URI}{HTTP}{-keep}{-scheme => 'https?'}(?:#[^\s<]+)?(? "url", }, { name => "httpurl_overwrite", - regex => qr/$RE{URI}{HTTP}{-keep}{-scheme => 'https?'}/, + regex => qr/$RE{URI}{HTTP}{-keep}{-scheme => 'https?'}(?:#[^\s<]+)?(? "url_overwrite", }, ); @@ -91,12 +96,6 @@ my $handle = sub { } }; -my $escaper = sub { - my $content = shift; - RT::Interface::Web::EscapeUTF8( \$content ); - return $content; -}; - # Hook to add more Clicky types # XXX Have to have Page argument, as Mason gets caller wrong in Callback? # This happens as we are in <%ONCE> block @@ -178,9 +177,7 @@ provides two formats: link after the URL. * 'httpurl_overwrite': also detects URLs as 'httpurl' format, but - replace URL with link and *adds spaces* into text if it's longer - then 30 chars. This allow browser to wrap long URLs and avoid - horizontal scrolling. + replace URL with link. To extend this with your own types of data, use the callback. It will be provided with: @@ -202,6 +199,6 @@ It will be provided with: have to. This can be used to add pre- or post-processing around all actions. -Read more about writing new actions in docs/extending_clickable_links.pod +Read more about writing new actions in docs/extending/clickable_links.pod