[Bps-public-commit] rt-extension-autolink branch, master, updated. 9cde9b28daac5bbd7d176b8259de68f2702eabf8

Shawn Moore sartak at bestpractical.com
Thu Jun 16 17:07:15 EDT 2011


The branch, master has been updated
       via  9cde9b28daac5bbd7d176b8259de68f2702eabf8 (commit)
       via  2bf9473c25daae40a019afa7efef196ecba2b2b9 (commit)
      from  a84979ed3765d789052c27f86bf2e900c4507596 (commit)

Summary of changes:
 lib/RT/Extension/AutoLink.pm |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)

- Log -----------------------------------------------------------------
commit 2bf9473c25daae40a019afa7efef196ecba2b2b9
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Thu Jun 16 17:03:46 2011 -0400

    Factor out AddRefersToLinksFromText

diff --git a/lib/RT/Extension/AutoLink.pm b/lib/RT/Extension/AutoLink.pm
index 8c385c0..1f7ca2d 100644
--- a/lib/RT/Extension/AutoLink.pm
+++ b/lib/RT/Extension/AutoLink.pm
@@ -14,17 +14,22 @@ my $orig = RT::Ticket->can('_RecordNote');
 
     my @ret = $self->$orig(@_);
 
-    my $content = $args{Content} || $args{MIMEObj}->stringify_body;
+    $self->AddRefersToLinksFromText($args{Content} || $args{MIMEObj}->stringify_body);
 
-    while ($content =~ /($RE{URI}{HTTP}{-keep}{-scheme => 'https?'}(?:#\S+)?)/g) {
+    return @ret;
+};
+
+sub RT::Ticket::AddRefersToLinksFromText {
+    my $self = shift;
+    my $text = shift;
+
+    while ($text =~ /($RE{URI}{HTTP}{-keep}{-scheme => 'https?'}(?:#\S+)?)/g) {
         $self->AddLink(
             Target => $1,
             Type   => 'RefersTo',
         );
     }
-
-    return @ret;
-};
+}
 
 
 1;

commit 9cde9b28daac5bbd7d176b8259de68f2702eabf8
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Thu Jun 16 17:07:05 2011 -0400

    Wrap Create too to get links from the first txn

diff --git a/lib/RT/Extension/AutoLink.pm b/lib/RT/Extension/AutoLink.pm
index 1f7ca2d..b22fbea 100644
--- a/lib/RT/Extension/AutoLink.pm
+++ b/lib/RT/Extension/AutoLink.pm
@@ -7,12 +7,24 @@ our $VERSION = '0.01';
 
 no warnings 'redefine';
 use RT::Ticket;
-my $orig = RT::Ticket->can('_RecordNote');
+my $orig_recordnote = RT::Ticket->can('_RecordNote');
 *RT::Ticket::_RecordNote = sub {
     my $self = shift;
     my %args = @_;
 
-    my @ret = $self->$orig(@_);
+    my @ret = $self->$orig_recordnote(@_);
+
+    $self->AddRefersToLinksFromText($args{Content} || $args{MIMEObj}->stringify_body);
+
+    return @ret;
+};
+
+my $orig_create = RT::Ticket->can('Create');
+*RT::Ticket::Create = sub {
+    my $self = shift;
+    my %args = @_;
+
+    my @ret = $self->$orig_create(@_);
 
     $self->AddRefersToLinksFromText($args{Content} || $args{MIMEObj}->stringify_body);
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list