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

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

fixed POD of Publish::MT

Line 
1 package Plagger::Plugin::Filter::Rule;
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.entry' => \&update,
10         'smartfeed.feed'  => \&feed,
11     );
12 }
13
14 sub update {
15     my($self, $context, $args) = @_;
16     $self->{entries}->{$args->{entry}} = 1;
17 }
18
19 sub feed {
20     my($self, $context, $args) = @_;
21
22     for my $entry ($args->{feed}->entries) {
23         $args->{feed}->delete_entry($entry)
24             unless $self->{entries}->{$entry};
25     }
26
27     $self->{entries} = {};
28
29     if ($args->{feed}->count == 0) {
30         $context->log(debug => "Deleting " . $args->{feed}->title . " since it has 0 entries");
31         $context->update->delete_feed($args->{feed})
32     }
33
34 }
35
36 1;
37
38 __END__
39
40 =head1 NAME
41
42 Plagger::Plugin::Filter::Rule - Filter feed entries using Rule
43
44 =head1 SYNOPSIS
45
46   - module: Filter::Rule
47     rule:
48       module: Fresh
49       mtime:
50         path: /tmp/foo.tmp
51         autoupdate: 1
52
53 =head1 DESCRIPTION
54
55 This module strips entries and feeds using Rules. It's sort of like
56 SmartFeed, but while SmartFeed B<creates> new feed using Rule,
57 Filter::Rule strips entries and feeds that don't match with Rules.
58
59 =head1 AUTHOR
60
61 Tatsuhiko Miyagawa
62
63 =head1 SEE ALSO
64
65 L<Plagger>, L<Plagger::Plugin::SmartFeed>
66
67 =cut
68
69
Note: See TracBrowser for help on using the browser.