user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] view: add links for mbox and atom feeds in homepage
Date: Sun,  4 Oct 2015 00:20:24 +0000	[thread overview]
Message-ID: <20151004002024.18759-1-e@80x24.org> (raw)

Having per-thread Atom feeds and downloadable mboxen is powerful
and should be more easily visible/accessible to casual readers.
---
 lib/PublicInbox/View.pm | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index c9be770..beb9989 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -12,6 +12,7 @@ use PublicInbox::Hval;
 use PublicInbox::MID qw/mid_clean id_compress mid2path/;
 use Digest::SHA qw/sha1_hex/;
 my $SALT = rand;
+my $MBOX_TITLE = 'title="download thread as gzipped mbox"';
 require POSIX;
 
 # TODO: make these constants tunable
@@ -198,7 +199,8 @@ sub emit_thread_html {
 	my $next = "<a\nid=\"s$final_anchor\">";
 	$next .= $final_anchor == 1 ? 'only message in' : 'end of';
 	$next .= " thread</a>, back to <a\nhref=\"../../\">index</a>";
-	$next .= "\ndownload thread: <a\nhref=\"../t.mbox.gz\">mbox.gz</a>";
+	$next .= "\ndownload thread: ";
+	$next .= "<a\n$MBOX_TITLE\nhref=\"../t.mbox.gz\">mbox.gz</a>";
 	$next .= " / follow: <a\nhref=\"../t.atom\">Atom feed</a>";
 	$cb->write("<hr />" . PRE_WRAP . $next . "\n\n". $foot .
 		   "</pre></body></html>");
@@ -862,17 +864,21 @@ sub dump_topics {
 		$ts = POSIX::strftime('%Y-%m-%d %H:%M', gmtime($ts));
 		if ($n == 1) {
 			$attr = "created by $u @ $ts UTC";
-			$n = "\n";
+			$n = "";
 		} else {
 			# $n isn't the total number of posts on the topic,
 			# just the number of posts in the current results
 			# window, so leave it unlabeled
 			$attr = "updated by $u @ $ts UTC";
-			$n = " ($n)\n";
+			$n = " ($n)";
 		}
 		if ($level == 0 || $attr ne $prev_attr) {
+			my $mbox = qq(<a\n$MBOX_TITLE\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";
 			$prev_attr = $attr;
 		}
 	}
-- 
EW


                 reply	other threads:[~2015-10-04  0:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message 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: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151004002024.18759-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).