$rv .= $pad ."<a\nhref=#r$id>$s_s, $s_c; $ctx->{s_nr}</a>\n";
}
-sub walk_thread {
+# non-recursive thread walker
+sub walk_thread ($$$) {
my ($rootset, $ctx, $cb) = @_;
my @q = map { (0, $_, -1) } @$rootset;
while (@q) {
}
}
-sub pre_thread {
+sub pre_thread { # walk_thread callback
my ($ctx, $level, $node, $idx) = @_;
$ctx->{mapping}->{$node->{id}} = [ '', $node, $idx, $level ];
skel_dump($ctx, $level, $node);
sub stream_thread_i { # PublicInbox::WwwStream::getline callback
my ($nr, $ctx) = @_;
- return unless exists($ctx->{dst});
+ return unless exists($ctx->{skel});
my $q = $ctx->{-queue};
while (@$q) {
my $level = shift @$q;
return ghost_index_entry($ctx, $level, $node);
}
}
- join('', thread_adj_level($ctx, 0)) . ${delete $ctx->{dst}}; # skel
+ join('', thread_adj_level($ctx, 0)) . ${delete $ctx->{skel}};
}
sub stream_thread ($$) {
PublicInbox::WwwStream->response($ctx, 200, \&stream_thread_i);
}
+# /$INBOX/$MESSAGE_ID/t/
sub thread_html {
my ($ctx) = @_;
my $mid = $ctx->{mid};
$skel .= "-- links below jump to the message on this page --\n";
$ctx->{-upfx} = '../../';
$ctx->{cur_level} = 0;
- $ctx->{dst} = \$skel;
+ $ctx->{skel} = \$skel;
$ctx->{prev_attr} = '';
$ctx->{prev_level} = 0;
$ctx->{root_anchor} = anchor_for($mid);
# reduce hash lookups in pre_thread->skel_dump
$ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef;
- walk_thread($rootset, $ctx, *pre_thread);
+ walk_thread($rootset, $ctx, \&pre_thread);
$skel .= '</pre>';
return stream_thread($rootset, $ctx) unless $ctx->{flat};
$ctx->{-inbox}->smsg_mime($smsg) or next;
return index_entry($smsg, $ctx, scalar @$msgs);
}
- my ($skel) = delete @$ctx{qw(dst msgs)};
+ my ($skel) = delete @$ctx{qw(skel msgs)};
$$skel;
}
}
sub thread_skel {
- my ($dst, $ctx, $hdr, $tpfx) = @_;
+ my ($skel, $ctx, $hdr, $tpfx) = @_;
my $mid = mids($hdr)->[0];
my $ibx = $ctx->{-inbox};
my ($nr, $msgs) = $ibx->over->get_thread($mid);
qq(<a\nhref="${tpfx}t.atom">Atom feed</a>);
my $parent = in_reply_to($hdr);
- $$dst .= "\n<b>Thread overview: </b>";
+ $$skel .= "\n<b>Thread overview: </b>";
if ($nr <= 1) {
if (defined $parent) {
- $$dst .= "$expand\n ";
- $$dst .= ghost_parent("$tpfx../", $parent) . "\n";
+ $$skel .= "$expand\n ";
+ $$skel .= ghost_parent("$tpfx../", $parent) . "\n";
} else {
- $$dst .= "[no followups] $expand\n";
+ $$skel .= "[no followups] $expand\n";
}
$ctx->{next_msg} = undef;
$ctx->{parent_msg} = $parent;
return;
}
- $$dst .= "$nr+ messages / $expand";
- $$dst .= qq! <a\nhref="#b">top</a>\n!;
+ $$skel .= "$nr+ messages / $expand";
+ $$skel .= qq! <a\nhref="#b">top</a>\n!;
# nb: mutt only shows the first Subject in the index pane
# when multiple Subject: headers are present, so we follow suit:
$ctx->{cur} = $mid;
$ctx->{prev_attr} = '';
$ctx->{prev_level} = 0;
- $ctx->{dst} = $dst;
+ $ctx->{skel} = $skel;
# reduce hash lookups in skel_dump
$ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef;
- walk_thread(thread_results($ctx, $msgs), $ctx, *skel_dump);
+ walk_thread(thread_results($ctx, $msgs), $ctx, \&skel_dump);
$ctx->{parent_msg} = $parent;
}
my $ibx = $ctx->{-inbox} if $ctx;
my $upfx = '../';
my $tpfx = '';
- my $idx = $standalone ? " <a\nhref=\"$upfx\">index</a>" : '';
+ my $skel = $standalone ? " <a\nhref=\"$upfx\">index</a>" : '';
my $irt = '';
- if ($idx && $ibx->over) {
- $idx .= "\n";
- thread_skel(\$idx, $ctx, $hdr, $tpfx);
+ if ($skel && $ibx->over) {
+ $skel .= "\n";
+ thread_skel(\$skel, $ctx, $hdr, $tpfx);
my ($next, $prev);
my $parent = ' ';
$next = $prev = ' ';
}
$rhref ||= '#R';
$irt .= qq(<a\nhref="$rhref">reply</a>);
- $irt .= $idx;
+ $irt .= $skel;
}
sub linkify_ref_no_over {
if (defined($mid) && scalar(@$rootset) > 1) {
$ctx->{root_idx} = -1;
my $nr = scalar @$msgs;
- walk_thread($rootset, $ctx, *find_mid_root);
+ walk_thread($rootset, $ctx, \&find_mid_root);
my $idx = $ctx->{found_mid_at};
if (defined($idx) && $idx != 0) {
my $tip = splice(@$rootset, $idx, 1);
$omit;
}
-sub skel_dump {
+sub skel_dump { # walk_thread callback
my ($ctx, $level, $node) = @_;
my $smsg = $node->{smsg} or return _skel_ghost($ctx, $level, $node);
- my $dst = $ctx->{dst};
+ my $skel = $ctx->{skel};
my $cur = $ctx->{cur};
my $mid = $smsg->{mid};
if ($level == 0 && $ctx->{skel_dump_roots}++) {
- $$dst .= delete $ctx->{sl_note} || '';
+ $$skel .= delete($ctx->{sl_note}) || '';
}
my $f = ascii_html($smsg->from_name);
if ($cur) {
if ($cur eq $mid) {
delete $ctx->{cur};
- $$dst .= "<b>$d<a\nid=r\nhref=\"#t\">".
+ $$skel .= "<b>$d<a\nid=r\nhref=\"#t\">".
"$attr [this message]</a></b>\n";
return 1;
} else {
} else {
$m = $ctx->{-upfx}.mid_escape($mid).'/';
}
- $$dst .= $d . "<a\nhref=\"$m\"$id>" . $end;
+ $$skel .= $d . "<a\nhref=\"$m\"$id>" . $end;
1;
}
} else {
$d .= qq{<<a\nhref="$href">$html</a>>\n};
}
- my $dst = $ctx->{dst};
- $$dst .= $d;
+ ${$ctx->{skel}} .= $d;
1;
}
# accumulate recent topics if search is supported
# returns 200 if done, 404 if not
-sub acc_topic {
+sub acc_topic { # walk_thread callback
my ($ctx, $level, $node) = @_;
my $mid = $node->{id};
my $x = $node->{smsg} || $ctx->{-inbox}->smsg_by_mid($mid);
my ($ctx) = @_;
my $msgs = paginate_recent($ctx, 200); # 200 is our window
if (@$msgs) {
- walk_thread(thread_results($ctx, $msgs), $ctx, *acc_topic);
+ walk_thread(thread_results($ctx, $msgs), $ctx, \&acc_topic);
}
- PublicInbox::WwwStream->response($ctx, dump_topics($ctx), *index_nav);
+ PublicInbox::WwwStream->response($ctx, dump_topics($ctx), \&index_nav);
}
sub thread_adj_level {