[rt-devel] Linking to external systems from RT

Robert Spier rspier at pobox.com
Wed Nov 19 22:16:51 EST 2003


> 
> Thanks for that Robert. I do vaguely remember that now from RT2.
> 
> I can't seem to find anything in the draft manual, or at
> http://fsck.com/rtfm/index.html
> 
> Can you point me at any useful documentation or examples?

Useful?  I'm not sure.  :)

I don't think there's any documentation on this (yet).

I believe RTFM and RTIR (downloadable from the same place you got RT)
make use of custom URIs, although not particularly fancily.  But I do
have another example.

Attached is a simple RT::URI::test, that will take things that look
like test:12345 in the Link field, and make them be links to
http://some.other.site/blah=12345 

As an extension, you can do test:12345#Some Title, and "Some Title"
it'll use that as the thing you click on.


(I've stripped this example down from something else, so it's possible
I screwed something up.. but the idea should be clear.)

-R


-------------- next part --------------
# local/lib/RT/URI/test.pm
# BEGIN LICENSE BLOCK
# 
# Copyright (c) 1996-2003 Jesse Vincent <jesse at bestpractical.com>
# 
# (Except where explictly superceded by other copyright notices)
# 
# 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.
# 
# Unless otherwise specified, all modifications, corrections or
# extensions to this work which alter its source code become the
# property of Best Practical Solutions, LLC when submitted for
# inclusion in the work.
# 
# 
# END LICENSE BLOCK
package RT::URI::test;

use RT::Ticket;

use RT::URI::base;

use strict;
use vars qw(@ISA);
@ISA = qw/RT::URI::base/;

my $scheme = "test";

=head2 ParseURI URI

When handed an test: URI, figures out things like whether its a
TEST reference or not.

=cut

sub ParseURI { 
    my $self = shift;
    my $uri = shift;

    # "test:<ticketnum>#<title>"

    if ($uri =~ /^$scheme:(\d+)/) {
      $self->{'uri'} = $uri;
      $self->{'href'} =  "http://some.other.site/blah=$1";
      $self->{'testid'} = $1;

     # if we have a tiitle, use it to setup the pretty printer
      if ($uri =~ /\#(.+)$/) {
	$self->{'title'} = $1 . "(test " . $self->{'testid'} . ")";
      } else {
        $self->{'title'} = $uri;
      }

      return 1;
    }
    return undef;
    
}

     # ->URI must always return the _full_ URI -- not a cleaned up version.

=head2 Scheme

Return the URI scheme 

=cut

sub Scheme {
  return $scheme;
}

sub HREF {
  my $self = shift;
  return($self->{'href'});
}

sub AsString {
  my $self = shift;
  return($self->{'title'});
}

1;


More information about the Rt-devel mailing list