| 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__ |