Index: lib/Plagger/Plugin/Subscription/XOXO.pm
===================================================================
--- lib/Plagger/Plugin/Subscription/XOXO.pm (revision 781)
+++ lib/Plagger/Plugin/Subscription/XOXO.pm (working copy)
@@ -1,54 +1,14 @@
package Plagger::Plugin::Subscription::XOXO;
use strict;
-use base qw( Plagger::Plugin );
+use base qw( Plagger::Plugin::Subscription::XPath );
-use HTML::TreeBuilder::XPath;
-use Plagger::Util;
-use URI;
-
-sub register {
- my($self, $context) = @_;
-
- $context->register_hook(
- $self,
- 'subscription.load' => \&load,
- );
-}
-
sub load {
my($self, $context) = @_;
- my $uri = URI->new($self->conf->{url})
- or $context->error("config 'url' is missing");
- $self->load_xoxo($context, $uri);
+ $self->conf->{xpath} = '//ul[@class="xoxo" or @class="subscriptionlist"]//a';
+ $self->SUPER::load($context);
}
-sub load_xoxo {
- my($self, $context, $uri) = @_;
-
- my $xhtml = Plagger::Util::load_uri($uri, $self);
- my $tree = HTML::TreeBuilder::XPath->new;
- $tree->parse($xhtml);
- $tree->eof;
-
- $self->find_xoxo($tree);
-}
-
-sub find_xoxo {
- my($self, $tree) = @_;
-
- for my $child ($tree->findnodes('//ul[@class="xoxo" or @class="subscriptionlist"]//a')) {
- my $href = $child->attr('href') or next;
- my $title = $child->attr('title') || $child->as_text;
-
- my $feed = Plagger::Feed->new;
- $feed->url($href);
- $feed->title($title);
-
- Plagger->context->subscription->add($feed);
- }
-}
-
1;
__END__