From de5b1b004578c44dcc7d33748941108a88c6eb9d Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 3 Aug 2008 13:16:57 -0300 Subject: [PATCH] initial MIME handling --- IkiWiki/Plugin/mailbox.pm | 22 +++++++++++++++------- README | 1 + 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/IkiWiki/Plugin/mailbox.pm b/IkiWiki/Plugin/mailbox.pm index 2a2320aec..8f501ea40 100644 --- a/IkiWiki/Plugin/mailbox.pm +++ b/IkiWiki/Plugin/mailbox.pm @@ -4,10 +4,13 @@ # Copyright (c) 2008 David Bremner # This file is distributed under the Artistic License/GPL2+ +use Email::MIME; +package Email::MIMEFolder; +use base 'Email::Folder'; +sub bless_message { return Email::MIME->new($_[1]) }; + package IkiWiki::Plugin::mailbox; -use warnings; -use strict; use IkiWiki 2.00; use Email::Folder; use Email::Thread; @@ -26,7 +29,6 @@ sub scan(@){ my %params=@_; my $page=$params{page}; - debug('calling scan'); push @{$metaheaders{$page}}, '' } @@ -58,7 +60,7 @@ sub format_mailbox(@){ my %params=@_; my $path=$params{path} || error("path parameter mandatory"); - my $folder=Email::Folder->new($path) || error("mailbox could not be opened"); + my $folder=Email::MIMEFolder->new($path) || error("mailbox could not be opened"); my $threader=new Email::Thread($folder->messages); $threader->thread(); @@ -111,15 +113,21 @@ sub format_message(@){ my $template= template("email.tmpl") || error gettext("missing template"); - + + my $output=""; + my @names = grep {m/$keep_headers/;} ($message->header_names); my @headers=map { make_pair($message,$_) } @names; $template->param(HEADERS=>[@headers]); - $template->param(body=>format_body($message->body)); - my $output=$template->output(); + + my $body= join("\n", map { $_->body } $message->parts); + + $template->param(body=>format_body($body)); + + $output .= $template->output(); return $output; } diff --git a/README b/README index 0712e3474..572197b7d 100644 --- a/README +++ b/README @@ -3,4 +3,5 @@ Required perl modules (only top level dependencies are listed) Email::Folder Email::Thread +Email::Mime CGI (distributed with perl 5.10.0; maybe before?) \ No newline at end of file -- 2.39.2