use PublicInbox::Linkify;
use PublicInbox::MID qw/id_compress mid_escape mids mids_for_index references/;
use PublicInbox::MsgIter;
use PublicInbox::Linkify;
use PublicInbox::MID qw/id_compress mid_escape mids mids_for_index references/;
use PublicInbox::MsgIter;
# $more cannot be true w/o $smsg being defined:
my $upfx = $more ? '../'.mid_escape($ctx->{smsg}->mid).'/' : '';
$ctx->{tip} .
# $more cannot be true w/o $smsg being defined:
my $upfx = $more ? '../'.mid_escape($ctx->{smsg}->mid).'/' : '';
$ctx->{tip} .
} elsif ($more && @$more) {
++$ctx->{end_nr};
msg_html_more($ctx, $more, $nr);
} elsif ($more && @$more) {
++$ctx->{end_nr};
msg_html_more($ctx, $more, $nr);
- eval {
- my $hdr = delete($ctx->{mime})->header_obj;
- '<pre>' . html_footer($hdr, 1, $ctx) .
- '</pre>' . msg_reply($ctx, $hdr)
- };
+ eval { html_footer($ctx) };
my ($ctx, $mime, $more, $smsg) = @_;
my $ibx = $ctx->{-inbox};
$ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef;
my ($ctx, $mime, $more, $smsg) = @_;
my $ibx = $ctx->{-inbox};
$ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef;
- $ctx->{tip} = _msg_html_prepare($mime->header_obj, $ctx, $more, 0);
+ my $hdr = $ctx->{hdr} = $mime->header_obj;
+ $ctx->{tip} = _msg_html_prepare($hdr, $ctx, $more, 0);
my $next = $ibx->over->next_by_mid($mid, \$id, \$prev);
@$more = $next ? ($id, $prev, $next) : ();
if ($smsg) {
my $next = $ibx->over->next_by_mid($mid, \$id, \$prev);
@$more = $next ? ($id, $prev, $next) : ();
if ($smsg) {
_msg_html_prepare($mime->header_obj, $ctx, $more, $nr) .
multipart_text_as_html($mime, $upfx, $ctx) .
'</pre><hr>'
_msg_html_prepare($mime->header_obj, $ctx, $more, $nr) .
multipart_text_as_html($mime, $upfx, $ctx) .
'</pre><hr>'
# this is already inside a <pre>
sub index_entry {
my ($smsg, $ctx, $more) = @_;
# this is already inside a <pre>
sub index_entry {
my ($smsg, $ctx, $more) = @_;
- my $ibx = $ctx->{-inbox};
- msg_iter($mime, sub { $rv .= add_text_body($mhref, $ctx, $_[0]) });
+ $ctx->{mhref} = $mhref;
+ $ctx->{rv} = \$rv;
+ msg_iter($mime, \&add_text_body, $ctx, 1);
+ delete $ctx->{rv};
my ($rootset, $ctx, $cb) = @_;
my @q = map { (0, $_, -1) } @$rootset;
while (@q) {
my ($rootset, $ctx, $cb) = @_;
my @q = map { (0, $_, -1) } @$rootset;
while (@q) {
my ($ctx, $level, $node, $idx) = @_;
$ctx->{mapping}->{$node->{id}} = [ '', $node, $idx, $level ];
skel_dump($ctx, $level, $node);
my ($ctx, $level, $node, $idx) = @_;
$ctx->{mapping}->{$node->{id}} = [ '', $node, $idx, $level ];
skel_dump($ctx, $level, $node);
$ctx->{-inbox}->smsg_mime($smsg) or next;
return index_entry($smsg, $ctx, scalar @$msgs);
}
$ctx->{-inbox}->smsg_mime($smsg) or next;
return index_entry($smsg, $ctx, scalar @$msgs);
}
- my ($mime, $upfx, $ctx) = @_;
- my $rv = "";
+ my (undef, $mhref, $ctx) = @_; # $mime = $_[0]
+ $ctx->{mhref} = $mhref;
+ $ctx->{rv} = \(my $rv = '');
- msg_iter($mime, sub { $rv .= add_text_body($upfx, $ctx, $_[0]) });
- $rv;
+ msg_iter($_[0], \&add_text_body, $ctx, 1);
+ ${delete $ctx->{rv}};
- my ($upfx, $ct, $p, $fn, $err) = @_;
+ my ($ctx, $ct, $p, $fn, $err) = @_;
my ($part, $depth, @idx) = @$p;
my $nl = $idx[-1] > 1 ? "\n" : '';
my $idx = join('.', @idx);
my ($part, $depth, @idx) = @$p;
my $nl = $idx[-1] > 1 ? "\n" : '';
my $idx = join('.', @idx);
my $ts = "Type: $ct, Size: $size bytes";
$desc = ascii_html($desc);
my $ts = "Type: $ct, Size: $size bytes";
$desc = ascii_html($desc);
# $p - from msg_iter: [ Email::MIME, depth, @idx ]
my ($part, $depth, @idx) = @$p;
my $ct = $part->content_type || 'text/plain';
my $fn = $part->filename;
my ($s, $err) = msg_part_text($part, $ct);
# $p - from msg_iter: [ Email::MIME, depth, @idx ]
my ($part, $depth, @idx) = @$p;
my $ct = $part->content_type || 'text/plain';
my $fn = $part->filename;
my ($s, $err) = msg_part_text($part, $ct);
-
- return attach_link($upfx, $ct, $p, $fn) unless defined $s;
+ return attach_link($ctx, $ct, $p, $fn) unless defined $s;
# makes no difference to browsers, and don't screw up filename
# link generation in diffs with the extra '%0D'
# makes no difference to browsers, and don't screw up filename
# link generation in diffs with the extra '%0D'
# split off quoted and unquoted blocks:
my @sections = split(/((?:^>[^\n]*\n)+)/sm, $s);
$s = '';
# split off quoted and unquoted blocks:
my @sections = split(/((?:^>[^\n]*\n)+)/sm, $s);
$s = '';
if (defined($fn) || $depth > 0 || $err) {
# badly-encoded message with $err? tell the world about it!
if (defined($fn) || $depth > 0 || $err) {
# badly-encoded message with $err? tell the world about it!
- $s .= attach_link($upfx, $ct, $p, $fn, $err);
- $s .= "\n";
+ attach_link($ctx, $ct, $p, $fn, $err);
+ $$rv .= "\n";
-sub thread_skel {
- my ($dst, $ctx, $hdr, $tpfx) = @_;
+sub SKEL_EXPAND () {
+ qq(expand[<a\nhref="T/#u">flat</a>) .
+ qq(|<a\nhref="t/#u">nested</a>] ) .
+ qq(<a\nhref="t.mbox.gz">mbox.gz</a> ) .
+ qq(<a\nhref="t.atom">Atom feed</a>);
+}
+
+sub thread_skel ($$$) {
+ my ($skel, $ctx, $hdr) = @_;
my $mid = mids($hdr)->[0];
my $ibx = $ctx->{-inbox};
my ($nr, $msgs) = $ibx->over->get_thread($mid);
my $mid = mids($hdr)->[0];
my $ibx = $ctx->{-inbox};
my ($nr, $msgs) = $ibx->over->get_thread($mid);
# nb: mutt only shows the first Subject in the index pane
# when multiple Subject: headers are present, so we follow suit:
# nb: mutt only shows the first Subject in the index pane
# when multiple Subject: headers are present, so we follow suit:
- walk_thread(thread_results($ctx, $msgs), $ctx, *skel_dump);
+ walk_thread(thread_results($ctx, $msgs), $ctx, \&skel_dump);
- my ($hdr, $standalone, $ctx, $rhref) = @_;
-
- my $ibx = $ctx->{-inbox} if $ctx;
+ my ($ctx) = @_;
+ my $ibx = $ctx->{-inbox};
+ my $hdr = delete $ctx->{hdr};
- my $tpfx = '';
- my $idx = $standalone ? " <a\nhref=\"$upfx\">index</a>" : '';
- my $irt = '';
- if ($idx && $ibx->over) {
- $idx .= "\n";
- thread_skel(\$idx, $ctx, $hdr, $tpfx);
+ my $skel = " <a\nhref=\"$upfx\">index</a>";
+ my $rv = '<pre>';
+ if ($ibx->over) {
+ $skel .= "\n";
+ thread_skel(\$skel, $ctx, $hdr);
my $idx = $ctx->{found_mid_at};
if (defined($idx) && $idx != 0) {
my $tip = splice(@$rootset, $idx, 1);
my $idx = $ctx->{found_mid_at};
if (defined($idx) && $idx != 0) {
my $tip = splice(@$rootset, $idx, 1);
my ($ctx, $level, $node) = @_;
my $smsg = $node->{smsg} or return _skel_ghost($ctx, $level, $node);
my ($ctx, $level, $node) = @_;
my $smsg = $node->{smsg} or return _skel_ghost($ctx, $level, $node);
# accumulate recent topics if search is supported
# returns 200 if done, 404 if not
# accumulate recent topics if search is supported
# returns 200 if done, 404 if not
my ($ctx, $level, $node) = @_;
my $mid = $node->{id};
my $x = $node->{smsg} || $ctx->{-inbox}->smsg_by_mid($mid);
my ($ctx, $level, $node) = @_;
my $mid = $node->{id};
my $x = $node->{smsg} || $ctx->{-inbox}->smsg_by_mid($mid);
sub str2ts ($) {
my ($yyyy, $mon, $dd, $hh, $mm, $ss) = unpack('A4A2A2A2A2A2', $_[0]);
sub str2ts ($) {
my ($yyyy, $mon, $dd, $hh, $mm, $ss) = unpack('A4A2A2A2A2A2', $_[0]);
- walk_thread(thread_results($ctx, $msgs), $ctx, *acc_topic);
+ walk_thread(thread_results($ctx, $msgs), $ctx, \&acc_topic);