Plagger::Plugin::Filter::CompositeFeed - Multi feeds = Entries of one feed


Plagger documentation Contained in the Plagger distribution.

Index


Code Index:

NAME

Top

Plagger::Plugin::Filter::CompositeFeed - Multi feeds = Entries of one feed

SYNOPSIS

Top

  - module: Filter::CompositeFeed

DESCRIPTION

Top

This plugin composites all the feeds as entries of one feed. This is kind of other way round to what Filter::BreaakEntriesToFeeds does, and is considered as yet another hackish plugin to change the behavior of Publish and Notify plugins.

AUTHOR

Top

Tatsuhiko Miyagawa

SEE ALSO

Top

Plagger, Plagger::Plugin::Filter::BreakEntriesToFeeds


Plagger documentation Contained in the Plagger distribution.

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

sub register {
    my($self, $context) = @_;
    $context->register_hook(
        $self,
        'smartfeed.init' => \&initialize,
        'smartfeed.feed' => \&feed,
        'smartfeed.finalize' => \&finalize,
    );
}

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

    $self->{feed} = Plagger::Feed->new;
    $self->{feed}->title( $self->conf->{title} || "All feeds" );
    $self->{feed}->link( $self->conf->{link} );
}

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

    my $entry = Plagger::Entry->new;
    $entry->title($args->{feed}->title);
    $entry->link($args->{feed}->link);
    $entry->body($args->{feed}->description);
    $entry->add_tag($_) for @{ $args->{feed}->tags };

    $self->{feed}->add_entry($entry);
}

sub finalize {
    my($self, $context, $args) = @_;
    $context->update->{feeds} = [ $self->{feed} ];
}

1;

__END__