Filter ticket text for display?

Hi folks – is there a hook to filter or process the ticket history texts
(email bodies) when they’re displayed? We’d like to turn certain pieces of
text (identified by regex) into html links.

Thanks!

Gary Oberbrunner

Hi folks – is there a hook to filter or process the ticket history
texts
(email bodies) when they’re displayed? We’d like to turn certain
pieces of
text (identified by regex) into html links.

You should be able to use the ModifyDisplay callback in
Tickets/Elements/ShowTransaction to do this.

If you already have html mail, you can turn on PreferRichText
in your config

-kevin

Hi Gary

Hi folks – is there a hook to filter or process the ticket history texts
(email bodies) when they’re displayed? We’d like to turn certain pieces of
text (identified by regex) into html links.

http://wiki.bestpractical.com/view/CustomizingWithCallbacks
I’m not sure how current it is, but it’s working for me on RT 3.4

Essentially I created a file in the local/share/request-tracker3.4 tree
called html/Callbacks/CCDC/Ticket/Elements/ShowMessageStanza/Default
containing:

<%init>
my $val = $$content;
use bytes;
$val =~ s/(s?http|https):[\w/.:+-]+/$&</a>/gi;
$$content = $val;
</%init>
<%args>
$content => undef
</%args>

If you capture anything in the , you can use $1, $2, … in the
replacement, as well as $& for the whole matched string.

$val =~ s;(bug|bz|bugzilla)\s*(\d{4,6});$&;gi;

would turn “bug 1234” into a clickable link.

LEGAL NOTICE
Unless expressly stated otherwise, information contained in this
message is confidential. If this message is not intended for you,
please inform postmaster@ccdc.cam.ac.uk and delete the message.
The Cambridge Crystallographic Data Centre is a company Limited
by Guarantee and a Registered Charity.
Registered in England No. 2155347 Registered Charity No. 800579
Registered office 12 Union Road, Cambridge CB2 1EZ.

Kevin Falcone wrote:

Hi folks – is there a hook to filter or process the ticket history texts
(email bodies) when they’re displayed? We’d like to turn certain
pieces of
text (identified by regex) into html links.

You should be able to use the ModifyDisplay callback in
Tickets/Elements/ShowTransaction to do this.

Thanks, Kevin – that looks like exactly what I need. I’ll try it. Does
anyone have a sample Callbacks/*/Elements/Ticket/ShowTransaction/ModifyDisplay
callback? I don’t really understand the calling convention, i.e. what are the
args and what I’m supposed to return. Should I write a function, or is it
just bare Mason/perl code? What are %INIT% and %ARGS% (I see those in some
other callbacks)? Where do I get the actual ticket text (message body)?

(I looked at the rt wiki page “CustomizingWithCallbacks” and it explains the
proper file/dir to put the callback in, but doesn’t say what it should look like.)

thx,

– Gary

Essentially I created a file in the local/share/request-tracker3.4 tree
called html/Callbacks/CCDC/Ticket/Elements/ShowMessageStanza/Default
containing:

<%init>
my $val = $$content;
use bytes;
$val =~ s/(s?http|https):[\w/.:+-]+/$&</a>/gi;
$$content = $val;
</%init>
<%args>
$content => undef
</%args>

Thanks – that’s exactly what I needed! I updated the wiki page with this code.

– Gary

Kevin Falcone wrote:

Hi folks – is there a hook to filter or process the ticket
history texts
(email bodies) when they’re displayed? We’d like to turn certain
pieces of
text (identified by regex) into html links.

You should be able to use the ModifyDisplay callback in
Tickets/Elements/ShowTransaction to do this.

Thanks, Kevin – that looks like exactly what I need. I’ll try
it. Does
anyone have a sample Callbacks/*/Elements/Ticket/ShowTransaction/
ModifyDisplay
callback? I don’t really understand the calling convention, i.e.
what are the
args and what I’m supposed to return. Should I write a function,
or is it
just bare Mason/perl code? What are %INIT% and %ARGS% (I see those
in some
other callbacks)? Where do I get the actual ticket text (message
body)?

(I looked at the rt wiki page “CustomizingWithCallbacks” and it
explains the
proper file/dir to put the callback in, but doesn’t say what it
should look like.)

The RTFM and RTIR packages on Index of /pub
rt/devel/ make
extensive use of callbacks. I’m not sure if they use that specific
callback, but
you should be able to understand the technique from them.

-kevin