]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/View.pm
view: do not shorten top-level messages in thread view
[public-inbox.git] / lib / PublicInbox / View.pm
index de2d667c91f7612e30d4023e3d5131302caad6dc..9ca4a6a419ab49e1b1c488783d880b36df5fe92f 100644 (file)
@@ -117,7 +117,7 @@ sub index_entry {
        my $mhref = "${path}$href/";
 
        # show full message if it's our root message
-       if ($root_anchor ne $id) {
+       if ($root_anchor ne $id || ($level != 0 && !$ctx->{flat})) {
                $fhref = "${path}$href/f/";
                $more_ref = \$more;
        }
@@ -410,7 +410,7 @@ sub headers_to_html_header {
        my $mid = $header_obj->header('Message-ID');
        $mid = PublicInbox::Hval->new_msgid($mid);
        foreach my $h (qw(From To Cc Subject Date)) {
-               my $v = $mime->header($h);
+               my $v = $header_obj->header($h);
                defined($v) && ($v ne '') or next;
                $v = PublicInbox::Hval->new_oneline($v);
 
@@ -432,15 +432,24 @@ sub headers_to_html_header {
        $rv .= 'Message-ID: <' . $mid->as_html . '> ';
        my $upfx = $full_pfx ? '' : '../';
        $rv .= "(<a\nhref=\"${upfx}raw\">raw</a>)\n";
+       my $atom;
        if ($srch) {
-               $rv .= "<a\nhref=\"${upfx}t/\">References: [expand]</a>\n";
+               if ($header_obj->header('In-Reply-To') ||
+                   $header_obj->header('References')) {
+                       $rv .= "<a\nhref=\"${upfx}t/#u\">" .
+                               "References: [expand]</a>\n";
+               }
+
+               $atom = qq{<link\nrel=alternate\ntitle="Atom feed"\n} .
+                       qq!href="${upfx}t.atom"\ntype="application/atom+xml"/>!;
        } else {
                $rv .= _parent_headers_nosrch($header_obj);
+               $atom = '';
        }
        $rv .= "\n";
 
        ("<html><head><title>".  join(' - ', @title) .
-        '</title></head><body>' . PRE_WRAP . $rv);
+        "</title>$atom</head><body>" . PRE_WRAP . $rv);
 }
 
 sub thread_inline {
@@ -540,6 +549,10 @@ sub html_footer {
        my $srch = $ctx->{srch} if $ctx;
        my $upfx = $full_pfx ? '../' : '../../';
        my $idx = $standalone ? " <a\nhref=\"$upfx\">index</a>" : '';
+
+       if ($srch && $standalone) {
+               $idx .= qq{ / follow: <a\nhref="t.atom">Atom feed</a>};
+       }
        if ($idx && $srch) {
                my ($next, $p) = thread_inline(\$idx, $ctx, $mime, $full_pfx);
                if (defined $p) {
@@ -578,12 +591,15 @@ sub anchor_for {
 }
 
 sub thread_html_head {
-       my ($cb, $mime) = @_;
+       my ($cb, $header, $state) = @_;
        $$cb = $$cb->([200, ['Content-Type'=> 'text/html; charset=UTF-8']]);
 
-       my $s = PublicInbox::Hval->new_oneline($mime->header('Subject'));
+       my $s = PublicInbox::Hval->new_oneline($header->header('Subject'));
        $s = $s->as_html;
-       $$cb->write("<html><head><title>$s</title></head><body>");
+       $$cb->write("<html><head><title>$s</title>".
+               qq{<link\nrel=alternate\ntitle="Atom feed"\n} .
+               qq!href="../t.atom"\ntype="application/atom+xml"/>! .
+               "</head><body>");
 }
 
 sub pre_anchor_entry {