Plagger::Plugin::Publish::Blosxom

for your happy splogging!
inspired by http://www.otsune.com/diary/2006/03/31/1.html#200603311

package Plagger::Plugin::Publish::Blosxom;
use utf8;
use strict;
use base qw( Plagger::Plugin );

use Encode;
use Digest::MD5 qw(md5_hex);

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

sub entry {
    my($self, $context, $args) = @_;
    
    my $content = $self->blosxom_entry($args->{entry}->title, $args->{entry}->body);
    $self->write($content, $args->{entry}->id);
}

sub blosxom_entry {
    my($self, $title, $body) = @_;
    return "$title\n$body\n";
}


sub write {
    my($self, $content, $id) = @_;
    
    my $file = $self->conf->{dir}.'/'.md5_hex(encode('utf-8', $id)).'.txt';
    open my $out, ">:utf8", $file or $self->context->error("$file: $!");
    print $out $content;
    close $out;
}

1;

config.yaml

plugins:
  - module: CustomFeed::GoogleVideo
    config:
      query: funny
      type: ipod

  - module: Cache
    config:
      file: /tmp/plagger_cache_blosxom
      diff_mode: 1

  - module: Publish::Blosxom
    config:
      dir: /public_html/blosxom/entries