[Bps-public-commit] rt-extension-autolink branch, master, created. f8fd839f49258e3ec49801f5ae55d2272b061c6f

Shawn Moore sartak at bestpractical.com
Thu Jun 16 16:44:39 EDT 2011


The branch, master has been created
        at  f8fd839f49258e3ec49801f5ae55d2272b061c6f (commit)

- Log -----------------------------------------------------------------
commit 3697f2cbfbb2bee7381ea52c30440b4d11a596c0
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Thu Jun 16 15:06:11 2011 -0400

    Boilerplate

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..935a863
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,13 @@
+MANIFEST
+MANIFEST.bak
+META.yml
+Makefile
+Makefile.old
+SIGNATURE
+blib/
+inc/
+pm_to_blib
+.prove
+*.sw[po]
+cover_db/
+t/tmp/
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100755
index 0000000..d50129c
--- /dev/null
+++ b/Makefile.PL
@@ -0,0 +1,8 @@
+use inc::Module::Install;
+
+RTx('RT-Extension-AutoLink');
+license('GPLv2');
+all_from('lib/RT/Extension/AutoLink.pm');
+readme_from('lib/RT/Extension/AutoLink.pm');
+
+&WriteAll;
diff --git a/lib/RT/Extension/AutoLink.pm b/lib/RT/Extension/AutoLink.pm
new file mode 100644
index 0000000..97512bd
--- /dev/null
+++ b/lib/RT/Extension/AutoLink.pm
@@ -0,0 +1,29 @@
+package RT::Extension::AutoLink;
+use strict;
+use warnings;
+
+our $VERSION = '0.01';
+
+1;
+
+__END__
+
+=head1 NAME
+
+RT::Extension::AutoLink - automatically add RefersTo links for URLs in messages
+
+=head1 INSTALLATION
+
+    perl Makefile.PL
+    make
+    make install
+
+    # edit RT_SiteConfig.pm to modify your Set(@Plugins, ...) line to
+    # include RT::Extension::AutoLink
+
+=head1 AUTHORS
+
+Shawn M Moore C<< <sartak at bestpractical.com> >>
+
+=cut
+

commit 2c00b02e797aa46c7e95bc5c1b553f2db7c28cf4
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Thu Jun 16 16:37:35 2011 -0400

    Implementation
    
        See also https://rt.cpan.org/Ticket/Display.html?id=68880

diff --git a/lib/RT/Extension/AutoLink.pm b/lib/RT/Extension/AutoLink.pm
index 97512bd..8c385c0 100644
--- a/lib/RT/Extension/AutoLink.pm
+++ b/lib/RT/Extension/AutoLink.pm
@@ -1,9 +1,32 @@
 package RT::Extension::AutoLink;
 use strict;
 use warnings;
+use Regexp::Common qw(URI);
 
 our $VERSION = '0.01';
 
+no warnings 'redefine';
+use RT::Ticket;
+my $orig = RT::Ticket->can('_RecordNote');
+*RT::Ticket::_RecordNote = sub {
+    my $self = shift;
+    my %args = @_;
+
+    my @ret = $self->$orig(@_);
+
+    my $content = $args{Content} || $args{MIMEObj}->stringify_body;
+
+    while ($content =~ /($RE{URI}{HTTP}{-keep}{-scheme => 'https?'}(?:#\S+)?)/g) {
+        $self->AddLink(
+            Target => $1,
+            Type   => 'RefersTo',
+        );
+    }
+
+    return @ret;
+};
+
+
 1;
 
 __END__

commit f8fd839f49258e3ec49801f5ae55d2272b061c6f
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Thu Jun 16 16:37:57 2011 -0400

    gitignore MYMETA.yml

diff --git a/.gitignore b/.gitignore
index 935a863..5ec0d47 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 MANIFEST
 MANIFEST.bak
+MYMETA.yml
 META.yml
 Makefile
 Makefile.old

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



More information about the Bps-public-commit mailing list