%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
<%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{[<a target="new" href="$args{value}">}. loc('Open URL') .qq{</a>]};
return $args{value} . qq{ <span class="clickylink">$result</span>};
},
url_overwrite => sub {
my %args = @_;
- my $result = qq{<a target="new" href="$args{'value'}">};
- #XXX: use spaces here. ­ <wbr> are not well supported :(
- $args{'value'} =~ s/(\S{30})/$1 /g;
- $result .= qq{$args{'value'}</a>};
+ $args{value} = $escaper->($args{value});
+ my $result = qq{<a target="new" href="$args{value}">$args{value}</a>};
return qq{<span class="clickylink">$result</span>};
},
);
my @types = (
{
name => "httpurl",
- regex => qr/$RE{URI}{HTTP}{-keep}{-scheme => 'https?'}/,
+ regex => qr/$RE{URI}{HTTP}{-keep}{-scheme => 'https?'}(?:#\S+)?/,
action => "url",
},
{
name => "httpurl_overwrite",
- regex => qr/$RE{URI}{HTTP}{-keep}{-scheme => 'https?'}/,
+ regex => qr/$RE{URI}{HTTP}{-keep}{-scheme => 'https?'}(?:#\S+)?/,
action => "url_overwrite",
},
);
}
};
-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
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:
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
</%doc>