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

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

Added docs to some plugins

  • 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;
40
41 __END__
42
43 =head1 NAME
44
45 Plagger::Plugin::Subscription::Config - Subscription in config.yaml
46
47 =head1 SYNOPSIS
48
49     - module: Subscription::Config
50       config:
51         feed:
52           - url: http://bulknews.typepad.com/blog/atom.xml
53           - url: http://blog.bulknews.net/mt/index.rdf
54
55 =head1 DESCRIPTION
56
57 This plugin allows you to configure your subscription I<hardwired> in
58 C<config.yaml>.
59
60 =head1 AUTHOR
61
62 Tatsuhiko Miyagawa
63
64 =head1 SEE ALSO
65
66 L<Plagger>
67
68 =cut
Note: See TracBrowser for help on using the browser.