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=-3.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 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 64FFC1FAC8 for ; Sat, 22 Aug 2015 11:41:24 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/6] view: misc cleanups and simplifications Date: Sat, 22 Aug 2015 11:41:20 +0000 Message-Id: <1440243684-2205-2-git-send-email-e@80x24.org> In-Reply-To: <1440243684-2205-1-git-send-email-e@80x24.org> References: <1440243684-2205-1-git-send-email-e@80x24.org> List-Id: Less code should be easier-to-read. --- lib/PublicInbox/View.pm | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 4e01507..922e8e9 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -93,8 +93,7 @@ sub index_entry { unless (defined $ts) { $ts = msg_timestamp($mime); } - my $fmt = '%Y-%m-%d %H:%M'; - $ts = POSIX::strftime($fmt, gmtime($ts)); + $ts = POSIX::strftime('%Y-%m-%d %H:%M', gmtime($ts)); my $rv = ""; if ($level) { @@ -167,14 +166,8 @@ sub emit_thread_html { } my $final_anchor = $state->[3]; my $next = ""; - - if ($final_anchor == 1) { - $next .= 'only message in thread'; - } else { - $next .= 'end of thread'; - } - $next .= ", back to index\n"; - + $next .= $final_anchor == 1 ? 'only message in' : 'end of'; + $next .= " thread, back to index\n"; $fh->write("
" . PRE_WRAP . $next . $foot . ""); $fh->close; @@ -258,9 +251,9 @@ sub flush_quote { if ($full_pfx) { if (!$final && scalar(@$quot) <= MAX_INLINE_QUOTED) { # show quote inline - my $rv = join("\n", map { linkify($_); $_ } @$quot); + my $rv = join('', map { linkify($_); $_ } @$quot); @$quot = (); - return $rv . "\n"; + return $rv; } # show a short snippet of quoted text and link to full version: @@ -286,7 +279,7 @@ sub flush_quote { # short version (see above) my $nr = ++$$n; my $rv = ""; - $rv .= join("\n", map { linkify($_); $_ } @$quot) . "\n"; + $rv .= join('', map { linkify($_); $_ } @$quot); @$quot = (); $rv; } @@ -309,7 +302,7 @@ sub add_text_body { $part->body_set(''); $s = $enc->decode($s); $s = ascii_html($s); - my @lines = split(/\n/, $s); + my @lines = split(/^/m, $s); $s = ''; if ($$part_nr > 0) { @@ -330,7 +323,6 @@ sub add_text_body { # regular line, OK linkify($cur); $s .= $cur; - $s .= "\n"; } else { push @quot, $cur; } -- EW