# 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;
}
$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>";
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 = {
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);
$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 ];
$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 = "";
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;
}
}