: $ctx->gone('over');
$ctx->{mhref} = ($ctx->{nr} || $ctx->{smsg}) ?
"../${\mid_href($smsg->{mid})}/" : '';
- my $obuf = _msg_page_prepare_obuf($eml, $ctx);
- if (length($$obuf)) {
+ if (_msg_page_prepare_obuf($eml, $ctx)) {
multipart_text_as_html($eml, $ctx);
- $$obuf .= '</pre><hr>';
+ ${$ctx->{obuf}} .= '</pre><hr>';
}
- delete $ctx->{obuf};
- $$obuf .= html_footer($ctx, $ctx->{first_hdr}) if !$ctx->{smsg};
- $$obuf;
+ html_footer($ctx, $ctx->{first_hdr}) if !$ctx->{smsg};
+ delete($ctx->{obuf}) // \'';
} else { # called by WwwStream::async_next or getline
$ctx->{smsg}; # may be undef
}
my $eml = PublicInbox::Eml->new($bref);
$ctx->{mhref} = '';
PublicInbox::WwwStream::init($ctx);
- my $obuf = _msg_page_prepare_obuf($eml, $ctx);
- if (length($$obuf)) {
+ if (_msg_page_prepare_obuf($eml, $ctx)) { # sets {-title_html}
multipart_text_as_html($eml, $ctx);
- $$obuf .= '</pre><hr>';
+ ${$ctx->{obuf}} .= '</pre><hr>';
}
- delete $ctx->{obuf};
- eval { $$obuf .= html_footer($ctx, $eml) };
- html_oneshot($ctx, 200, $$obuf);
+ html_footer($ctx, $eml);
+ $ctx->html_done;
}
# public functions: (unstable)
# allow user to easily browse the range around this message if
# they have ->over
$ctx->{-t_max} = $smsg->{ts};
- PublicInbox::WwwStream::aresponse($ctx, 200, \&msg_page_i);
+ PublicInbox::WwwStream::aresponse($ctx, \&msg_page_i);
}
# /$INBOX/$MESSAGE_ID/#R
sub stream_thread ($$) {
my ($rootset, $ctx) = @_;
@{$ctx->{-queue}} = map { (0, $_) } @$rootset;
- PublicInbox::WwwStream::aresponse($ctx, 200, \&stream_thread_i);
+ PublicInbox::WwwStream::aresponse($ctx, \&stream_thread_i);
}
# /$INBOX/$MSGID/t/ and /$INBOX/$MSGID/T/
# flat display: lazy load the full message from smsg
$ctx->{msgs} = $msgs;
$ctx->{-html_tip} = '<pre>';
- PublicInbox::WwwStream::aresponse($ctx, 200, \&thread_html_i);
+ PublicInbox::WwwStream::aresponse($ctx, \&thread_html_i);
}
sub thread_html_i { # PublicInbox::WwwStream::getline callback
if ($nr) { # unlikely
if ($ctx->{chash} eq content_hash($eml)) {
warn "W: BUG? @$mids not deduplicated properly\n";
- return \$rv;
+ return;
}
$rv .=
"<pre>WARNING: multiple messages have this Message-ID\n</pre><pre>";
$ctx->{chash} = content_hash($eml) if $ctx->{smsg}; # reused MID
$rv .= "<pre\nid=b>"; # anchor for body start
}
- $ctx->{-upfx} = '../' if $have_over;
+ $ctx->{-upfx} = '../';
my @title; # (Subject[0], From[0])
for my $v ($eml->header('From')) {
my @n = PublicInbox::Address::names($v);
for my $v ($eml->header('Date')) {
$v = ascii_html($v);
obfuscate_addrs($obfs_ibx, $v) if $obfs_ibx; # possible :P
- $rv .= qq{Date: $v\t<a\nhref="#r">[thread overview]</a>\n};
+ $rv .= qq{Date: $v\n};
+ }
+ # [thread overview] link is typically added after Date,
+ # but added after Subject, or even nothing.
+ if ($have_over) {
+ chop $rv; # drop "\n", or noop if $rv eq ''
+ $rv .= qq{\t<a\nhref="#r">[thread overview]</a>\n};
}
if (!$nr) { # first (and only) message, common case
$ctx->{-title_html} = join(' - ', @title);
}
_parent_headers($ctx, $eml);
$rv .= "\n";
- \$rv;
+ 1;
}
sub SKEL_EXPAND () {
}
}
-# returns a string buffer
+# appends to obuf
sub html_footer {
my ($ctx, $hdr) = @_;
my $upfx = '../';
- my $skel;
- my $rv = '<pre>';
- my $related;
+ my ($related, $skel);
my $qry = delete $ctx->{-qry};
if ($qry && $ctx->{ibx}->isrch) {
my $q = ''; # search for either ancestor or descendent patches
} elsif ($u) { # unlikely
$parent = " <a\nhref=\"$u\"\nrel=prev>parent</a>";
}
- $rv .= "$next $prev$parent ";
+ ${$ctx->{obuf}} .= "<pre>$next $prev$parent ";
} else { # unindexed inboxes w/o over
+ ${$ctx->{obuf}} .= '<pre>';
$skel = qq( <a\nhref="$upfx">latest</a>);
}
- $rv .= qq(<a\nhref="#R">reply</a>);
- $rv .= $skel;
- $rv .= '</pre>';
- $rv .= $related // '';
- $rv .= msg_reply($ctx, $hdr);
+ ${$ctx->{obuf}} .= qq(<a\nhref="#R">reply</a>);
+ # $skel may be big for big threads, don't append it to obuf
+ $skel .= '</pre>' . ($related // '');
+ $ctx->zmore($skel .= msg_reply($ctx, $hdr)); # flushes obuf
}
sub linkify_ref_no_over {
my $n = strftime('%Y-%m-%d %H:%M:%S', gmtime($newest));
my $o = strftime('%Y-%m-%d %H:%M:%S', gmtime($oldest));
$ctx->{t_note} = <<EOM;
- messages from $o to $n UTC, [<a href="#nav">more...</a>]
+ messages from $o to $n UTC [<a href="#nav">more...</a>]
EOM
my $s = ts2str($newest);
$ctx->{prev_page} = qq[<a\nhref="?t=$s-"\nrel=prev>] .