| Plagger documentation | Contained in the Plagger distribution. |
Plagger::Plugin::Publish::OutlineText - Publish as hierarchical text
- module: Publish::OutlineText
config:
filename: /path/to/outline.txt
encoding: utf8
This plugin publishes feeds as hierarchical text format.
The output filename
The encoding name for the output file. (ex: utf8, shiftjis, euc-jp)
Motokazu Sekine (CHEEBOW) @M-Logic, Inc.
Plagger, Encode::Supported
| Plagger documentation | Contained in the Plagger distribution. |
# Plagger::Plugin::Publish::OutlineText # $Id: /mirror/plagger/trunk/plagger/lib/Plagger/Plugin/Publish/OutlineText.pm 4054 2006-08-24T09:32:37.524228Z miyagawa $ package Plagger::Plugin::Publish::OutlineText; use strict; use base qw( Plagger::Plugin ); use Encode; sub register { my($self, $context) = @_; $context->register_hook( $self, 'publish.feed' => \&feed, 'publish.finalize' => \&finalize, ) } my $feed_count = 0; sub feed { my($self, $context, $args) = @_; push @{ $self->{_feeds} }, $args->{feed}; } sub finalize { my($self, $context, $args) = @_; my $filename = $self->conf->{filename} || './outline.txt'; my $encoding = $self->conf->{encoding} || 'utf8'; my $out; foreach my $feed (@{ $self->{_feeds} }) { $out .= '.' . $feed->title . "\n"; foreach my $entry (@{ $feed->entries }) { $out .= '..' . ($entry->title || '') . "\n"; my $body = $entry->body_text; $body =~ s/^\./ \./g; $out .= $body . "\n"; } } $out = encode($encoding, $out); open my $fh, ">", $filename or $context->error("$filename: $!"); print $fh $out; close $fh; } 1; __END__