From: Eric Wong Date: Sat, 22 Aug 2015 11:41:20 +0000 (+0000) Subject: view: misc cleanups and simplifications X-Git-Tag: v1.0.0~1004 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=c84813e43031f0683cbbb53ca033926cd4848737;p=public-inbox.git view: misc cleanups and simplifications Less code should be easier-to-read. --- diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 4e015070..922e8e93 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; }