| Plagger documentation | Contained in the Plagger distribution. |
Plagger::Plugin::Subscription::Config - Subscription in config.yaml
- module: Subscription::Config
config:
feed:
- url: http://bulknews.typepad.com/blog/atom.xml
- url: http://blog.bulknews.net/mt/index.rdf
This plugin allows you to configure your subscription hardwired in
config.yaml.
Tatsuhiko Miyagawa
| Plagger documentation | Contained in the Plagger distribution. |
package Plagger::Plugin::Subscription::Config; use strict; use base qw( Plagger::Plugin ); use Encode; use Plagger::Tag; sub register { my($self, $context) = @_; $context->register_hook( $self, 'subscription.load' => $self->can('load'), ); } sub load { my($self, $context) = @_; my $feeds = $self->conf->{feed} or return; $feeds = [ $feeds ] unless ref $feeds; for my $config (@$feeds) { if (!ref($config)) { $config = { url => $config }; } # file:// URL doesn't work with UTF-8 flag on Win32 Encode::_utf8_off($config->{url}); my $feed = Plagger::Feed->new; $feed->url($config->{url}) or $context->error("Feed URL is missing"); $feed->link($config->{link}) if $config->{link}; $feed->title($config->{title}) if $config->{title}; $feed->meta($config->{meta}) if $config->{meta}; if (my $tags = $config->{tag}) { unless (ref $tags) { $tags = [ Plagger::Tag->parse($config->{tag}) ]; } $feed->tags($tags); } $context->subscription->add($feed); } } 1; __END__