threads / patch / 14811

patchgitweb: ref markers link to named shortlogs

Subject: [PATCH] gitweb: ref markers link to named shortlogs

## tl;dr

5 messages between Aug 2, 2008 and Aug 3, 2008. Diffs are folded; open one to read it.

replies: 4people: 2as markdown or json

Giuseppe Bilotta· Aug 2, 2008, 15:39 UTC · lore

This patch turns ref markers for tags and heads into links to shortlog/refname. Appropriate changes are made in the CSS to prevent ref markers to be annoyingly blue and underlined.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.css  |    5 +++++
 gitweb/gitweb.perl |    5 ++++-
 2 files changed, 9 insertions(+), 1 deletions(-)
Show changes to 2 files +9 −1

gitweb/gitweb.css, gitweb/gitweb.perl

diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index aa0eeca..2b43eea 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -481,6 +481,11 @@ span.refs span {
 	border-color: #ffccff #ff00ee #ff00ee #ffccff;
 }
 
+span.refs span a {
+	text-decoration: none;
+	color: inherit;
+}
+
 span.refs span.ref {
 	background-color: #aaaaff;
 	border-color: #ccccff #0033cc #0033cc #ccccff;
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 90cd99b..7f391fa 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1093,6 +1093,7 @@ sub format_log_line_html {
 sub format_ref_marker {
 	my ($refs, $id) = @_;
 	my $markers = '';
+	my $htmltext;
 
 	if (defined $refs->{$id}) {
 		foreach my $ref (@{$refs->{$id}}) {
@@ -1101,13 +1102,15 @@ sub format_ref_marker {
 			if ($ref =~ m!^(.*?)s?/(.*)$!) {
 				$type = $1;
 				$name = $2;
+				$htmltext = $cgi->a({-href => href(action=>"shortlog", hash=>$name)}, $name);
 			} else {
 				$type = "ref";
 				$name = $ref;
+				$htmltext = esc_html($name);
 			}
 
 			$markers .= " <span class=\"$type\" title=\"$ref\">" .
-			            esc_html($name) . "</span>";
+			            $htmltext . "</span>";
 		}
 	}
 
-- 
1.5.6.3
Petr Baudis· Aug 3, 2008, 12:03 UTC · re: Giuseppe Bilotta · lore

Re: [PATCH] gitweb: ref markers link to named shortlogs

On Sat, Aug 02, 2008 at 05:39:14PM +0200, Giuseppe Bilotta wrote:
Show 5 quoted lines
> This patch turns ref markers for tags and heads into links to
> shortlog/refname. Appropriate changes are made in the CSS to prevent ref
> markers to be annoyingly blue and underlined.
> 
> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
I think this is good idea in principle, but
	(i) Why not do this for all the refs?
	(ii) I think you should decide on the type of the action based
on the object type of the ref; actually, any kind of object type can be
ref'd, and for tags you would rather want tag view, etc. (The tag view
actually sucks and should behave more like git show tag - i.e. append
the appropriate view after the tag info - but that is different matter.)
-- 
				Petr "Pasky" Baudis
The next generation of interesting software will be done
on the Macintosh, not the IBM PC.  -- Bill Gates
Giuseppe Bilotta· Aug 3, 2008, 13:14 UTC · re: Petr Baudis · lore

Re: [PATCH] gitweb: ref markers link to named shortlogs

On Sun, Aug 3, 2008 at 2:03 PM, Petr Baudis <pasky@suse.cz> wrote:
Show 16 quoted lines
> On Sat, Aug 02, 2008 at 05:39:14PM +0200, Giuseppe Bilotta wrote:
>> This patch turns ref markers for tags and heads into links to
>> shortlog/refname. Appropriate changes are made in the CSS to prevent ref
>> markers to be annoyingly blue and underlined.
>>
>> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
>
> I think this is good idea in principle, but
>
>        (i) Why not do this for all the refs?
>
>        (ii) I think you should decide on the type of the action based
> on the object type of the ref; actually, any kind of object type can be
> ref'd, and for tags you would rather want tag view, etc. (The tag view
> actually sucks and should behave more like git show tag - i.e. append
> the appropriate view after the tag info - but that is different matter.)

Funny that. My original plan was to have a different action depending on tag (I tried shortlog for tag and commitdiff for branch). And since I I had no idea what kind of action to use for 'generic' refs, I left them out. Then I had second thoughts and started using shortlog for both heads and tags, and collapsed the code but still kept the generic refs out of the way. So maybe we can use shortlog as default action and single out tags (and whatever else we'll find to need a different action)?

-- 
Giuseppe "Oblomov" Bilotta
Petr Baudis· Aug 3, 2008, 13:20 UTC · re: Giuseppe Bilotta · lore

Re: [PATCH] gitweb: ref markers link to named shortlogs

On Sun, Aug 03, 2008 at 03:14:09PM +0200, Giuseppe Bilotta wrote:
Show 15 quoted lines
> On Sun, Aug 3, 2008 at 2:03 PM, Petr Baudis <pasky@suse.cz> wrote:
> >        (ii) I think you should decide on the type of the action based
> > on the object type of the ref; actually, any kind of object type can be
> > ref'd, and for tags you would rather want tag view, etc. (The tag view
> > actually sucks and should behave more like git show tag - i.e. append
> > the appropriate view after the tag info - but that is different matter.)
> 
> Funny that. My original plan was to have a different action depending
> on tag (I tried shortlog for tag and commitdiff for branch). And since
> I I had no idea what kind of action to use for 'generic' refs, I left
> them out. Then I had second thoughts and started using shortlog for
> both heads and tags, and collapsed the code but still kept the generic
> refs out of the way. So maybe we can use shortlog as default action
> and single out tags (and whatever else we'll find to need a different
> action)?

What's wrong with my proposed approach to choose actoin based on object type of the ref?

-- 
				Petr "Pasky" Baudis
The next generation of interesting software will be done
on the Macintosh, not the IBM PC.  -- Bill Gates
Giuseppe Bilotta· Aug 3, 2008, 20:48 UTC · re: Petr Baudis · lore

[PATCHv2] gitweb: ref markers link to named shortlogs

This patch turns ref markers for tags and heads into links to appropriate views for the ref name. Appropriate changes are made in the CSS to prevent ref markers to be annoyingly blue and underlined.

For all git ref types it's assumed that the preferred view is named like the ref type itself. For commits, we map the view to shortlog.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---

Following pasky's suggestion, the action used by the ref marker is now determined from the ref type, default action to the ref type itsef. Currently the only non-default action is shortlog for commit refs, but the map can be expanded as needed.

 gitweb/gitweb.css  |    5 +++++
 gitweb/gitweb.perl |    7 ++++++-
 2 files changed, 11 insertions(+), 1 deletions(-)
Show changes to 2 files +11 −1

gitweb/gitweb.css, gitweb/gitweb.perl

diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index aa0eeca..2b43eea 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -481,6 +481,11 @@ span.refs span {
 	border-color: #ffccff #ff00ee #ff00ee #ffccff;
 }
 
+span.refs span a {
+	text-decoration: none;
+	color: inherit;
+}
+
 span.refs span.ref {
 	background-color: #aaaaff;
 	border-color: #ccccff #0033cc #0033cc #ccccff;
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 90cd99b..a12ce87 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1093,10 +1093,14 @@ sub format_log_line_html {
 sub format_ref_marker {
 	my ($refs, $id) = @_;
 	my $markers = '';
+	my %view = (
+		"commit" => "shortlog",
+	);
 
 	if (defined $refs->{$id}) {
 		foreach my $ref (@{$refs->{$id}}) {
 			my ($type, $name) = qw();
+			my $git_type = git_get_type($ref);
 			# e.g. tags/v2.6.11 or heads/next
 			if ($ref =~ m!^(.*?)s?/(.*)$!) {
 				$type = $1;
@@ -1107,7 +1111,8 @@ sub format_ref_marker {
 			}
 
 			$markers .= " <span class=\"$type\" title=\"$ref\">" .
-			            esc_html($name) . "</span>";
+				$cgi->a({-href => href(action=>$view{$git_type} || $git_type, hash=>$name)}, $name) .
+				"</span>";
 		}
 	}
 
-- 
1.5.6.3

← back to recent threads