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

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

updated tag configuration

  • 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 (my $tags = $config->{tag}) {
29             unless (ref $tags) {
30                 $tags = [ Plagger::Tag->parse($config->{tag}) ];
31             }
32             $feed->tags($tags);
33         }
34
35         $context->subscription->add($feed);
36     }
37 }
38
39 1;
Note: See TracBrowser for help on using the browser.