root/trunk/plagger/lib/Plagger/Plugin/Filter/HatenaDiaryKeywordUnlink.pm

Revision 545 (checked in by miyagawa, 15 years ago)
Line 
1 package Plagger::Plugin::Filter::HatenaDiaryKeywordUnlink;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 sub register {
6     my($self, $context) = @_;
7     $context->register_hook(
8         $self,
9         'update.entry.fixup' => \&update,
10     );
11 }
12
13 sub update {
14     my($self, $context, $args) = @_;
15     my $body = $args->{entry}->body;
16
17     my $count = $body =~ s!<a class="o?keyword" href="http://(?:d|[\w\-]+\.g)\.hatena\.ne\.jp/keyword/.*?"[^>]*?>(.*?)</a>!$1!g;
18
19     if ($count) {
20         $context->log(info => "Stripped $count links to Hatena Diary Keywords");
21     }
22
23     $args->{entry}->body($body);
24 }
25
26 1;
27
28 __END__
29
30 =head1 NAME
31
32 Plagger::Plugin::Filter::HatenaDiaryKeywordUnlink - Strip Hatena Diary keyword links from fulltext feeds
33
34 =head1 SYNOPSIS
35
36   - module: Filter::HatenaDiaryKeywordUnlink
37
38 =head1 DESCRIPTION
39
40 This plugin strips link to Hatena Diary keyword links in feeds. By
41 default Hatena Diary feeds don't contain links to keywords, but with
42 Filter::EntryFullText plugin it might contain them.
43
44 =head1 AUTHOR
45
46 Tatsuhiko Miyagawa
47
48 =head1 SEE ALSO
49
50 L<Plagger>
51
52 =cut
Note: See TracBrowser for help on using the browser.