-# Copyright (C) 2014-2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2014-2020 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
#
# Used for displaying the HTML web interface.
my $more = $ctx->{more};
if ($nr == 1) {
# $more cannot be true w/o $smsg being defined:
- my $upfx = $more ? '../'.mid_escape($ctx->{smsg}->mid).'/' : '';
- multipart_text_as_html(delete $ctx->{mime}, $upfx, $ctx);
+ $ctx->{mhref} = $more ? '../'.mid_escape($ctx->{smsg}->mid).'/'
+ : '';
+ multipart_text_as_html(delete $ctx->{mime}, $ctx);
${delete $ctx->{obuf}} .= '</pre><hr>';
} elsif ($more) {
++$ctx->{end_nr};
my $next = $ibx->over->next_by_mid($ctx->{mid}, \$id, \$prev);
$ctx->{more} = $next ? [ $id, $prev, $next ] : undef;
return '' unless $smsg;
- my $upfx = '../' . mid_escape($smsg->mid) . '/';
+ $ctx->{mhref} = '../' . mid_escape($smsg->mid) . '/';
my $mime = delete $smsg->{mime};
_msg_page_prepare_obuf($mime->header_obj, $ctx, $nr);
- multipart_text_as_html($mime, $upfx, $ctx);
+ multipart_text_as_html($mime, $ctx);
${delete $ctx->{obuf}} .= '</pre><hr>';
}
}
sub multipart_text_as_html {
- my (undef, $mhref, $ctx) = @_; # $mime = $_[0]
- $ctx->{mhref} = $mhref;
+ # ($mime, $ctx) = @_; # msg_iter will do "$_[0] = undef"
# scan through all parts, looking for displayable text
- msg_iter($_[0], \&add_text_body, $ctx, 1);
+ msg_iter($_[0], \&add_text_body, $_[1], 1);
}
sub flush_quote {
my ($s, $l, $quot) = @_;
- # show everything in the full version with anchor from
- # short version (see above)
- my $rv = $l->linkify_1($$quot);
+ my $rv = $l->to_html($$quot);
# we use a <span> here to allow users to specify their own
# color for quoted text
- $rv = $l->linkify_2(ascii_html($rv));
$$quot = undef;
$$s .= qq(<span\nclass="q">) . $rv . '</span>'
}
$idx[0] = $upfx . $idx[0] if $upfx ne '';
$ctx->{-apfx} = join('/', @idx);
$ctx->{-anchors} = {}; # attr => filename
- $ctx->{-diff} = $diff = [];
+ $diff = 1;
delete $ctx->{-long_path};
my $spfx;
if ($ibx->{-repo_objs}) {
attach_link($ctx, $ct, $p, $fn, $err);
$$rv .= "\n";
}
- my $l = PublicInbox::Linkify->new;
+ my $l = $ctx->{-linkify} //= PublicInbox::Linkify->new;
foreach my $cur (@sections) {
if ($cur =~ /\A>/) {
flush_quote($rv, $l, \$cur);
} elsif ($diff) {
- @$diff = split(/^/m, $cur);
- $cur = undef;
- flush_diff($rv, $ctx, $l);
+ flush_diff($rv, $ctx, \$cur);
} else {
# regular lines, OK
- $l->linkify_1($cur);
- $$rv .= $l->linkify_2(ascii_html($cur));
+ $$rv .= $l->to_html($cur);
$cur = undef;
}
}