]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/View.pm
www: label sections and hopefully improve navigation
[public-inbox.git] / lib / PublicInbox / View.pm
index 5a312d84ba8d14e45cee9fac410440736aefca47..5f99644f8abaaebf630624c587b1b835dcd52058 100644 (file)
@@ -51,14 +51,22 @@ sub msg_reply {
        my $p_url =
         'https://en.wikipedia.org/wiki/Posting_style#Interleaved_style';
 
+       my $info = '';
+       if (my $url = $ctx->{-inbox}->{infourl}) {
+               $url = PublicInbox::Hval::prurl($ctx->{env}, $url);
+               $info = qq(\n  List information: <a\nhref="$url">$url</a>\n);
+       }
+
        my ($arg, $link) = mailto_arg_link($hdr);
        push @$arg, '/path/to/YOUR_REPLY';
        $arg = join(" \\\n    ", '', @$arg);
        <<EOF
-<pre
-id=R>You may reply publically to <a
-href=#t>this message</a> via
-plain-text email using any one of the following methods:
+<hr><pre
+id=R><b>Reply instructions:</b>
+
+You may reply publically to <a
+href=#t>this message</a> via plain-text email
+using any one of the following methods:
 
 * Save the following mbox file, import it into your mail client,
   and reply-to-all from there: <a
@@ -67,7 +75,7 @@ href=raw>mbox</a>
   Avoid top-posting and favor interleaved quoting:
   <a
 href="$p_url">$p_url</a>
-
+$info
 * Reply to all the recipients using the <b>--to</b>, <b>--cc</b>,
   and <b>--in-reply-to</b> switches of git-send-email(1):
 
@@ -320,10 +328,12 @@ sub thread_html {
        return missing_thread($ctx) if $nr == 0;
        my $skel = '<hr><pre>';
        $skel .= $nr == 1 ? 'only message in thread' : 'end of thread';
-       $skel .= ", back to <a\nhref=\"../../\">index</a>";
-       $skel .= "\n<a\nid=t>$nr+ messages in thread:</a> (download: ";
-       $skel .= "<a\nhref=\"../t.mbox.gz\">mbox.gz</a>";
+       $skel .= ", back to <a\nhref=\"../../\">index</a>\n\n";
+       $skel .= "<b\nid=t>Thread overview:</b> ";
+       $skel .= $nr == 1 ? '(only message)' : "$nr+ messages";
+       $skel .= " (download: <a\nhref=\"../t.mbox.gz\">mbox.gz</a>";
        $skel .= " / follow: <a\nhref=\"../t.atom\">Atom feed</a>)\n";
+       $skel .= "-- links below jump to the message on this page --\n";
        $ctx->{-upfx} = '../../';
        $ctx->{cur_level} = 0;
        $ctx->{dst} = \$skel;
@@ -517,6 +527,7 @@ sub thread_skel {
                        qq(/ <a\nhref="${tpfx}t.atom">Atom feed</a>);
 
        my $parent = in_reply_to($hdr);
+       $$dst .= "\n<b>Thread overview: </b>";
        if ($nr <= 1) {
                if (defined $parent) {
                        $$dst .= "($expand)\n ";
@@ -879,14 +890,16 @@ sub acc_topic {
 
 sub dump_topics {
        my ($ctx) = @_;
-       my $order = $ctx->{order}; # [ ts, subj1, subj2, subj3, ... ]
+       my $order = delete $ctx->{order}; # [ ts, subj1, subj2, subj3, ... ]
        if (!@$order) {
                $ctx->{-html_tip} = '<pre>[No topics in range]</pre>';
                return 404;
        }
 
        my @out;
-       foreach my $topic (@$order) {
+
+       # sort by recency, this allows new posts to "bump" old topics...
+       foreach my $topic (sort { $b->[0] <=> $a->[0] } @$order) {
                my ($ts, $n, $seen, $top, @ex) = @$topic;
                @$topic = ();
                next unless defined $top;  # ghost topic
@@ -897,11 +910,18 @@ sub dump_topics {
 
                # $n isn't the total number of posts on the topic,
                # just the number of posts in the current results window
-               $n = $n == 1 ? '' : " ($n+ messages)";
+               my $anchor;
+               if ($n == 1) {
+                       $n = '';
+                       $anchor = '#u'; # top of only message
+               } else {
+                       $n = " ($n+ messages)";
+                       $anchor = '#t'; # thread skeleton
+               }
 
                my $mbox = qq(<a\nhref="$href/t.mbox.gz">mbox.gz</a>);
                my $atom = qq(<a\nhref="$href/t.atom">Atom</a>);
-               my $s = "<a\nhref=\"$href/T/#t\"><b>$top</b></a>\n" .
+               my $s = "<a\nhref=\"$href/T/$anchor\"><b>$top</b></a>\n" .
                        " $ts UTC $n - $mbox / $atom\n";
                for (my $i = 0; $i < scalar(@ex); $i += 2) {
                        my $level = $ex[$i];