X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FView.pm;h=e7e387d3069f0f5f04daf1873b6bd09ec40fa7c0;hb=4af9fd9c5e46eed341a535f37d54cf228303326c;hp=0ba78fe2d9e103bcbe201dbbb47d1cf32a56fa40;hpb=115f78accd1cd79ea716db1d4e29ddc0633a9d45;p=public-inbox.git diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 0ba78fe2..e7e387d3 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -9,11 +9,13 @@ use warnings; use URI::Escape qw/uri_escape_utf8/; use Date::Parse qw/str2time/; use Encode::MIME::Header; +use Plack::Util; use PublicInbox::Hval qw/ascii_html/; use PublicInbox::Linkify; use PublicInbox::MID qw/mid_clean id_compress mid2path mid_mime/; use PublicInbox::MsgIter; use PublicInbox::Address; +use PublicInbox::WwwStream; require POSIX; use constant INDENT => ' '; @@ -21,17 +23,22 @@ use constant TCHILD => '` '; sub th_pfx ($) { $_[0] == 0 ? '' : TCHILD }; # public functions: (unstable) -# TODO: stream this, since threading is expensive but also oh-so-important sub msg_html { my ($ctx, $mime, $footer) = @_; - $footer = defined($footer) ? "\n$footer" : ''; my $hdr = $mime->header_obj; - headers_to_html_header($hdr, $ctx) . - multipart_text_as_html($mime, '') . - '
' .
-		html_footer($hdr, 1, $ctx) .
-		'
' . msg_reply($ctx, $hdr) . - '
'.  $footer . '
'; + my $tip = _msg_html_prepare($hdr, $ctx); + PublicInbox::WwwStream->new($ctx, sub { + my ($nr, undef) = @_; + if ($nr == 1) { + $tip . multipart_text_as_html($mime, '') . + '
' + } elsif ($nr == 2) { + '
' . html_footer($hdr, 1, $ctx) .
+			'
' . msg_reply($ctx, $hdr) . '
' + } else { + undef + } + }); } # /$INBOX/$MESSAGE_ID/#R @@ -44,14 +51,14 @@ sub msg_reply { push @$arg, '/path/to/YOUR_REPLY'; "
". - "You may reply publically to this message via email\n". - "using any one of the following methods:\n\n" . + "You may reply publically to this message via\n". + "plain-text email using any one of the following methods:\n\n" . "* Save the following mbox file, import it into your mail client,\n" . " and reply-to-all from there: mbox\n\n" . "* Reply to all the recipients using the --to, --cc,\n" . " and --in-reply-to switches of git-send-email(1):\n\n" . "\tgit send-email \\\n\t\t" . - join(" \\ \n\t\t", @$arg ). "\n\n" . + join(" \\\n\t\t", @$arg ). "\n\n" . qq( $se_url\n\n) . "* If your mail client supports setting the In-Reply-To" . " header\n via mailto: links, try the " . @@ -303,18 +310,15 @@ sub add_text_body { $s; } -sub headers_to_html_header { +sub _msg_html_prepare { my ($hdr, $ctx) = @_; my $srch = $ctx->{srch} if $ctx; my $atom = ''; - my $rv = ''; - my $upfx = ''; + my $rv = ""; # anchor for body start if ($srch) { - $atom = qq{!; + $ctx->{-upfx} = '../'; } - my @title; my $mid = $hdr->header_raw('Message-ID'); $mid = PublicInbox::Hval->new_msgid($mid); @@ -337,15 +341,11 @@ sub headers_to_html_header { $rv .= "$h: " . $v->as_html . "\n"; } + $ctx->{-title_html} = join(' - ', @title); $rv .= 'Message-ID: <' . $mid->as_html . '> '; - $rv .= "(raw)\n"; + $rv .= "(raw)\n"; $rv .= _parent_headers($hdr, $srch); $rv .= "\n"; - - ("". join(' - ', @title) . "$atom". - PublicInbox::Hval::STYLE . - "" . # anchor for body start - $rv); } sub thread_skel {