[Rt-commit] r4941 - in rt/branches/3.7-EXPERIMENTAL: .
html/Ticket/Elements
alexmv at bestpractical.com
alexmv at bestpractical.com
Mon Apr 3 18:22:30 EDT 2006
Author: alexmv
Date: Mon Apr 3 18:22:29 2006
New Revision: 4941
Added:
rt/branches/3.7-EXPERIMENTAL/html/Elements/MakeClicky
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowMessageHeaders
rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowMessageStanza
Log:
r12105 at zoq-fot-pik: chmrr | 2006-04-03 18:20:59 -0400
* Merge MakeClicky into core
Added: rt/branches/3.7-EXPERIMENTAL/html/Elements/MakeClicky
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL/html/Elements/MakeClicky Mon Apr 3 18:22:29 2006
@@ -0,0 +1,66 @@
+<%ONCE>
+use Regexp::Common qw(URI);
+
+my %actions = (
+ default => sub {
+ my %args = @_;
+ return $args{value};
+ },
+ url => sub {
+ my %args = @_;
+ my $result = qq{[<a target="new" href="$args{value}">}. loc('open URL') .qq{</a>]};
+ return $args{value} . qq{ <span class="clickylink">$result</span>};
+ },
+);
+
+my @types = (
+ {
+ name => "httpurl",
+ regex => qr/$RE{URI}{HTTP}{-keep}{-scheme => 'https?'}/,
+ action => "url",
+ },
+);
+
+my $handle = sub {
+ my %args = @_;
+ for my $rec( @types ) {
+ return $rec->{action}->( %args ) if $args{value} =~ $rec->{regex};
+ }
+};
+
+# Hook to add more Clicky types
+# XXX Have to have Page argument, as Mason gets caller wrong in Callback?
+$m->comp("/Elements/Callback", Page => "/Elements/MakeClicky",
+ types => \@types,
+ actions => \%actions,
+ handle => \$handle
+);
+
+# Filter
+my %active;
+$active{$_}++ for RT->Config->Get('Active_MakeClicky');
+ at types = grep {$active{$_->{name}}} @types;
+
+# Build up the whole match
+my $regexp = join "|",
+ map '\b'. $_->{regex} .'\b',
+ @types;
+
+# Make sure we have a default
+$actions{default} ||= sub {};
+
+# Anchor the regexes and look up the actions
+foreach my $type ( @types ) {
+ $type->{regex} = qr/^$type->{regex}$/;
+ $type->{action} = $actions{$type->{action}} || $actions{default};
+}
+
+</%ONCE>
+<%ARGS>
+$content => undef
+</%ARGS>
+<%INIT>
+
+$$content =~ s/($regexp)/$handle->( %ARGS, value => ($1 || '') )/gsieo;
+
+</%INIT>
Modified: rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowMessageHeaders
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowMessageHeaders (original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowMessageHeaders Mon Apr 3 18:22:29 2006
@@ -67,6 +67,12 @@
my %display_headers = map { lc($_) => 1 } @DisplayHeaders;
+my $ticket = $Message->TransactionObj->TicketObj;
+foreach my $f (@headers) {
+ next unless $display_headers{'_all'} || $display_headers{ lc $f->{'Tag'} };
+ $m->comp('/Elements/MakeClicky', content => \$f->{'Value'}, ticket => $ticket, %ARGS);
+}
+
$m->comp( '/Elements/Callback',
message => $Message,
headers => \@headers,
Modified: rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowMessageStanza
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowMessageStanza (original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowMessageStanza Mon Apr 3 18:22:29 2006
@@ -56,6 +56,7 @@
elsif ( ref $stanza eq "HASH" ) {
my $content = $stanza->{raw};
RT::Interface::Web::EscapeUTF8(\$content);
+ $m->comp('/Elements/MakeClicky', content => \$content, ticket => $ticket, %ARGS);
$m->comp('/Elements/Callback', content => \$content, %ARGS);
$content =~ s{$}{<br />}mg
if defined $content;
@@ -68,12 +69,13 @@
% } else {
% my $content = $Message;
% RT::Interface::Web::EscapeUTF8(\$content);
+% $m->comp('/Elements/MakeClicky', content => \$content, ticket => $ticket, %ARGS);
% $m->comp('/Elements/Callback', content => \$content, %ARGS);
% $content =~ s{$}{<br />}mg;
<%$content |n%>
% }
<%INIT>
-use URI::URL;
+my $ticket = $Transaction ? $Transaction->TicketObj : undef;
</%INIT>
<%ARGS>
$Message => undef
More information about the Rt-commit
mailing list