about summary refs log tree commit homepage
path: root/lib/PublicInbox/Mbox.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-08-23 00:02:34 +0000
committerEric Wong <e@80x24.org>2015-08-23 00:02:50 +0000
commitf1747921cf00e251ea0d814d732fb8c9dc9e39cd (patch)
tree1376396b1474ed09f352f4e786a3e4eaada9100b /lib/PublicInbox/Mbox.pm
parent539f90b266ff9cf476234d87036157c008569835 (diff)
downloadpublic-inbox-f1747921cf00e251ea0d814d732fb8c9dc9e39cd.tar.gz
This improves compatibility and allows individual messages
to be concatenated into an existing mbox without further
modifications.  "git format-patch" does something similar
(but does not do "From " line escaping(!))
Diffstat (limited to 'lib/PublicInbox/Mbox.pm')
-rw-r--r--lib/PublicInbox/Mbox.pm12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index d49e9b39..bc4d639e 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -5,6 +5,7 @@ package PublicInbox::Mbox;
 use strict;
 use warnings;
 use PublicInbox::MID qw/mid_compressed mid2path/;
+require Email::Simple;
 
 sub thread_mbox {
         my ($ctx, $srch, $sfx) = @_;
@@ -14,6 +15,16 @@ sub thread_mbox {
         }
 }
 
+sub emit1 {
+        my $simple = Email::Simple->new(pop);
+        sub {
+                my ($response) = @_;
+                # single message should be easily renderable in browsers
+                my $fh = $response->([200, ['Content-Type'=>'text/plain']]);
+                emit_msg($fh, $simple);
+        }
+}
+
 sub emit_msg {
         my ($fh, $simple) = @_; # Email::Simple object
 
@@ -52,7 +63,6 @@ sub emit_mbox {
         $fh = PublicInbox::MboxGz->new($fh) if $sfx;
 
         require PublicInbox::GitCatFile;
-        require Email::Simple;
         my $mid = mid_compressed($ctx->{mid});
         my $git = PublicInbox::GitCatFile->new($ctx->{git_dir});
         my %opts = (offset => 0);