sub mime2html {
my ($out, $eml, $ctx) = @_;
- my $smsg = bless {}, 'PublicInbox::Smsg';
+ my $smsg = $ctx->{smsg} = bless {}, 'PublicInbox::Smsg';
$smsg->populate($eml);
- print $out PublicInbox::View::eml_entry($ctx, $smsg, $eml, 1) or die;
+ print $out PublicInbox::View::eml_entry($ctx, $eml, 1) or die;
}
sub html_start {
my ($ctx, $eml) = @_;
$ctx->zmore($ctx->html_top) if exists $ctx->{-html_tip};
- $eml and return PublicInbox::View::eml_entry($ctx, $ctx->{smsg}, $eml,
+ $eml and return PublicInbox::View::eml_entry($ctx, $eml,
scalar @{$ctx->{msgs}});
my $smsg = shift @{$ctx->{msgs}} or
$ctx->zmore(PublicInbox::View::pagination_footer(
sub mset_thread_i {
my ($ctx, $eml) = @_;
$ctx->zmore($ctx->html_top) if exists $ctx->{-html_tip};
- $eml and return PublicInbox::View::eml_entry($ctx, $ctx->{smsg}, $eml,
+ $eml and return PublicInbox::View::eml_entry($ctx, $eml,
scalar @{$ctx->{msgs}});
my $smsg = shift @{$ctx->{msgs}} or
$ctx->zmore(${delete($ctx->{skel})});
# Displays the text of of the message for /$INBOX/$MSGID/[Tt]/ endpoint
# this is already inside a <pre>
sub eml_entry {
- my ($ctx, $smsg, $eml, $more) = @_;
+ my ($ctx, $eml, $more) = @_;
+ my $smsg = delete $ctx->{smsg};
my $subj = delete $smsg->{subject};
my $mid_raw = $smsg->{mid};
my $id = id_compress($mid_raw, 1);
}
sub thread_eml_entry {
- my ($ctx, $level, $smsg, $eml) = @_;
- my ($beg, $end) = thread_adj_level($ctx, $level);
- $beg . '<pre>' . eml_entry($ctx, $smsg, $eml, 0) . '</pre>' . $end;
+ my ($ctx, $eml) = @_;
+ my ($beg, $end) = thread_adj_level($ctx, $ctx->{level});
+ $beg . '<pre>' . eml_entry($ctx, $eml, 0) . '</pre>' . $end;
}
sub next_in_queue ($$) {
my ($ctx, $eml) = @_;
if ($eml) {
- my ($level, $smsg) = delete @$ctx{qw(level smsg)};
if ($ctx->{nr} == 1) {
- $ctx->{-title_html} = ascii_html($smsg->{subject});
+ $ctx->{-title_html} =
+ ascii_html($ctx->{smsg}->{subject});
$ctx->zmore($ctx->html_top);
}
- return thread_eml_entry($ctx, $level, $smsg, $eml);
+ goto &thread_eml_entry; # tail recursion
}
return unless exists($ctx->{skel});
my $ghost_ok = $ctx->{nr}++;
$ctx->{-title_html} = ascii_html($smsg->{subject});
$ctx->zmore($ctx->html_top);
}
- return eml_entry($ctx, $smsg, $eml, scalar @{$ctx->{msgs}});
+ return eml_entry($ctx, $eml, scalar @{$ctx->{msgs}});
} else {
while (my $smsg = shift @{$ctx->{msgs}}) {
return $smsg if exists($smsg->{blob});