root/trunk/plagger/lib/Plagger/Plugin/SmartFeed.pm

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

oops, fail to svk add

  • Property svn:keywords set to Id Revision
Line 
1 package Plagger::Plugin::SmartFeed;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use Plagger::Tag;
6
7 sub rule_hook { 'smartfeed.entry' }
8
9 sub register {
10     my($self, $context) = @_;
11     $context->register_hook(
12         $self,
13         'smartfeed.init'  => \&feed_init,
14         'smartfeed.entry' => \&feed_entry,
15     );
16 }
17
18 sub feed_init {
19     my($self, $context, $args) = @_;
20
21     my $feed = Plagger::Feed->new;
22     $feed->type('smartfeed');
23     $feed->id( $self->conf->{id} || ('smartfeed:' . $self->rule->id) );
24     $feed->title( $self->conf->{title} || "Entries " . $self->rule->as_title );
25
26     $context->update->add($feed);
27
28     $self->{feed} = $feed;
29 }
30
31 sub feed_entry {
32     my($self, $context, $args) = @_;
33     $self->{feed}->add_entry($args->{entry}->clone);
34 }
35
36 1;
Note: See TracBrowser for help on using the browser.