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

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

Filter::BreakEntriesToFeeds?: support Rule to handle which feeds to braek. Suggested by otsune

Line 
1 package Plagger::Plugin::Filter::BreakEntriesToFeeds;
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.feed.fixup' => \&break,
10     );
11 }
12
13 sub break {
14     my($self, $context, $args) = @_;
15
16     for my $entry ($args->{feed}->entries) {
17         my $feed = $args->{feed}->clone;
18         $feed->clear_entries;
19         $feed->add_entry($entry);
20         $feed->title($entry->title)
21             if $self->conf->{use_entry_title};
22         $context->update->add($feed);
23     }
24
25     $context->update->delete_feed($args->{feed});
26 }
27
28 1;
29
30 __END__
31
32 =head1 NAME
33
34 Plagger::Plugin::Filter::BreakEntriesToFeeds - 1 entry = 1 feed
35
36 =head1 SYNOPSIS
37
38   - module: Filter::BreakEntriesToFeeds
39
40 =head1 DESCRIPTION
41
42 This plugin breaks all the updated entries into a single feed. This is
43 a bit hackish plugin but allows things like sending a single mail
44 containing single entry, rather than a feed containing multiple
45 entries, with Publish::Gmail plugin.
46
47 =head1 CONFIG
48
49 =over 4
50
51 =item use_entry_title
52
53 Use entry's title as a newly genrated feed title. Defaults to 0.
54
55 =back
56
57 =head1 AUTHOR
58
59 Tatsuhiko Miyagawa
60
61 =head1 SEE ALSO
62
63 L<Plagger>
64
65 =cut
Note: See TracBrowser for help on using the browser.