Plagger::Plugin::Publish::File
読了まで:約0分
概要: Feed か
Plagger に
package Plagger::Plugin::Publish::File;
use strict;
use warnings;
use base qw(Plagger::Plugin);
use Array::Uniq qw(uniq);
sub init {
my $self = shift;
$self->SUPER::init(@_);
$self->{'url'} = [];
}
sub register {
my ( $self, $c ) = @_;
$c->register_hook(
$self,
'publish.entry' => $self->can('add'),
'publish.finalize' => $self->can('publish'),
);
}
sub add {
my ( $self, $c, $args ) = @_;
if ( $self->conf->{'entry_url'} ) {
push @{ $self->{'url'} }, $args->{'entry'}->link;
}
else {
push @{ $self->{'url'} }, $args->{'feed'}->url;
}
}
sub publish {
my ( $self, $c ) = @_;
my $out = q{};
for my $url ( uniq sort { $a cmp $b } @{ $self->{'url'} } ) {
$out .= "$url\n";
}
my $path = $self->conf->{'filename'};
$c->log(info => "writing output to $path");
open my $fh, ">:utf8", $path or $c->error("$path: $!");
print $fh $out;
close $fh;
}
1;
__END__
ライセンスは
plugins:
- module: Subscription::Config
config:
feed: http://nyarla.net/blog
- module: Publish::File
config:
entry_url: 1
filename: /path/to/entry_list.txt
設定のentry_url
を
SBM からの
あとで
追記
一部修正。
#FIXME