X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FElements%2FMakeClicky;h=8efe78c4ae36b3aa68892c7277e9451ef1a80944;hp=e22e75fbbbc01df491c733fdd7de34c4d1a33e32;hb=0ea23112cfa0d82738b0f08d60d90579721b7524;hpb=60dd95422a1ad4724e0c5d9dd7f8e8878cd96aa8 diff --git a/rt/share/html/Elements/MakeClicky b/rt/share/html/Elements/MakeClicky index e22e75fbb..8efe78c4a 100644 --- a/rt/share/html/Elements/MakeClicky +++ b/rt/share/html/Elements/MakeClicky @@ -96,6 +96,8 @@ my $handle = sub { } }; +my $cache; # only defined via callback + # 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 @@ -104,6 +106,7 @@ $m->callback( types => \@types, actions => \%actions, handle => \$handle, + cache => \$cache, ); @@ -131,6 +134,15 @@ $html => undef <%INIT> return unless defined $$content; +if ( defined $cache ) { + my $cached_content = $cache->(fetch => $content); + if ( $cached_content ) { + RT->Logger->debug("Found MakeClicky cache"); + $$content = $cached_content; + return; + } +} + unless ( $regexp ) { RT::Interface::Web::EscapeUTF8( $content ) unless $html; return; @@ -165,40 +177,6 @@ substr( $$content, $pos ) = $escaper->( substr( $$content, $pos ) ) unless ($pos == length $$content) || $html; pos($$content) = 0; +$cache->(store => $content) if defined $cache; -<%doc> - -MakeClicky detects various formats of data in headers and email -messages, and extends them with supporting links. By default, RT -provides two formats: - - * 'httpurl': detects http:// and https:// URLs and adds '[Open URL]' - link after the URL. - - * 'httpurl_overwrite': also detects URLs as 'httpurl' format, but - replace URL with link. - -To extend this with your own types of data, use the callback. -It will be provided with: - - * 'types': An array reference of hash references. Modify this array - reference to add your own types; the first matching type will be - used. Each hashref should contain: - - 'name': The name of the data format; this is used in the - configuration file to enable the format. - - 'regex': A regular expression to match against - - 'action': The name of the action to run (see "actions", below) - - * 'actions': A hash reference of 'actions'. Modify this hash - reference to change or add action types. Values are subroutine - references which will get called when needed. They should return - the modified string. Note that subroutine must escape HTML. - - * 'handler': A reference to a subroutine reference; modify it if you - 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 - -