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

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

spacing fix.

Line 
1 package Plagger::Plugin::Subscription::File;
2
3 use strict;
4 use warnings;
5
6 use base qw(Plagger::Plugin);
7 use Plagger::Util;
8
9 use URI;
10
11 sub register {
12     my ( $self, $context ) = @_;
13
14     $context->register_hook( $self, 'subscription.load' => \&load );
15 }
16
17 sub load {
18     my ( $self, $context ) = @_;
19
20     my $uri = URI->new( $self->conf->{file} )
21       or $context->error("config 'file' is missing");
22
23     $uri->scheme('file') unless $uri->scheme;
24
25     for ( split /\n/, Plagger::Util::load_uri($uri)) {
26         s/\#.*//;
27         next if /^\s*$/;
28         my $feed = Plagger::Feed->new;
29         $feed->url($_);
30         $context->subscription->add($feed);
31     }
32
33     return 1;
34 }
35
36 1;
37
38 =head1 NAME
39
40 Plagger::Plugin::Subscription::File - Store feed URLs in a file
41
42 =head1 SYNOPSIS
43
44   - module: Subscription::File
45     config:
46       file: feeds.txt
47
48 =head1 DESCRIPTION
49
50 This module subscribes to feed URLs from a file, where each line is one URL.
51 Lines that start with # are ignored.The URLs can also point to HTML files, in
52 which case feed autodiscovery will happen. The C<file> configuration key can
53 point to any URI supported. If a scheme is not specified, 'file' is assumed.
54
55 =head1 AUTHOR
56
57 Ilmari Vacklin <ilmari.vacklin@helsinki.fi>
58
59 =head1 SEE ALSO
60
61 L<Plagger>
62
63 =head1 LICENSE
64
65 This module is free software; you can redistribute it and/or modify it under
66 the same terms as Perl itself.
Note: See TracBrowser for help on using the browser.