root/trunk/plagger/lib/Plagger/Plugin/Publish/OPML.pm

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

Merge from refactoring-planet. YAY!

  • Property svn:keywords set to Id Revision
Line 
1 package Plagger::Plugin::Publish::OPML;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use Plagger::Date;
6 use File::Spec;
7
8 sub init {
9     my $self = shift;
10     $self->SUPER::init(@_);
11     my $output = $self->conf->{filename}
12         or Plagger->context->error("filename is missing");
13 }
14
15 sub register {
16     my($self, $context) = @_;
17     $context->register_hook(
18         $self,
19         'publish.finalize' => \&finalize,
20     );
21 }
22
23 sub finalize {
24     my($self, $context, $args) = @_;
25
26     my $out = $self->templatize('opml.tt', {
27         feeds => [ $context->subscription->feeds ],
28         now   => Plagger::Date->now,
29         conf  => $self->conf,
30     });
31
32     my $path = $self->conf->{filename};
33     $context->log(info => "Writing OPML to $path");
34
35     open my $fh, ">:utf8", $path or $context->error("$path: $!");
36     print $fh $out;
37     close $fh;
38 }
39
40 1;
41
42 __END__
43
44 =head1
45
46 Plagger::Plugin::Publish::OPML - Publish OPML files based on your subcscription
47
48 =head1 SYNOPSYS
49
50   - module: Publish::OPML
51     config:
52       filename: /path/to/subscription.opml
53
54 =head1 DESCRIPTION
55
56 This plugin publishes OPML file using feeds fonnd in the subscription.
57
58 =head1 CONFIG
59
60 =over 4
61
62 =item filename
63
64 Filename to save the OPML file. Required.
65
66 =item title
67
68 Title to be used as OPML head. Optional and defaults to I<Plagger Subscriptions>.
69
70 =back
71
72 =head1 AUTHOR
73
74 Tatsuhiko Miyagawa
75
76 =head1 SEE ALSO
77
78 L<Plagger>
79
80 =cut
Note: See TracBrowser for help on using the browser.