Plagger::Plugin::Filter::BreakEntriesToFeeds - 1 entry = 1 feed


Plagger documentation Contained in the Plagger distribution.

Index


Code Index:

NAME

Top

Plagger::Plugin::Filter::BreakEntriesToFeeds - 1 entry = 1 feed

SYNOPSIS

Top

  - module: Filter::BreakEntriesToFeeds

DESCRIPTION

Top

This plugin breaks all the updated entries into a single feed. This is a bit hackish plugin but allows things like sending a single mail containing single entry, rather than a feed containing multiple entries, with Publish::Gmail plugin.

CONFIG

Top

use_entry_title

Use entry's title as a newly generated feed title. Defaults to 0.

AUTHOR

Top

Tatsuhiko Miyagawa

SEE ALSO

Top

Plagger


Plagger documentation Contained in the Plagger distribution.

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

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

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

    for my $entry ($args->{feed}->entries) {
        my $feed = $args->{feed}->clone;
        $feed->clear_entries;
        $feed->add_entry($entry);
        $feed->title($entry->title)
            if $self->conf->{use_entry_title};
        $context->update->add($feed);
    }

    $context->update->delete_feed($args->{feed});
}

1;

__END__