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

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

split out tags functionality into shiny new Plagger::Tag

  • Property svn:keywords set to Id Revision
Line 
1 package Plagger::Plugin::Subscription::Config;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use Plagger::Tag;
6
7 sub register {
8     my($self, $context) = @_;
9
10     $context->register_hook(
11         $self,
12         'subscription.load' => \&load,
13     );
14 }
15
16 sub load {
17     my($self, $context) = @_;
18
19     my $feeds = $self->conf->{feed};
20        $feeds = [ $feeds ] unless ref $feeds;
21
22     for my $config (@$feeds) {
23         my $feed = Plagger::Feed->new;
24         $feed->url($config->{url}) or $context->error("Feed URL is missing");
25         $feed->link($config->{link})   if $config->{link};
26         $feed->title($config->{title}) if $config->{title};
27
28         if ($config->{tags}) {
29             my @tags = Plagger::Tag->parse($config->{tags});
30             $feed->tags(\@tags);
31         }
32
33         $context->subscription->add($feed);
34     }
35 }
36
37 1;
Note: See TracBrowser for help on using the browser.