unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] index: show short-ish permalinks to messages in threads
@ 2014-09-14 23:08 Eric Wong
  2014-09-15  2:21 ` Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2014-09-14 23:08 UTC (permalink / raw)
  To: meta; +Cc: Eric Wong

This should allow us to reference discussions more easily.
---
 lib/PublicInbox/Feed.pm | 22 ++++++++++++----------
 lib/PublicInbox/View.pm |  3 ++-
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 339d9c2..385e573 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -58,7 +58,8 @@ sub generate_html_index {
 	$title = PublicInbox::Hval->new_oneline($title)->as_html;
 
 	my @messages;
-	my $git = PublicInbox::GitCatFile->new($args->{git_dir});
+	my $git_dir = $args->{git_dir};
+	my $git = PublicInbox::GitCatFile->new($git_dir);
 	my ($first, $last) = each_recent_blob($args, sub {
 		my $mime = do_cat_mail($git, $_[0]) or return 0;
 
@@ -90,7 +91,7 @@ sub generate_html_index {
 	for (sort { (eval { $b->message->header('X-PI-Date') } || 0) <=>
 		    (eval { $a->message->header('X-PI-Date') } || 0)
 		  } $th->rootset) {
-		dump_msg($_, 0, \$html, time, \%seen);
+		dump_msg($_, 0, \$html, time, \%seen, $first);
 	}
 
 	Email::Address->purge_cache;
@@ -143,7 +144,8 @@ sub each_recent_blob {
 	# we could use git log -z, but, we already know ssoma will not
 	# leave us with filenames with spaces in them..
 	my @cmd = ('git', "--git-dir=$args->{git_dir}",
-			qw/log --no-notes --no-color --raw -r/);
+			qw/log --no-notes --no-color --raw -r
+			   --abbrev=16 --abbrev-commit/);
 	push @cmd, $range;
 
 	my $pid = open(my $log, '-|', @cmd) or
@@ -163,14 +165,14 @@ sub each_recent_blob {
 			}
 		} elsif ($line =~ /$delmsg/o) {
 			$deleted{$1} = 1;
-		} elsif ($line =~ /^commit (${hex}{40})/) {
+		} elsif ($line =~ /^commit (${hex}{7,40})/) {
 			push @commits, $1;
 		}
 	}
 
 	if ($last) {
 		while (my $line = <$log>) {
-			if ($line =~ /^commit (${hex}{40})/) {
+			if ($line =~ /^commit (${hex}{7,40})/) {
 				push @commits, $1;
 				last;
 			}
@@ -285,14 +287,14 @@ sub add_to_feed {
 }
 
 sub dump_msg {
-	my ($self, $level, $html, $now, $seen) = @_;
+	my ($self, $level, $html, $now, $seen, $first) = @_;
 	my $mime = $self->message;
 	if ($mime) {
-		$$html .=
-		    PublicInbox::View->index_entry($mime, $now, $level, $seen);
+		$$html .= PublicInbox::View->index_entry($mime, $now, $level,
+		                                         $seen, $first);
 	}
-	dump_msg($self->child, $level+1, $html, $now, $seen) if $self->child;
-	dump_msg($self->next, $level, $html, $now, $seen) if $self->next;
+	dump_msg($self->child, $level+1, $html, $now, $seen, $first) if $self->child;
+	dump_msg($self->next, $level, $html, $now, $seen, $first) if $self->next;
 }
 
 sub do_cat_mail {
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 14133d5..de78720 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -43,7 +43,7 @@ sub feed_entry {
 
 # this is already inside a <pre>
 sub index_entry {
-	my ($class, $mime, $now, $level, $seen) = @_;
+	my ($class, $mime, $now, $level, $seen, $first) = @_;
 	my $rv = "";
 	my $part_nr = 0;
 	my $enc_msg = enc_for($mime->header("Content-Type"));
@@ -134,6 +134,7 @@ sub index_entry {
 		}
 		$rv .= " <a\nhref=\"$anchor\">parent</a>";
 	}
+	$rv .= " <a\nhref=\"?r=$first#$name\">permalink</a>";
 
 	$rv . "\n\n";
 }
-- 
EW


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] index: show short-ish permalinks to messages in threads
  2014-09-14 23:08 [PATCH] index: show short-ish permalinks to messages in threads Eric Wong
@ 2014-09-15  2:21 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2014-09-15  2:21 UTC (permalink / raw)
  To: meta

Pushed with one minor change to hopefully reduce confusion
(link vs permalink)

--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -85,7 +85,7 @@ sub index_entry {
 	my $href = $mid->as_href;
 	my $mhref = "m/$href.html";
 	my $fhref = "f/$href.html";
-	my $more = 'link';
+	my $more = 'message';
 	# scan through all parts, looking for displayable text
 	$mime->walk_parts(sub {
 		my ($part) = @_;
@@ -134,6 +134,7 @@ sub index_entry {

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-15  2:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-14 23:08 [PATCH] index: show short-ish permalinks to messages in threads Eric Wong
2014-09-15  2:21 ` Eric Wong

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).