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

Revision 138 (checked in by miyagawa, 15 years ago)
  • Fixes SmartFeed? duplicate entries bug. Fixes #61
  • Support CTCP ACTION (/me blah blah) in Publish::IRC
  • 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         'smartfeed.finalize' => \&feed_finalize,
16     );
17 }
18
19 sub feed_init {
20     my($self, $context, $args) = @_;
21
22     my $feed = Plagger::Feed->new;
23     $feed->type('smartfeed');
24     $feed->id( $self->conf->{id} || ('smartfeed:' . $self->rule->id) );
25     $feed->title( $self->conf->{title} || "Entries " . $self->rule->as_title );
26
27     $self->{feed} = $feed;
28 }
29
30 sub feed_entry {
31     my($self, $context, $args) = @_;
32     $self->{feed}->add_entry($args->{entry}->clone);
33 }
34
35 sub feed_finalize {
36     my($self, $context, $args) = @_;
37     $context->update->add($self->{feed}) if $self->{feed}->count;
38 }
39
40 1;
Note: See TracBrowser for help on using the browser.