X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=blobdiff_plain;f=lib%2FPublicInbox%2FView.pm;h=040604b08b926552aa797725e3960bebeeacb0ee;hp=83b622fbde0cc43dd9f6b83ce26ef7ef5fe090ab;hb=c44a47c6d3463e35c68ab570cf286068f6b6657d;hpb=021b862ac94f1c226f0778a336d4f3d566b86f9b
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 83b622fb..040604b0 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -385,7 +385,8 @@ sub _th_index_lite {
$rv .= $pad ."$s_s, $s_c; $ctx->{s_nr}\n";
}
-sub walk_thread {
+# non-recursive thread walker
+sub walk_thread ($$$) {
my ($rootset, $ctx, $cb) = @_;
my @q = map { (0, $_, -1) } @$rootset;
while (@q) {
@@ -398,7 +399,7 @@ sub walk_thread {
}
}
-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);
@@ -412,7 +413,7 @@ sub thread_index_entry {
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;
@@ -425,7 +426,7 @@ sub stream_thread_i { # PublicInbox::WwwStream::getline callback
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 ($$) {
@@ -449,6 +450,7 @@ sub stream_thread ($$) {
PublicInbox::WwwStream->response($ctx, 200, \&stream_thread_i);
}
+# /$INBOX/$MESSAGE_ID/t/
sub thread_html {
my ($ctx) = @_;
my $mid = $ctx->{mid};
@@ -465,7 +467,7 @@ sub thread_html {
$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);
@@ -477,7 +479,7 @@ sub thread_html {
# 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 .= '';
return stream_thread($rootset, $ctx) unless $ctx->{flat};
@@ -501,7 +503,7 @@ sub thread_html_i { # PublicInbox::WwwStream::getline callback
$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;
}
@@ -722,7 +724,7 @@ sub _msg_html_prepare {
}
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);
@@ -732,21 +734,21 @@ sub thread_skel {
qq(Atom feed);
my $parent = in_reply_to($hdr);
- $$dst .= "\nThread overview: ";
+ $$skel .= "\nThread overview: ";
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! top\n!;
+ $$skel .= "$nr+ messages / $expand";
+ $$skel .= qq! top\n!;
# nb: mutt only shows the first Subject in the index pane
# when multiple Subject: headers are present, so we follow suit:
@@ -756,11 +758,11 @@ sub thread_skel {
$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;
}
@@ -804,11 +806,11 @@ sub html_footer {
my $ibx = $ctx->{-inbox} if $ctx;
my $upfx = '../';
my $tpfx = '';
- my $idx = $standalone ? " index" : '';
+ my $skel = $standalone ? " index" : '';
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 = ' ';
@@ -843,7 +845,7 @@ sub html_footer {
}
$rhref ||= '#R';
$irt .= qq(reply);
- $irt .= $idx;
+ $irt .= $skel;
}
sub linkify_ref_no_over {
@@ -911,7 +913,7 @@ sub thread_results {
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);
@@ -948,16 +950,16 @@ sub dedupe_subject {
$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);
@@ -986,7 +988,7 @@ sub skel_dump {
if ($cur) {
if ($cur eq $mid) {
delete $ctx->{cur};
- $$dst .= "$d".
+ $$skel .= "$d".
"$attr [this message]\n";
return 1;
} else {
@@ -1026,7 +1028,7 @@ sub skel_dump {
} else {
$m = $ctx->{-upfx}.mid_escape($mid).'/';
}
- $$dst .= $d . "" . $end;
+ $$skel .= $d . "" . $end;
1;
}
@@ -1051,8 +1053,7 @@ sub _skel_ghost {
} else {
$d .= qq{<$html>\n};
}
- my $dst = $ctx->{dst};
- $$dst .= $d;
+ ${$ctx->{skel}} .= $d;
1;
}
@@ -1065,7 +1066,7 @@ sub sort_ds {
# 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);
@@ -1231,9 +1232,9 @@ sub index_topics {
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 {