トップ «前の日記(2006-09-16) 最新 次の日記(2006-09-20)» 編集

活動日誌


2006-09-18

[Plagger]CustomFeed::Simple でフィードのタイトルを指定する

CustomFeed::Simple を使った場合、フィードのタイトルはページの <title> 要素の中身になる。

こちらで指定したい場合があったので、指定できるようにしてみた。

Index: lib/Plagger/Plugin/CustomFeed/Simple.pm
===================================================================
--- lib/Plagger/Plugin/CustomFeed/Simple.pm     (リビジョン 1694)
+++ lib/Plagger/Plugin/CustomFeed/Simple.pm     (作業コピー)
@@ -44,7 +44,7 @@
     }

     my $content = decode_content($res);
-    my $title   = extract_title($content);
+    my $title   = $self->conf->{title} || extract_title($content);

     my $feed = Plagger::Feed->new;
     $feed->title($title);

config.yaml

  - module: CustomFeed::Simple
    config:
      title: ほげほげ

修正

mizzy さんのコメントをもとに、 Subscription::Config での指定を生かすように修正しました。

Index: lib/Plagger/Plugin/CustomFeed/Simple.pm
===================================================================
--- lib/Plagger/Plugin/CustomFeed/Simple.pm     (リビジョン 1694)
+++ lib/Plagger/Plugin/CustomFeed/Simple.pm     (作業コピー)
@@ -44,7 +44,7 @@
     }

     my $content = decode_content($res);
-    my $title   = extract_title($content);
+    my $title   = $args->{feed}->title || extract_title($content);

     my $feed = Plagger::Feed->new;
     $feed->title($title);

config.yaml

  - module: Subscription::Config
    config:
      feed:
        - url: http://....
          meta:
            follow_link: ....
          title: ほげほげ
  - module: CustomFeed::Simple

[Plagger]Filter::Pile を使うと途中で切れる

Filter::Pipe を使うと、エントリの body をパイプに渡して処理することができる。

しかし、どうも body が途中で切れてしまうことがあるようだ。

IPC::Run でどうやれば最後まで読めるのかは調べてみたがよく分からなかった。 (とりあえず ad hoc な対処としては、たくさん pump_nb すればそれなりに読めるが、それでも切れるようだ)

本日のツッコミ(全2件) [ツッコミを入れる]
_ mizzy (2006-09-18 18:17)

CustomFeed::Simple のタイトル指定ですが、これだと複数のフィードがある場合も、全部同じタイトルになっちゃいますね。<br><br>Subscription::Config でタイトルが指定できるので、そちらで指定しておいて、CustomFeed:::Simple では<br><br>my $title ||= extract_title($content);<br><br>とするのがいいんじゃないかと思います。

_ yanagi (2006-09-18 19:21)

ありがとうございます。複数フィードのことは考えから抜けていました。<br>確かにそちらの方がいいですね。


2005|02|03|04|05|06|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|03|04|05|06|10|
2008|04|10|
2009|10|
2010|05|08|
2012|01|02|03|
2014|01|
2022|05|
トップ «前の日記(2006-09-16) 最新 次の日記(2006-09-20)»