From 567db04c83a6dea6f6885716e159d9f9dc4c9798 Mon Sep 17 00:00:00 2001
From: David Bremner <bremner@unb.ca>
Date: Wed, 30 Jul 2008 23:23:53 -0300
Subject: [PATCH] open a mailbox

---
 IkiWiki/Plugin/mailbox.pm | 24 ++++++++++++++++++------
 test/out/.keep            |  0
 test/test.setup           |  2 +-
 3 files changed, 19 insertions(+), 7 deletions(-)
 delete mode 100644 test/out/.keep

diff --git a/IkiWiki/Plugin/mailbox.pm b/IkiWiki/Plugin/mailbox.pm
index 70c2eddfd..838a6378e 100644
--- a/IkiWiki/Plugin/mailbox.pm
+++ b/IkiWiki/Plugin/mailbox.pm
@@ -55,24 +55,25 @@ sub preprocess (@) { #{{{
 	my $page=$params{page};
 	my $type=$params{type} || 'maildir';
 
+	print STDERR join("\n",%params);
+
 	error("path is mandatory") if (!defined($params{path}));
 
 	# note, mbox is not a directory
 	my $dir=bestdir($page,$params{path}) || 
 	    error("could not find ".$params{path});
 
-	my $folder=Email::Folder->new($dir);
+	$dir = $config{srcdir} ."/" . $dir;
+
+	return  format_mailbox(path=>$dir);
 
-	    
-	    
-	return "mailbox plugin result";
 } # }}}
 
 sub filter (@) { #{{{
 	my %params=@_;
 	
-
-	debug("mailbox plugin: path=".$params{path});
+	
+#	debug("mailbox plugin: path=".$params{path});
 
 	return $params{content};
 } # }}}
@@ -200,6 +201,17 @@ sub savestate () { #{{{
 	debug("mailbox plugin running in savestate");
 } #}}}
 
+### The guts of the plugin
+### parameters 
+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=>$_) } $folder->messages;
+
+}
 
 ### Utilities
 
diff --git a/test/out/.keep b/test/out/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/test/test.setup b/test/test.setup
index b8f579016..5ec06b45d 100644
--- a/test/test.setup
+++ b/test/test.setup
@@ -115,7 +115,7 @@ use IkiWiki::Setup::Standard {
 	# Only send cookies over SSL connections.
 	#sslcookie => 1,
 	# Logging settings:
-	#verbose => 1,
+	verbose => 1,
 	syslog => 0,
 	# To link to user pages in a subdirectory of the wiki.
 	#userdir => "users",
-- 
2.39.5