user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Cc: Eric Wong <e@80x24.org>
Subject: [PATCH 4/5] feed: show permalink to home page
Date: Thu, 28 Aug 2014 02:47:35 +0000	[thread overview]
Message-ID: <1409194056-4735-4-git-send-email-e@80x24.org> (raw)
In-Reply-To: <1409194056-4735-1-git-send-email-e@80x24.org>

This will make it easier to bookmark an index page with threading
context.
---
 lib/PublicInbox/Feed.pm | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index cf64517..1eaba6c 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -59,7 +59,7 @@ sub generate_html_index {
 
 	my @messages;
 	my $git = PublicInbox::GitCatFile->new($args->{git_dir});
-	my $last = each_recent_blob($args, sub {
+	my ($first, $last) = each_recent_blob($args, sub {
 		my $mime = do_cat_mail($git, $_[0]) or return 0;
 
 		my $t = eval { str2time($mime->header('Date')) };
@@ -89,7 +89,7 @@ sub generate_html_index {
 
 	Email::Address->purge_cache;
 
-	my $footer = nav_footer($args->{cgi}, $last, $feed_opts);
+	my $footer = nav_footer($args->{cgi}, $first, $last, $feed_opts);
 	my $list_footer = $args->{footer};
 	$footer .= "\n" . $list_footer if ($footer && $list_footer);
 	$footer = "<hr />" . PRE_WRAP . "$footer</pre>" if $footer;
@@ -99,21 +99,22 @@ sub generate_html_index {
 # private subs
 
 sub nav_footer {
-	my ($cgi, $last, $feed_opts) = @_;
+	my ($cgi, $first, $last, $feed_opts) = @_;
 	$cgi or return '';
 	my $old_r = $cgi->param('r');
 	my $head = '    ';
 	my $next = '    ';
 
 	if ($last) {
-		$next = qq!<a href="?r=$last">next</a>!;
+		$next = qq!<a\nhref="?r=$last">next</a>!;
 	}
 	if ($old_r) {
 		$head = $cgi->path_info;
-		$head = qq!<a href="$head">head</a>!;
+		$head = qq!<a\nhref="$head">head</a>!;
 	}
-	my $atom = "<a href=\"$feed_opts->{atomurl}\">atom</a>";
-	"$next $head $atom";
+	my $atom = "<a\nhref=\"$feed_opts->{atomurl}\">atom</a>";
+	my $permalink = "<a\nhref=\"?r=$first\">permalink</a>";
+	"$next $head $atom $permalink";
 }
 
 sub each_recent_blob {
@@ -174,7 +175,7 @@ sub each_recent_blob {
 
 	close $log; # we may EPIPE here
 	# for pagination
-	$commits[-1];
+	($commits[0], $commits[-1]);
 }
 
 # private functions below
-- 
EW


  parent reply	other threads:[~2014-08-28  2:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-28  2:47 [PATCH 1/5] view: Email::Address cache purge is optional Eric Wong
2014-08-28  2:47 ` [PATCH 2/5] redo main HTML index to show nested messages Eric Wong
2014-08-28  2:47 ` [PATCH 3/5] view: increase MAX_INLINE_QUOTED threshold to 12 Eric Wong
2014-08-28  2:47 ` Eric Wong [this message]
2014-08-28  2:47 ` [PATCH 5/5] feed: deal with removed files Eric Wong

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=1409194056-4735-4-git-send-email-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).