root/trunk/plagger/lib/Plagger/Plugin/Subscription/PlanetINI.pm

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

new plugin Subscription::PlanetINIT

Line 
1 package Plagger::Plugin::Subscription::PlanetINI;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use Config::INI::Simple;
6 use Plagger::Util;
7 use URI;
8
9 sub register {
10     my($self, $context) = @_;
11
12     $context->register_hook(
13         $self,
14         'subscription.load' => \&load,
15     );
16 }
17
18 sub load {
19     my($self, $context) = @_;
20
21     my $config = Config::INI::Simple->new;
22     $config->read($self->conf->{path});
23
24     for my $url (keys %$config) {
25         next if $url !~ m!https?://!;
26
27         my $feed = Plagger::Feed->new;
28         $feed->url($url);
29         $feed->title($config->{$url}->{name});
30
31         $context->subscription->add($feed);
32     }
33 }
34
35 1;
36
37 __END__
38
39 =head1 NAME
40
41 Plagger::Plugin::Subscription::PlanetINI - read subscriptions from Planet Planet's config.ini
42
43 =head1 SYNOPSIS
44
45   - module: Subscription::PlanetINI
46     config:
47       path: /path/to/config.ini
48
49 =head1 DESCRIPTION
50
51 This plugin extracts subscriptions out of Python Planet's I<config.ini> file.
52
53 =head1 AUTHOR
54
55 Tatsuhiko Miyagawa
56
57 =head1 SEE ALSO
58
59 L<Plagger>, L<http://planetplanet.org/>
60
61 =cut
62
Note: See TracBrowser for help on using the browser.