libofxにutfパッチ

gnucashで日本語が入ったofx(MS Money形式)ファイルをインポートすると文字化けして困っていたんですが、https://bugs.launchpad.net/ubuntu/+source/libofx/+bug/276379のパッチで直りました。
Fedoraだと

rpm -ivh http://kojipkgs.fedoraproject.org/packages/libofx/0.9.1/2.fc12/src/libofx-0.9.1-2.fc12.src.rpm
cd rpm/SOURCES
wget http://launchpadlibrarian.net/18087523/utf-8_fix.patch
cd ..

とした上で、SPECS/libofx.spec を

--- SPECS/libofx.spec.orig	2009-07-27 06:20:01.000000000 +0900
+++ SPECS/libofx.spec	2009-09-20 19:43:48.000000000 +0900
@@ -9,2 +9,3 @@
 Patch1: libofx-assorted-c++-fu.patch
+Patch2: utf-8_fix.patch
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -44,2 +45,3 @@
 %patch1 -p1 -b .c++-fu
+%patch2 -p1
 

と変更して

rpmbuild -ba SPECS/libofx.spec
rpm -U --force RPMS/i586/libofx-0.9.1-2.fc11.i586.rpm

で更新。

追記: gcc-c++ が入ってないとわかりにくいエラーが出て configure できません。

PubSubHubbubプラグインgithubに載せました

この前作ったプラグインgithubに載せました
hubとselfが2つずつあるのはやっぱり気になるので、

  • フィードを作る側でhubとselfを設定
  • Publish::FeedやNotify::PubSubHubbubは独自設定なしでフィードからhubやselfを読み出す

ように変えたい気もしますが、selfはともかくhubなんていうPubSubHubbubローカルの設定をそんなところに入れるのもなんだかなあです。

PlaggerでPubSubHubbub

PubSubHubbubでフィード更新を通知するのが流行りだしているので、Plaggerプラグインをいぢってみました。
まず、フィードに

  <link rel="hub" href="http://pubsubhubbub.appspot.com/"/>
  <link rel="self" href="http://foo.bar/baz.xml"/>

というリンクを入れる必要があるので、Publish::Feedに

--- Feed.pm.orig	2006-12-05 16:01:29.000000000 +0900
+++ Feed.pm	2009-08-11 21:53:36.000000000 +0900
@@ -62,4 +62,12 @@
     }
 
+    if ($self->conf->{hub} && $feed_format eq 'Atom') {
+        $feed->{atom}->add_link({ rel => 'hub', href => $self->conf->{hub}, });
+    }
+
+    if ($self->conf->{self} && $feed_format eq 'Atom') {
+        $feed->{atom}->add_link({ rel => 'self', href => $self->conf->{self}, });
+    }
+
     # add entry
     for my $e ($f->entries) {

というのを追加しました(すみませんAtomしか考えてません)。
更新時のPOSTによる通知は、cpanのNet::PubSubHubbub::Publisherを使って、以下のNotify::PubSubHubbubでやります:

package Plagger::Plugin::Notify::PubSubHubbub;

use strict;
use base qw( Plagger::Plugin );

use Net::PubSubHubbub::Publisher;

sub register {
    my ( $self, $context ) = @_;
    $context->register_hook(
        $self,
        'publish.entry' => \&update,
        'publish.finalize' => \&finalize,
    );
    $self->{count} = 0;
}

sub update {
    my($self, $context, $args) = @_;
    $self->{count}++ if $args->{feed}->count;
}

sub finalize {
    my($self, $context, $args) = @_;

    if ($self->{count}) {
	if ((my $hub = $self->conf->{hub}) && (my $s = $self->conf->{self})) {
	    $context->log(info => "Notifying " . $s . " to " . $hub);
	    my $pub = Net::PubSubHubbub::Publisher->new(hub => $hub);
	    $pub->publish_update($s) or
		die "Ping failed: " . $pub->last_response->status_line;
	    $context->log(info => "Status: " . $pub->last_response->status_line);
	}
    }
}
1;

使い方はこう(hubとselfが2つずつあるのがなんですが):

  - module: Publish::Feed
    config:
      filename: baz.xml
      hub: http://pubsubhubbub.appspot.com/
      self: http://foo.bar/baz.xml
  - module: Notify::PubSubHubbub
    config:
      hub: http://pubsubhubbub.appspot.com/
      self: http://foo.bar/baz.xml

これで作ったフィードをFriendFeedに登録してみたところ、Plagger終了直後に更新がFriendFeedに反映されているようです。
ちなみにフィードをPOSTしても、誰もそれをsubscribeしていないと、Publisher Diagnosticsで見てもCould not find any recordと言われます(しばらくこれで悩みました)。

次はGoogle Readerがsubscribe対応してくれるとうれしいんですが(今はin-progress)。

xfce 4.6でemacsバインディング

Fedora 11 RC2を入れてみたらfirefoxのキーバインディングemacsでなくなってしまいました。
xfce 4.6 で xfce-mcs-plugins がなくなって、~/.config/xfce4/mcs_settings/gtk.xml

<option name="Gtk/KeyThemeName" type="string" value="Emacs"/>

が認識されなくなったせいです。

xfconf-query -c xsettings -p /Gtk/KeyThemeName -s Emacs

で直りました。~/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml

<property name="Gtk" type="empty">
  <property name="KeyThemeName" type="string" value="Emacs"/>
</property>

というのが入ります。