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

Revision 1678 (checked in by miyagawa, 14 years ago)

r5306@rock: miyagawa | 2006-09-13 19:13:18 +0900
BloglinesContentNormalize?: added nasty hack to add space for empty tags in XHTML for StripRSSAd plugin

Line 
1 package Plagger::Plugin::Filter::BloglinesContentNormalize;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 our $Pattern = qr! target=_blank class=blines[23] title="Link (?:outside of|to another page in) this blog"!;
6
7 sub register {
8     my($self, $context) = @_;
9     $context->register_hook(
10         $self,
11         'update.entry.fixup' => \&filter,
12     );
13 }
14
15 sub filter {
16     my($self, $context, $args) = @_;
17
18     my $body = $args->{entry}->body;
19     my $c  = $body =~ s!$Pattern!!g;
20        $c += $body =~ s!
!!g;
21        $c += $body =~ s!"/>!" />!g;
22     if ($c) {
23         $context->log(info => "Stripped Bloglines extra attributes on " . $args->{entry}->link);
24         $args->{entry}->body($body);
25     }
26 }
27
28 1;
29
30 __END__
31
32 =head1 NAME
33
34 Plagger::Plugin::Filter::BloglinesContentNormalize - Strip extra attributes in Bloglines body
35
36 =head1 SYNOPSIS
37
38   - module: Filter::BloglinesContentNormalize
39
40 =head1 DESCRIPTION
41
42 This plugin strips extra attributes contained in Bloglines entry feed, e.g.
43
44   target=_blank class=blines2 title="Link to another page in this blog"
45   target=_blank class=blines3 title="Link outside of this blog"
46
47 This plugin is autoloaded via Filter::StripRSSAd plugin.
48
49 =head1 AUTHOR
50
51 Tatsuhiko Miyagawa
52
53 =head1 SEE ALSO
54
55 L<Plagger>, L<Plagger::Plugin::Filter::StripRSSAd>, L<http://www.bloglines.com/>
56
57 =cut
Note: See TracBrowser for help on using the browser.