]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/View.pm
*view: avoid leading zero in time display of the hour
[public-inbox.git] / lib / PublicInbox / View.pm
index ce97f6152376ec4b591f87208d107965e55063fa..2506c95417fc267b6e6436ca0e0bf7175922104b 100644 (file)
@@ -1,5 +1,8 @@
 # Copyright (C) 2014-2015 all contributors <meta@public-inbox.org>
 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
+#
+# Used for displaying the HTML web interface.
+# See Documentation/design_www.txt for this.
 package PublicInbox::View;
 use strict;
 use warnings;
@@ -107,7 +110,7 @@ sub index_entry {
        }
        $rv .= "<td\nid=s$midx>" . PRE_WRAP;
        $rv .= "<b\nid=\"$id\">$subj</b>\n";
-       $rv .= "- by $from @ $ts UTC - ";
+       $rv .= "- $from @ $ts UTC - ";
        $rv .= "<a\nhref=\"#s$next\">next</a>";
        if ($prev >= 0) {
                $rv .= "/<a\nhref=\"#s$prev\">prev</a>";
@@ -460,15 +463,17 @@ sub thread_inline {
        my $mid = mid_clean($cur->header('Message-ID'));
        my $res = $srch->get_thread($mid);
        my $nr = $res->{total};
+       my $upfx = $full_pfx ? '' : '../';
+       my $expand = "(<a\nhref=\"${upfx}t/#u\">expand</a> " .
+                       "/ <a\nhref=\"${upfx}t.mbox.gz\">mbox.gz</a>)";
 
        if ($nr <= 1) {
-               $$dst .= "\n[no followups, yet]\n";
+               $$dst .= "\n[no followups, yet] $expand\n";
                return (undef, in_reply_to($cur));
        }
-       my $upfx = $full_pfx ? '' : '../';
 
-       $$dst .= "\n\n~$nr messages in thread: ".
-                "(<a\nhref=\"${upfx}t/#u\">expand</a>)\n";
+       $$dst .= "\n\n~$nr messages in thread: $expand\n";
+
        my $subj = $srch->subject_path($cur->header('Subject'));
        my $parent = in_reply_to($cur);
        my $state = {
@@ -707,9 +712,11 @@ sub missing_thread {
 sub _msg_date {
        my ($mime) = @_;
        my $ts = $mime->header('X-PI-TS') || msg_timestamp($mime);
-       POSIX::strftime('%Y-%m-%d %H:%M', gmtime($ts));
+       fmt_ts($ts);
 }
 
+sub fmt_ts { POSIX::strftime('%Y-%m-%d %k:%M', gmtime($_[0])) }
+
 sub _inline_header {
        my ($dst, $state, $upfx, $mime, $level) = @_;
        my $pfx = INDENT x ($level - 1);
@@ -814,8 +821,9 @@ sub add_topic {
                $topic = $subj;
 
                # kill "[PATCH v2]" etc. for summarization
-               $topic =~ s/\A\s*\[[^\]]+\]\s*//g;
-               $topic = substr($topic, 0, 30);
+               unless ($level == 0) {
+                       $topic =~ s/\A\s*\[[^\]]+\]\s*//g;
+               }
 
                if (++$state->{subjs}->{$topic} == 1) {
                        push @{$state->{order}}, [ $level, $subj, $topic ];
@@ -859,7 +867,7 @@ sub dump_topics {
                $dst .= "$nl$pfx$dot<a\nhref=\"$mid/t/#u\"><b>$subj</b></a>\n";
 
                my $attr;
-               $ts = POSIX::strftime('%Y-%m-%d %H:%M', gmtime($ts));
+               $ts = fmt_ts($ts);
                if ($n == 1) {
                        $attr = "@ $ts UTC";
                        $n = "";
@@ -875,8 +883,7 @@ sub dump_topics {
                                   qq(href="$mid/t.mbox.gz">mbox.gz</a>);
                        my $atom = qq(<a\nhref="$mid/t.atom">Atom</a>);
                        $pfx .= INDENT if $level > 0;
-                       $dst .= "$pfx- ". $attr . $n;
-                       $dst .= " - $mbox / $atom\n";
+                       $dst .= $pfx . $attr . $n . " - $mbox / $atom\n";
                        $prev_attr = $attr;
                }
        }