X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FElements%2FMakeClicky;h=e22e75fbbbc01df491c733fdd7de34c4d1a33e32;hb=b8988e1d3ac75af63c85e8563e57701030315a9e;hp=f0aaf0696fa503d4457559f26e9153c4ed51d417;hpb=63a268637b2d51a8766412617724b9436439deb6;p=freeside.git diff --git a/rt/share/html/Elements/MakeClicky b/rt/share/html/Elements/MakeClicky index f0aaf0696..e22e75fbb 100644 --- a/rt/share/html/Elements/MakeClicky +++ b/rt/share/html/Elements/MakeClicky @@ -1,40 +1,40 @@ %# BEGIN BPS TAGGED BLOCK {{{ -%# +%# %# COPYRIGHT: -%# -%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC -%# -%# +%# +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC +%# +%# %# (Except where explicitly superseded by other copyright notices) -%# -%# +%# +%# %# LICENSE: -%# +%# %# This work is made available to you under the terms of Version 2 of %# the GNU General Public License. A copy of that license should have %# been provided with this software, but in any event can be snarfed %# from www.gnu.org. -%# +%# %# This work is distributed in the hope that it will be useful, but %# WITHOUT ANY WARRANTY; without even the implied warranty of %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %# General Public License for more details. -%# +%# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA %# 02110-1301 or visit their web page on the internet at %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. -%# -%# +%# +%# %# CONTRIBUTION SUBMISSION POLICY: -%# +%# %# (The following paragraph is not intended to limit the rights granted %# to you to modify and distribute this software under the terms of %# the GNU General Public License and is only of importance to you if %# you choose to contribute your changes and enhancements to the %# community by submitting them to Best Practical Solutions, LLC.) -%# +%# %# By intentionally submitting any modifications, corrections or %# derivatives to this work, or any other work intended for use with %# Request Tracker, to Best Practical Solutions, LLC, you confirm that @@ -43,27 +43,32 @@ %# royalty-free, perpetual, license to use, copy, create derivative %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. -%# +%# %# END BPS TAGGED BLOCK }}} <%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