Plagger::Plugin::Filter::BloglinesContentNormalize - Strip extra attributes in Bloglines body


Plagger documentation Contained in the Plagger distribution.

Index


Code Index:

NAME

Top

Plagger::Plugin::Filter::BloglinesContentNormalize - Strip extra attributes in Bloglines body

SYNOPSIS

Top

  - module: Filter::BloglinesContentNormalize

DESCRIPTION

Top

This plugin strips extra attributes contained in Bloglines entry feed, e.g.

  target=_blank class=blines2 title="Link to another page in this blog"
  target=_blank class=blines3 title="Link outside of this blog"

This plugin is autoloaded via Filter::StripRSSAd plugin.

AUTHOR

Top

Tatsuhiko Miyagawa

SEE ALSO

Top

Plagger, Plagger::Plugin::Filter::StripRSSAd, http://www.bloglines.com/


Plagger documentation Contained in the Plagger distribution.

package Plagger::Plugin::Filter::BloglinesContentNormalize;
use strict;
use base qw( Plagger::Plugin );

our $Pattern = qr! target=_blank class=blines[23] title="Link (?:outside of|to another page in) this blog"!;

sub register {
    my($self, $context) = @_;
    $context->register_hook(
        $self,
        'update.entry.fixup' => \&filter,
    );
}

sub filter {
    my($self, $context, $args) = @_;

    my $body = $args->{entry}->body;
    my $c  = $body =~ s!$Pattern!!g;
       $c += $body =~ s!
!!g;
       $c += $body =~ s!"/>!" />!g;
    if ($c) {
        $context->log(info => "Stripped Bloglines extra attributes on " . $args->{entry}->link);
        $args->{entry}->body($body);
    }
}

1;

__END__