Aggregator::Simpleにaggregator.parseフェーズを実装するパッチ

読了まで:約0分


パッチを修正しました。修正したのは Aggregator::Simple に aggregator.parse フェーズを実装するパッチ 修正版 です。

=== lib/Plagger/Plugin/Aggregator/Simple.pm
==================================================================
--- lib/Plagger/Plugin/Aggregator/Simple.pm (revision 52)
+++ lib/Plagger/Plugin/Aggregator/Simple.pm (local)
@@ -15,7 +15,7 @@
my($self, $context) = @_;
$context->register\_hook(
$self,
-        'customfeed.handle'  => \\&aggregate,
+        'customfeed.handle'  => $self->can('aggregate'),
);
}
@@ -38,7 +38,7 @@
$res = $self->fetch_content($feed\_url) or return;
$self->handle_feed($feed_url, \$res->content, $args->{feed});
} else {
-        return;
+        $self->handle_content($url, $res, $args->{feed});
\}
return 1;
@@ -215,6 +215,19 @@
$str;
}
+sub handle_content {
+    my ($self, $url, $res, $feed) = @_;
+
+    my $context = Plagger->context;
+    my $args    = {
+        url      => $url,
+        response => $res,
+        feed     => $feed,
+    };
+
+    $context->run_hook_once('aggregator.parse', $args);
+}
+
1;
__END__

なんか書いてみたらあっさりできてしまった。

ちなみに他の Aggregator 系のプラグインで対応するにはやっぱり改造が必要なので注意。

#FIXME

にゃるら(カラクリスタ)

『輝かしい青春』なんて失かった人。
次に備えて待機中。

今は趣味でプログラミングをして
生活しています。