Template-Plugin-Clickable-0.06/ 0000755 0001750 0001750 00000000000 10376245634 017747 5 ustar miyagawa miyagawa 0000000 0000000 Template-Plugin-Clickable-0.06/t/ 0000755 0001750 0001750 00000000000 10376245634 020212 5 ustar miyagawa miyagawa 0000000 0000000 Template-Plugin-Clickable-0.06/t/01_clickable.t 0000644 0001750 0001750 00000002026 10376245573 022612 0 ustar miyagawa miyagawa 0000000 0000000 use strict;
use Template::Test;
test_expect(\*DATA);
__END__
--test--
[% USE Clickable -%]
[% FILTER clickable -%]
http://www.template-toolkit.org/
[%- END %]
--expect--
http://www.template-toolkit.org/
--test--
[% USE Clickable -%]
[% FILTER clickable target => '_blank' -%]
http://www.template-toolkit.org/
http://www.template-toolkit.org/
[%- END %]
--expect--
http://www.template-toolkit.org/
http://www.template-toolkit.org/
--test--
[% USE Clickable -%]
[% FILTER clickable target => '_blank', rel => 'nofollow' -%]
http://www.template-toolkit.org/
[%- END %]
[% FILTER clickable rel => 'nofollow' -%]
http://www.template-toolkit.org/
[%- END %]
--expect--
http://www.template-toolkit.org/
http://www.template-toolkit.org/
Template-Plugin-Clickable-0.06/t/00_compile.t 0000644 0001750 0001750 00000000127 10303520531 022304 0 ustar miyagawa miyagawa 0000000 0000000 use strict;
use Test::More tests => 1;
BEGIN { use_ok 'Template::Plugin::Clickable' }
Template-Plugin-Clickable-0.06/lib/ 0000755 0001750 0001750 00000000000 10376245634 020515 5 ustar miyagawa miyagawa 0000000 0000000 Template-Plugin-Clickable-0.06/lib/Template/ 0000755 0001750 0001750 00000000000 10376245634 022270 5 ustar miyagawa miyagawa 0000000 0000000 Template-Plugin-Clickable-0.06/lib/Template/Plugin/ 0000755 0001750 0001750 00000000000 10376245634 023526 5 ustar miyagawa miyagawa 0000000 0000000 Template-Plugin-Clickable-0.06/lib/Template/Plugin/Clickable.pm 0000644 0001750 0001750 00000006022 10376245627 025737 0 ustar miyagawa miyagawa 0000000 0000000 package Template::Plugin::Clickable;
use strict;
our $VERSION = 0.06;
require Template::Plugin;
use base qw(Template::Plugin);
use vars qw($FILTER_NAME);
$FILTER_NAME = 'clickable';
use UNIVERSAL::require;
sub new {
my($class, $context, @args) = @_;
my $name = $args[0] || $FILTER_NAME;
$context->define_filter($name, $class->filter_factory());
bless { }, $class;
}
sub filter_factory {
my $class = shift;
my $sub = sub {
my($context, @args) = @_;
my $config = ref $args[-1] eq 'HASH' ? pop(@args) : { };
return sub {
my $text = shift;
my $finder_class = $config->{finder_class} || 'URI::Find';
$finder_class->require or die $UNIVERSAL::require::ERROR;
my $finder = $finder_class->new(
sub {
my($uri, $orig_uri) = @_;
my $target = $config->{target} ? qq( target="$config->{target}") : '';
my $rel = $config->{rel} ? qq( rel="$config->{rel}") : '';
return qq($orig_uri);
},
);
$finder->find(\$text);
return $text;
};
};
return [ $sub, 1 ];
}
1;
__END__
=head1 NAME
Template::Plugin::Clickable - Make URLs clickable in HTML
=head1 SYNOPSIS
[% USE Clickable %]
[% FILTER clickable %]
URL is http://www.tt2.org/
[% END %]
this will become:
URL is http://www.tt2.org/
=head1 DESCRIPTION
Template::Plugin::Clickable is a plugin for TT, which allows you to
filter HTMLs clickable.
=head1 OPTIONS
=over 4
=item target
[% FILTER clickable target => '_blank' %]
[% message.body | html %]
[% END %]
C option enables you to set target attribute in A links. none
by default.
=item finder_class
C option enables you to set other URI finder class
rather than URI::Find (default). For example,
[% FILTER clickable finder_class => 'URI::Find::Schemeless' %]
Visit www.example.com/join right now!
[% END %]
this will become:
Visit www.example.com/join right now!
=back
=head1 NOTE
If you use this module with C filter, you should be careful not
to break tags or brackets around the URLs. For example if you have a
following URL form,
Clickable plugin will filter this into:
which is bad for HTML viewing. However, if you HTML filter them first
and then clickable filter, you'll get:
<http://www.example.com/>
which href part is wrong.
You'd better try L in this case.
[% USE Clickable -%]
[% USE TagRescue -%]
[% FILTER html_except_for('a') -%]
[% FILTER clickable -%]
[%- END %]
[%- END %]
will give you the right format.
=head1 AUTHOR
Tatsuhiko Miyagawa Emiyagawa@bulknews.netE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 SEE ALSO
L, L, L
=cut
Template-Plugin-Clickable-0.06/MANIFEST 0000644 0001750 0001750 00000000264 10303520531 021060 0 ustar miyagawa miyagawa 0000000 0000000 Changes
MANIFEST
Makefile.PL
README
lib/Template/Plugin/Clickable.pm
t/00_compile.t
t/01_clickable.t
META.yml Module meta-data (added by MakeMaker)
Template-Plugin-Clickable-0.06/META.yml 0000644 0001750 0001750 00000000753 10376245633 021224 0 ustar miyagawa miyagawa 0000000 0000000 # http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Template-Plugin-Clickable
version: 0.06
version_from: lib/Template/Plugin/Clickable.pm
installdirs: site
requires:
Template: 2.07
Test::More: 0.32
UNIVERSAL::require: 0
URI::Find: 0.13
distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.17
Template-Plugin-Clickable-0.06/Changes 0000644 0001750 0001750 00000001102 10376245621 021230 0 ustar miyagawa miyagawa 0000000 0000000 Revision history for Perl extension Template::Plugin::Clickable
0.06 2006-02-20T04:54:28Z
- Added supporf of rel="nofollow"
(Thanks to Tokuhiro Matsuno)
0.05 Fri Dec 24 04:08:14 JST 2004
- Added reference to TagRescue in POD
(Stephen Quinney, Satoshi Tanimoto)
0.04 Wed Nov 12 02:24:56 JST 2003
* Added finder_class option, thanks to Tony Bowden
0.03 Thu Nov 14 18:49:15 JST 2002
* Fixed memory leak due to Template::Plugin::Filter
0.02 Sun Aug 18 19:04:30 JST 2002
- improved documentation
0.01 Tue Apr 23 20:40:40 2002
- original version
Template-Plugin-Clickable-0.06/README 0000644 0001750 0001750 00000002572 10303520531 020613 0 ustar miyagawa miyagawa 0000000 0000000 NAME
Template::Plugin::Clickable - Make URLs clickable in HTML
SYNOPSIS
[% USE Clickable %]
[% FILTER clickable %]
URL is http://www.tt2.org/
[% END %]
this will become:
URL is http://www.tt2.org/
DESCRIPTION
Template::Plugin::Clickable is a plugin for TT, which allows you to
filter HTMLs clickable.
OPTIONS
target
[% FILTER clickable target => '_blank' %]
[% message.body | html %]
[% END %]
"target" option enables you to set target attribute in A links. none
by default.
finder_class
"finder_class" option enables you to set other URI finder class
rather than URI::Find (default). For example,
[% FILTER clickable finder_class => 'URU::Find::Schemeless' %]
Visit www.example.com/join right now!
[% END %]
this will become:
Visit www.example.com/join right now!
NOTE
If you use this module with "html" filter, you should set this
"clickable" module after the "html" filter. Otherwise links will be also
escaped and thus broken.
AUTHOR
Tatsuhiko Miyagawa
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
SEE ALSO
Template, URI::Find
Template-Plugin-Clickable-0.06/Makefile.PL 0000644 0001750 0001750 00000000445 10303520531 021702 0 ustar miyagawa miyagawa 0000000 0000000 use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'Template::Plugin::Clickable',
'VERSION_FROM' => 'lib/Template/Plugin/Clickable.pm', # finds $VERSION
'PREREQ_PM' => {
'Test::More' => 0.32,
'Template' => 2.07,
'URI::Find' => 0.13,
'UNIVERSAL::require' => 0,
},
);