[Rt-commit] r4940 - in rtir/branches/1.9-EXPERIMENTAL: .
html/Callbacks/RTIR/Elements/MakeClicky
html/Callbacks/RTIR/Ticket/Elements/ShowMessageHeaders
html/Callbacks/RTIR/Ticket/Elements/ShowMessageStanza
html/RTIR/Tools
alexmv at bestpractical.com
alexmv at bestpractical.com
Mon Apr 3 18:22:10 EDT 2006
Author: alexmv
Date: Mon Apr 3 18:21:58 2006
New Revision: 4940
Added:
rtir/branches/1.9-EXPERIMENTAL/html/Callbacks/RTIR/Elements/MakeClicky/
rtir/branches/1.9-EXPERIMENTAL/html/Callbacks/RTIR/Elements/MakeClicky/Default
Removed:
rtir/branches/1.9-EXPERIMENTAL/html/Callbacks/RTIR/Ticket/Elements/ShowMessageHeaders/
rtir/branches/1.9-EXPERIMENTAL/html/Callbacks/RTIR/Ticket/Elements/ShowMessageStanza/
Modified:
rtir/branches/1.9-EXPERIMENTAL/ (props changed)
rtir/branches/1.9-EXPERIMENTAL/etc/RTIR_Config.pm
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Tools/Lookup.html
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Tools/Traceroute.html
Log:
r12106 at zoq-fot-pik: chmrr | 2006-04-03 18:21:30 -0400
* Use new core MakeClicky from 3.7
Modified: rtir/branches/1.9-EXPERIMENTAL/etc/RTIR_Config.pm
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/etc/RTIR_Config.pm (original)
+++ rtir/branches/1.9-EXPERIMENTAL/etc/RTIR_Config.pm Mon Apr 3 18:21:58 2006
@@ -273,8 +273,11 @@
# if true then Blocks queue functionality inactive and disabled
Set($RTIR_DisableBlocksQueue, 0);
-# Define list of enabled MakeClicky extensions, allowed values are
-# httpurl, ip, ipdecimal, email, domain and RIPE
-Set(@RTIR_MakeClicky, qw(httpurl ip email domain));
+# Define list of enabled MakeClicky extensions; RTIR extends the
+# default 'httpurl', and additionally provides 'ip', 'ipdecimal',
+# 'email', 'domain' and 'RIPE'. It is possible to add your own types
+# of clicky links using callbacks; see
+# html/Callbacks/RTIR/Elements/MakeClicky/Default for an example.
+Set(@Active_MakeClicky, qw(httpurl ip email domain));
1;
Added: rtir/branches/1.9-EXPERIMENTAL/html/Callbacks/RTIR/Elements/MakeClicky/Default
==============================================================================
--- (empty file)
+++ rtir/branches/1.9-EXPERIMENTAL/html/Callbacks/RTIR/Elements/MakeClicky/Default Mon Apr 3 18:21:58 2006
@@ -0,0 +1,127 @@
+<%init>
+use Regexp::Common qw(URI net);
+use URI::URL;
+
+my $web_path = RT->Config->Get('WebPath');
+
+my %super = %{$ARGS{actions}};
+
+my %actions;
+%actions = (
+ default => sub {
+ my %args = @_;
+ return qq{<a href="$web_path/RTIR/Tools/Lookup.html?$args{lookup_params}q=$args{value}">$args{value}</a>};
+ },
+ url => sub {
+ my %args = @_;
+ my $uri = URI::URL->new($args{value});
+ my $host = $uri->host;
+
+ my $super = $super{url} ? $super{url}->(%args) : $args{value};
+
+ my $result = qq{[<a href="$web_path/RTIR/Tools/Lookup.html?$args{lookup_params}type=host&q=$host">}
+ .loc('lookup "[_1]"', $host) .qq{</a>]};
+ return $super . qq{ <span class="clickylink">$result</span>};
+ },
+ ip => sub {
+ my %args = @_;
+ $args{host} ||= $args{value};
+ my $result .= qq{[<a href="$web_path/RTIR/Tools/Lookup.html?$args{lookup_params}type=ip&q=$args{host}">}
+ .loc('lookup IP') .q{</a>]};
+ if ( $args{incident} && !RT->Config->Get('RTIR_DisableBlocksQueue') ) {
+ $result .= qq{[<a href="$web_path/RTIR/Create.html?Incident=$args{incident}&Queue=Blocks&IP-Value=$args{host}">block</a>]};
+ }
+ return $args{value} . qq{ <span class="clickylink">$result</span>};
+ },
+ ipdecimal => sub {
+ my %args = @_;
+ my $i = unpack "L",$args{value};
+ return $args{value} unless $args{value} > 33554432;
+
+ my $host = do {
+ my $hostnum = sprintf "%lx", $i;
+ my $a = hex( substr( $hostnum, 0, 2 ) );
+ my $b = hex( substr( $hostnum, 2, 2 ) );
+ my $c = hex( substr( $hostnum, 4, 2 ) );
+ my $d = hex( substr( $hostnum, 6, 2 ) );
+ "$a.$b.$c.$d";
+ };
+ return $actions{ip}->(%args, host => $host);
+ },
+ email => sub {
+ my %args = @_;
+ my ($pre, $post) = split /@/, $args{value}, 2;
+ my $result = qq{[<a href="$web_path/RTIR/Tools/Lookup.html?$args{lookup_params}type=email&q=$args{value}">}
+ .loc('lookup email') .q{</a>]};
+ if ( $args{incident} ) {
+ if ( $r->uri =~ /Lookup.html$/ ) {
+ $result .= qq{<input type="checkbox" name="Requestorbox-$args{value}" unchecked />};
+ }
+ $result .= qq{[<a href="$web_path/RTIR/Create.html?Incident=$args{incident}&Queue=Investigations&Requestors=$args{value}">}
+ .loc('Investigate to') .qq{</a>]};
+ }
+ $result .= qq{ [<a href="$web_path/RTIR/Tools/Lookup.html?$args{lookup_params}type=host&q=$post">}
+ .loc('lookup "[_1]"', $post) .qq{</a>]};
+ return $args{value} . qq{ <span class="clickylink">$result</span>};
+ },
+ noc => sub {
+ my %args = @_;
+ my $result = qq{[<a href="$web_path/RTIR/Tools/Lookup.html?$args{lookup_params}type=handle&q=$args{value}">}
+ .loc('lookup') .qq{</a>]};
+ return $args{value} . qq{ <span class="clickylink">$result</span>};
+ },
+ host => sub {
+ my %args = @_;
+ my $result = qq{[<a href="$web_path/RTIR/Tools/Lookup.html?$args{lookup_params}type=host&q=$args{value}">}
+ .loc('lookup host') .qq{</a>]};
+ return $args{value} . qq{ <span class="clickylink">$result</span>};
+ },
+);
+
+my @types = (
+ {
+ name => "ip",
+ regex => q[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}],
+ action => "ip",
+ },
+ {
+ name => "ipdecimal",
+ regex => q[\d{8,13}(?!=)],
+ action => "ipdecimal",
+ },
+ {
+ name => "email",
+ regex => q[(?:mailto:)?[\w\.\+-]+\@[\w\.-]+\.\w{2,3}],
+ action => "email",
+ },
+ {
+ name => "domain",
+ regex => q[(?:[\w-]+\.)+[A-Za-z]{2,3}],
+ action => "host",
+ },
+ {
+ name => "RIPE",
+ regex => q[(?-i:[A-Z][A-Z0-9-]+)],
+ action => "noc",
+ },
+);
+
+my $handle = ${$ARGS{handle}};
+${$ARGS{handle}} = sub {
+ my %args = @_;
+
+ $args{incident} = $args{ticket}->id
+ if $args{ticket} and $args{ticket}->QueueObj->Name eq 'Incidents';
+
+ $args{lookup_params} .= "&"
+ if $args{lookup_params} and $args{lookup_params} !~ /&$/;
+
+ return $handle->(%args);
+};
+
+%{$ARGS{actions}} = ( %{$ARGS{actions}}, %actions );
+push @{$ARGS{types}}, @types;
+
+$RT::Logger->info("Finished adding callbacks");
+
+</%init>
\ No newline at end of file
Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Tools/Lookup.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Tools/Lookup.html (original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Tools/Lookup.html Mon Apr 3 18:21:58 2006
@@ -164,7 +164,7 @@
% my @lines_starting_with_space = grep ( /^(\s+)(\w+)/, $obj->content());
% if ($handparse || $#lines_starting_with_space >= 4) { #we couldn't parse that. suck
% my $content = join("", $obj->content());
-% $m->comp( '/RTIR/Elements/MakeClicky', ticket => $TicketObj, url_params => "ticket=".$ticket."&server=$server", content => \$content);
+% $m->comp( '/Elements/MakeClicky', ticket => $TicketObj, lookup_params => "ticket=".$ticket."&server=$server", content => \$content);
% if ($content =~ /Requestorbox/ig) {
% $DoInvestigate = 1;
% }
@@ -180,7 +180,7 @@
% foreach my $attribute ($obj->attributes()) {
% foreach my $value ($obj->$attribute()) {
<b><%$attribute%></b>:
-% $m->comp( '/RTIR/Elements/MakeClicky', ticket => $TicketObj, url_params => "ticket=".$ticket, content => \$value);
+% $m->comp( '/Elements/MakeClicky', ticket => $TicketObj, lookup_params => "ticket=".$ticket, content => \$value);
<%$value|n%><br />
% }
% }
Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Tools/Traceroute.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Tools/Traceroute.html (original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Tools/Traceroute.html Mon Apr 3 18:21:58 2006
@@ -27,7 +27,7 @@
<pre>
<%PERL>
while (my $content = <$tr>) {
- $m->comp('/RTIR/Elements/MakeClicky', content => \$content);
+ $m->comp('/Elements/MakeClicky', content => \$content);
$m->out( $content );
$m->out('<br />');
$m->flush_buffer;
More information about the Rt-commit
mailing list