From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.8 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EFCB1201CD for ; Wed, 30 Dec 2015 01:42:26 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [REJECT] view: use
    /
  • for threading instead of tables Date: Wed, 30 Dec 2015 01:42:26 +0000 Message-Id: <20151230014226.27351-1-e@80x24.org> List-Id: Rejecting this for now since it eats precious horizontal whitespace on browsers that can render indentation properly; and this still doesn't render thread levels properly on lynx. --- lib/PublicInbox/View.pm | 53 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index ad90eb3..be92e9f 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -103,11 +103,7 @@ sub index_entry { } my $ts = _msg_date($mime); - my $rv = ""; - if ($level) { - $rv .= '
    ' . (INDENT x $level) . '
    '; - } - $rv .= "
    ";
    +	my $rv = "";
     	$rv .= "$subj\n";
     	$rv .= "- $from @ $ts UTC - ";
     	$rv .= "next";
    @@ -155,8 +151,7 @@ sub index_entry {
     				"flat]";
     		}
     	}
    -
    -	$fh->write($rv .= '
    '); + $fh->write($rv .= ''); } sub thread_html { @@ -181,16 +176,20 @@ sub emit_thread_html { seen => $seen, root_anchor => anchor_for($mid), anchor_idx => 0, + max_level => 0, }; require PublicInbox::Git; my $git = $ctx->{git} ||= PublicInbox::Git->new($ctx->{git_dir}); if ($flat) { pre_anchor_entry($seen, $_) for (@$msgs); - __thread_entry(\$cb, $git, $state, $_, 0) for (@$msgs); + __thread_entry(\$cb, $git, $state, $_, -1) for (@$msgs); } else { my $th = thread_results($msgs); thread_entry(\$cb, $git, $state, $_, 0) for $th->rootset; + my $max = $state->{max_level}; + $cb->write('
' x $max) if $max; + $cb->write(''); } $git = undef; Email::Address->purge_cache; @@ -608,7 +607,7 @@ sub anchor_for { } sub thread_html_head { - my ($cb, $header, $state) = @_; + my ($cb, $header, $state, $level) = @_; $$cb = $$cb->([200, ['Content-Type'=> 'text/html; charset=UTF-8']]); my $s = PublicInbox::Hval->new_oneline($header->header('Subject')); @@ -617,7 +616,7 @@ sub thread_html_head { qq{! . PublicInbox::Hval::STYLE . - ""); + '' . ($level >= 0 ? '
    ' : '')); } sub pre_anchor_entry { @@ -637,12 +636,26 @@ sub ghost_parent { qq{[parent not found: <$html>]}; } -sub ghost_table { - my ($upfx, $mid, $level) = @_; - "" . - (INDENT x $level) . '
    ' .
    -		ghost_parent($upfx, $mid) .
    -		'
    '; +sub __thread_adj_level { + my ($cb, $state, $level) = @_; + + return if $level < 0; # flat output + + if ($level > $state->{max_level}) { + $state->{max_level} = $level; + $$cb->write('
    • '); + } else { + $$cb->write('
    • '); + } +} + +sub __thread_ghost { + my ($cb, $state, $upfx, $mid, $level) = @_; + + __thread_adj_level($cb, $state, $level); + + $$cb->write('
      ' .  ghost_parent($upfx, $mid) . '
      ' . + ($level >= 0 ? '' : '
    • ')); } sub __thread_entry { @@ -655,16 +668,20 @@ sub __thread_entry { } or return; if ($state->{anchor_idx} == 0) { - thread_html_head($cb, $mime, $state); + thread_html_head($cb, $mime, $state, $level); } if (my $ghost = delete $state->{ghost}) { # n.b. ghost messages may only be parents, not children foreach my $g (@$ghost) { - $$cb->write(ghost_table('../../', @$g)); + __thread_ghost($cb, $state, '../../', @$g); } } + __thread_adj_level($cb, $state, $level); + index_entry($$cb, $mime, $level, $state); + $$cb->write(''); + 1; } -- EW