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

Revision 641 (checked in by miyagawa, 15 years ago)

add new hack plugin CompositeFeed?

Line 
1 package Plagger::Plugin::Filter::CompositeFeed;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 sub register {
6     my($self, $context) = @_;
7     $context->register_hook(
8         $self,
9         'smartfeed.init' => \&initialize,
10         'smartfeed.feed' => \&feed,
11         'smartfeed.finalize' => \&finalize,
12     );
13 }
14
15 sub initialize {
16     my($self, $context, $args) = @_;
17
18     $self->{feed} = Plagger::Feed->new;
19     $self->{feed}->title( $self->conf->{title} || "All feeds" );
20     $self->{feed}->link( $self->conf->{link} );
21 }
22
23 sub feed {
24     my($self, $context, $args) = @_;
25
26     my $entry = Plagger::Entry->new;
27     $entry->title($args->{feed}->title);
28     $entry->link($args->{feed}->link);
29     $entry->body($args->{feed}->description);
30     $entry->add_tag($_) for @{ $args->{feed}->tags };
31
32     $self->{feed}->add_entry($entry);
33 }
34
35 sub finalize {
36     my($self, $context, $args) = @_;
37     $context->update->{feeds} = [ $self->{feed} ];
38 }
39
40 1;
41
42 __END__
43
44 =head1 NAME
45
46 Plagger::Plugin::Filter::CompositeFeed - Multi feeds = Entries of one feed
47
48 =head1 SYNOPSIS
49
50   - module: Filter::CompositeFeed
51
52 =head1 DESCRIPTION
53
54 This plugin composites all the feeds as entries of one feed. This is
55 kind of other way round to what Filter::BreaakEntriesToFeeds does, and
56 is considered as yet another hackish plugin to change the behavior of
57 Publish and Notify plugins.
58
59 =head1 AUTHOR
60
61 Tatsuhiko Miyagawa
62
63 =head1 SEE ALSO
64
65 L<Plagger>, L<Plagger::Plugin::Filter::BreakEntriesToFeeds>
66
67 =cut
Note: See TracBrowser for help on using the browser.