From: David Bremner Date: Thu, 31 Jul 2008 21:52:11 +0000 (-0300) Subject: add colon to header, add header filteringi, add discussion of message bodies; factor... X-Git-Tag: 0.4~26 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/2faac3c6fc457db9347ba378845b89b2799ae265 add colon to header, add header filteringi, add discussion of message bodies; factor out formatting routine --- diff --git a/IkiWiki/Plugin/mailbox.pm b/IkiWiki/Plugin/mailbox.pm index 7c8e4a5db..6e2939d69 100644 --- a/IkiWiki/Plugin/mailbox.pm +++ b/IkiWiki/Plugin/mailbox.pm @@ -40,7 +40,6 @@ sub preprocess (@) { #{{{ sub format_mailbox(@){ my %params=@_; my $path=$params{path} || error("path parameter mandatory"); - my $header_list=$params{headers} || "subject,from"; my $folder=Email::Folder->new($path) || error("mailbox could not be opened"); return join "\n", map { format_message(message=>$_) } $folder->messages; @@ -63,20 +62,30 @@ sub format_message(@){ my $message=$params{message} || error gettext("missing parameter"). "message"; + my $keep_headers=$params{headers} || qr/^(subject|from|date)/i; + my $template= template("email.tmpl") || error gettext("missing template"); - my @headers=map { make_pair($message,$_) } - $message->header_names; + my @names = grep {m/$keep_headers/;} ($message->header_names); + my @headers=map { make_pair($message,$_) } @names; + $template->param(HEADERS=>[@headers]); - - $template->param(body=>escapeHTML($message->body)); + $template->param(body=>format_body($message->body)); my $output=$template->output(); return $output; } +sub format_body($){ + my $body=shift; + + # it is not completely clear to me the right way to go here. some + # passing things straight to markdown is not working all that + # well. + return "
".escapeHTML($body)."
"; +} ### Utilities # From Arpit Jain diff --git a/templates/email.tmpl b/templates/email.tmpl index 17922ec95..8508fd2f4 100644 --- a/templates/email.tmpl +++ b/templates/email.tmpl @@ -1,9 +1,7 @@
- - - + :