All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gitweb: linkify author/committer names with search
@ 2009-10-14  2:12 Stephen Boyd
  2009-10-14  9:13 ` Junio C Hamano
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Stephen Boyd @ 2009-10-14  2:12 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Giuseppe Bilotta, Jakub Narebski

It's nice to search for an author by merely clicking on their name in
gitweb. This is usually faster than selecting the name, copying the
selection, pasting it into the search box, selecting between
author/committer and then hitting enter.

Linkify the avatar icon in log/shortlog view because the icon is directly
adjacent to the name and thus more related. The same is not true
when in commit/tag view where the icon is farther away.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

This is on top of Giuseppe's fix esc_param patch.

 gitweb/gitweb.css  |    1 +
 gitweb/gitweb.perl |   21 ++++++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 8f68fe3..e2cd9d7 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -30,6 +30,7 @@ img.logo {
 
 img.avatar {
 	vertical-align: middle;
+	border-width: 0px;
 }
 
 div.page_header {
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 4b21ad2..bdf1037 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1602,8 +1602,12 @@ sub format_author_html {
 	my $co = shift;
 	my $author = chop_and_escape_str($co->{'author_name'}, @_);
 	return "<$tag class=\"author\">" .
-	       git_get_avatar($co->{'author_email'}, -pad_after => 1) .
-	       $author . "</$tag>";
+	       $cgi->a({-href => href(action=>"search", hash=>$hash,
+			searchtext=>$co->{'author_name'},
+			searchtype=>"author"), class=>"list"},
+			git_get_avatar($co->{'author_email'}, -pad_after => 1) .
+			$author) .
+	       "</$tag>";
 }
 
 # format git diff header line, i.e. "diff --(git|combined|cc) ..."
@@ -3372,10 +3376,13 @@ sub git_print_authorship {
 	my $co = shift;
 	my %opts = @_;
 	my $tag = $opts{-tag} || 'div';
+	my $author = $co->{'author_name'};
 
 	my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'});
 	print "<$tag class=\"author_date\">" .
-	      esc_html($co->{'author_name'}) .
+	      $cgi->a({-href => href(action=>"search", searchtext=>$author,
+		      searchtype=>"author"), class=>"list"},
+		      esc_html($author)) .
 	      " [$ad{'rfc2822'}";
 	print_local_time(%ad) if ($opts{-localtime});
 	print "]" . git_get_avatar($co->{'author_email'}, -pad_before => 1)
@@ -3394,8 +3401,12 @@ sub git_print_authorship_rows {
 	@people = ('author', 'committer') unless @people;
 	foreach my $who (@people) {
 		my %wd = parse_date($co->{"${who}_epoch"}, $co->{"${who}_tz"});
-		print "<tr><td>$who</td><td>" . esc_html($co->{$who}) . "</td>" .
-		      "<td rowspan=\"2\">" .
+		print "<tr><td>$who</td><td>" .
+		      $cgi->a({-href => href(action=>"search",
+			       searchtext=>$co->{"${who}_name"},
+			       searchtype=>$who), class=>"list"},
+			       esc_html($co->{$who})) .
+		      "</td><td rowspan=\"2\">" .
 		      git_get_avatar($co->{"${who}_email"}, -size => 'double') .
 		      "</td></tr>\n" .
 		      "<tr>" .
-- 
1.6.5.1.g75846.dirty

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

* Re: [PATCH] gitweb: linkify author/committer names with search
  2009-10-14  2:12 [PATCH] gitweb: linkify author/committer names with search Stephen Boyd
@ 2009-10-14  9:13 ` Junio C Hamano
  2009-10-14 16:55 ` Wincent Colaiuta
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2009-10-14  9:13 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: git, Junio C Hamano, Giuseppe Bilotta, Jakub Narebski

Stephen Boyd <bebarino@gmail.com> writes:

> It's nice to search for an author by merely clicking on their name in
> gitweb. This is usually faster than selecting the name, copying the
> selection, pasting it into the search box, selecting between
> author/committer and then hitting enter.
>
> Linkify the avatar icon in log/shortlog view because the icon is directly
> adjacent to the name and thus more related. The same is not true
> when in commit/tag view where the icon is farther away.
>
> Signed-off-by: Stephen Boyd <bebarino@gmail.com>
> ---
>
> This is on top of Giuseppe's fix esc_param patch.
>
>  gitweb/gitweb.css  |    1 +
>  gitweb/gitweb.perl |   21 ++++++++++++++++-----
>  2 files changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
> index 8f68fe3..e2cd9d7 100644
> --- a/gitweb/gitweb.css
> +++ b/gitweb/gitweb.css
> @@ -30,6 +30,7 @@ img.logo {
>  
>  img.avatar {
>  	vertical-align: middle;
> +	border-width: 0px;
>  }

Even though it _might_ be a good thing to do, this looks an unrelated
change,

>  div.page_header {
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 4b21ad2..bdf1037 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -1602,8 +1602,12 @@ sub format_author_html {
>  	my $co = shift;
>  	my $author = chop_and_escape_str($co->{'author_name'}, @_);
>  	return "<$tag class=\"author\">" .
> -	       git_get_avatar($co->{'author_email'}, -pad_after => 1) .
> -	       $author . "</$tag>";
> +	       $cgi->a({-href => href(action=>"search", hash=>$hash,
> +			searchtext=>$co->{'author_name'},
> +			searchtype=>"author"), class=>"list"},
> +			git_get_avatar($co->{'author_email'}, -pad_after => 1) .
> +			$author) .
> +	       "</$tag>";
>  }
>  
>  # format git diff header line, i.e. "diff --(git|combined|cc) ..."
> @@ -3372,10 +3376,13 @@ sub git_print_authorship {
>  	my $co = shift;
>  	my %opts = @_;
>  	my $tag = $opts{-tag} || 'div';
> +	my $author = $co->{'author_name'};
>  
>  	my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'});
>  	print "<$tag class=\"author_date\">" .
> -	      esc_html($co->{'author_name'}) .
> +	      $cgi->a({-href => href(action=>"search", searchtext=>$author,
> +		      searchtype=>"author"), class=>"list"},
> +		      esc_html($author)) .
>  	      " [$ad{'rfc2822'}";
>  	print_local_time(%ad) if ($opts{-localtime});
>  	print "]" . git_get_avatar($co->{'author_email'}, -pad_before => 1)
> @@ -3394,8 +3401,12 @@ sub git_print_authorship_rows {
>  	@people = ('author', 'committer') unless @people;
>  	foreach my $who (@people) {
>  		my %wd = parse_date($co->{"${who}_epoch"}, $co->{"${who}_tz"});
> -		print "<tr><td>$who</td><td>" . esc_html($co->{$who}) . "</td>" .
> -		      "<td rowspan=\"2\">" .
> +		print "<tr><td>$who</td><td>" .
> +		      $cgi->a({-href => href(action=>"search",
> +			       searchtext=>$co->{"${who}_name"},
> +			       searchtype=>$who), class=>"list"},
> +			       esc_html($co->{$who})) .
> +		      "</td><td rowspan=\"2\">" .
>  		      git_get_avatar($co->{"${who}_email"}, -size => 'double') .
>  		      "</td></tr>\n" .
>  		      "<tr>" .
> -- 
> 1.6.5.1.g75846.dirty

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

* Re: [PATCH] gitweb: linkify author/committer names with search
  2009-10-14  2:12 [PATCH] gitweb: linkify author/committer names with search Stephen Boyd
  2009-10-14  9:13 ` Junio C Hamano
@ 2009-10-14 16:55 ` Wincent Colaiuta
  2009-10-14 20:24 ` [PATCHv2] " Stephen Boyd
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Wincent Colaiuta @ 2009-10-14 16:55 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: git, Junio C Hamano, Giuseppe Bilotta, Jakub Narebski

El 14/10/2009, a las 04:12, Stephen Boyd escribió:

> It's nice to search for an author by merely clicking on their name in
> gitweb. This is usually faster than selecting the name, copying the
> selection, pasting it into the search box, selecting between
> author/committer and then hitting enter.

What about installs where search is turned off? (ie. with "$feature 
{'search'}{'default'} = [undef];" in gitweb.conf)

Cheers,
Wincent

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

* [PATCHv2] gitweb: linkify author/committer names with search
  2009-10-14  2:12 [PATCH] gitweb: linkify author/committer names with search Stephen Boyd
  2009-10-14  9:13 ` Junio C Hamano
  2009-10-14 16:55 ` Wincent Colaiuta
@ 2009-10-14 20:24 ` Stephen Boyd
  2009-10-15 11:41 ` [PATCH] " Jakub Narebski
  2009-10-16  4:14 ` [PATCHv3] " Stephen Boyd
  4 siblings, 0 replies; 7+ messages in thread
From: Stephen Boyd @ 2009-10-14 20:24 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Wincent Colaiuta

It's nice to search for an author by merely clicking on their name in
gitweb. This is usually faster than selecting the name, copying the
selection, pasting it into the search box, selecting between
author/committer and then hitting enter.

Linkify the avatar icon in log/shortlog view because the icon is directly
adjacent to the name and thus more related. The same is not true
when in commit/tag view where the icon is farther away.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

This is based off next now that Giuseppe's patch is there.

Changes since v1:

 * CSS hack has been cleaned up to only remove the link border from
   avatar icons when actually linked.

 * Checking for search capability to avoid generating search links (Wincent)

 * Linking of name and email are separate in commit/commitdiff/tag views

The last one I figured I'd throw in because I'm doing it again.

 gitweb/gitweb.css  |    4 ++++
 gitweb/gitweb.perl |   33 ++++++++++++++++++++++++++++-----
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 8faa94e..50067f2 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -32,6 +32,10 @@ img.avatar {
 	vertical-align: middle;
 }
 
+a.list img.avatar {
+	border-style: none;
+}
+
 div.page_header {
 	height: 25px;
 	padding: 8px;
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 0c71ee8..6325b97 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1625,6 +1625,22 @@ sub git_get_avatar {
 	}
 }
 
+sub format_search_author {
+	my $searchtext = shift;
+	my $searchtype = shift;
+	my $displaytext = shift;
+	my $have_search = gitweb_check_feature('search');
+	if ($have_search) {
+		return $cgi->a({-href => href(action=>"search", hash=>$hash,
+				searchtext=>$searchtext,
+				searchtype=>$searchtype), class=>"list"},
+				$displaytext);
+
+	} else {
+		return $displaytext;
+	}
+}
+
 # format the author name of the given commit with the given tag
 # the author name is chopped and escaped according to the other
 # optional parameters (see chop_str).
@@ -1633,8 +1649,10 @@ sub format_author_html {
 	my $co = shift;
 	my $author = chop_and_escape_str($co->{'author_name'}, @_);
 	return "<$tag class=\"author\">" .
-	       git_get_avatar($co->{'author_email'}, -pad_after => 1) .
-	       $author . "</$tag>";
+	       format_search_author($co->{'author_name'}, "author",
+		       git_get_avatar($co->{'author_email'}, -pad_after => 1) .
+		       $author) .
+	       "</$tag>";
 }
 
 # format git diff header line, i.e. "diff --(git|combined|cc) ..."
@@ -3433,10 +3451,11 @@ sub git_print_authorship {
 	my $co = shift;
 	my %opts = @_;
 	my $tag = $opts{-tag} || 'div';
+	my $author = $co->{'author_name'};
 
 	my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'});
 	print "<$tag class=\"author_date\">" .
-	      esc_html($co->{'author_name'}) .
+	      format_search_author($author, "author", esc_html($author)) .
 	      " [$ad{'rfc2822'}";
 	print_local_time(%ad) if ($opts{-localtime});
 	print "]" . git_get_avatar($co->{'author_email'}, -pad_before => 1)
@@ -3455,8 +3474,12 @@ sub git_print_authorship_rows {
 	@people = ('author', 'committer') unless @people;
 	foreach my $who (@people) {
 		my %wd = parse_date($co->{"${who}_epoch"}, $co->{"${who}_tz"});
-		print "<tr><td>$who</td><td>" . esc_html($co->{$who}) . "</td>" .
-		      "<td rowspan=\"2\">" .
+		print "<tr><td>$who</td><td>" .
+		      format_search_author($co->{"${who}_name"}, $who,
+			       esc_html($co->{"${who}_name"})) . " " .
+		      format_search_author($co->{"${who}_email"}, $who,
+			       esc_html("<" . $co->{"${who}_email"} . ">")) .
+		      "</td><td rowspan=\"2\">" .
 		      git_get_avatar($co->{"${who}_email"}, -size => 'double') .
 		      "</td></tr>\n" .
 		      "<tr>" .
-- 
1.6.5.94.gcd2f3

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

* Re: [PATCH] gitweb: linkify author/committer names with search
  2009-10-14  2:12 [PATCH] gitweb: linkify author/committer names with search Stephen Boyd
                   ` (2 preceding siblings ...)
  2009-10-14 20:24 ` [PATCHv2] " Stephen Boyd
@ 2009-10-15 11:41 ` Jakub Narebski
  2009-10-15 18:30   ` Stephen Boyd
  2009-10-16  4:14 ` [PATCHv3] " Stephen Boyd
  4 siblings, 1 reply; 7+ messages in thread
From: Jakub Narebski @ 2009-10-15 11:41 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: git, Junio C Hamano, Giuseppe Bilotta

On Wed, 14 Oct 2009, Stephen Boyd wrote:

> It's nice to search for an author by merely clicking on their name in
> gitweb. This is usually faster than selecting the name, copying the
> selection, pasting it into the search box, selecting between
> author/committer and then hitting enter.
[...]

I see that it can be useful.  But is this discoverable, and does this
do expected thing?  Most of links in gitweb lead to some view (page)
that is specific to link; other lead to anchor on same page.  Leading
to search results can be unexpected.

Perhaps title explaining what does such link does would help?  Or making
style of this link distinct from other (dashed underline, dashed 
underline on mouseover, double underline, different mouse cursor on
mouseover, etc.)?

Just my 2 eurocents.  Feel free to ignore my ramblings.

-- 
Jakub Narebski
Poland

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

* Re: [PATCH] gitweb: linkify author/committer names with search
  2009-10-15 11:41 ` [PATCH] " Jakub Narebski
@ 2009-10-15 18:30   ` Stephen Boyd
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Boyd @ 2009-10-15 18:30 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git, Junio C Hamano, Giuseppe Bilotta

Jakub Narebski wrote:
>
> I see that it can be useful.  But is this discoverable, and does this
> do expected thing?  Most of links in gitweb lead to some view (page)
> that is specific to link; other lead to anchor on same page.  Leading
> to search results can be unexpected.
>
> Perhaps title explaining what does such link does would help?  Or making
> style of this link distinct from other (dashed underline, dashed 
> underline on mouseover, double underline, different mouse cursor on
> mouseover, etc.)?

A title sounds good. Something like "List commits by $author"? I'll try
to write something up by tonight.

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

* [PATCHv3] gitweb: linkify author/committer names with search
  2009-10-14  2:12 [PATCH] gitweb: linkify author/committer names with search Stephen Boyd
                   ` (3 preceding siblings ...)
  2009-10-15 11:41 ` [PATCH] " Jakub Narebski
@ 2009-10-16  4:14 ` Stephen Boyd
  4 siblings, 0 replies; 7+ messages in thread
From: Stephen Boyd @ 2009-10-16  4:14 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Giuseppe Bilotta, Jakub Narebski

It's nice to search for an author by merely clicking on their name in
gitweb. This is usually faster than selecting the name, copying the
selection, pasting it into the search box, selecting between
author/committer and then hitting enter.

Linkify the avatar icon in log/shortlog view because the icon is directly
adjacent to the name and thus more related. The same is not true
when in commit/tag view where the icon is farther away.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

Changes since v2:

 * Add a title to make it not so suprising before you click (Jakub)

Changes since v1:

 * CSS hack has been cleaned up to only remove the link border from
    avatar icons when actually linked.

 * Checking for search capability to avoid generating search links (Wincent)

 * Linking of name and email are separate in commit/commitdiff/tag views

 gitweb/gitweb.css  |    4 ++++
 gitweb/gitweb.perl |   40 +++++++++++++++++++++++++++++++++++-----
 2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 8faa94e..50067f2 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -32,6 +32,10 @@ img.avatar {
 	vertical-align: middle;
 }
 
+a.list img.avatar {
+	border-style: none;
+}
+
 div.page_header {
 	height: 25px;
 	padding: 8px;
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 0c71ee8..63e18f4 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1625,6 +1625,29 @@ sub git_get_avatar {
 	}
 }
 
+sub format_search_author {
+	my ($author, $searchtype, $displaytext) = @_;
+	my $have_search = gitweb_check_feature('search');
+
+	if ($have_search) {
+		my $performed = "";
+		if ($searchtype eq 'author') {
+			$performed = "authored";
+		} elsif ($searchtype eq 'committer') {
+			$performed = "committed";
+		}
+
+		return $cgi->a({-href => href(action=>"search", hash=>$hash,
+				searchtext=>$author,
+				searchtype=>$searchtype), class=>"list",
+				title=>"Search for commits $performed by $author"},
+				$displaytext);
+
+	} else {
+		return $displaytext;
+	}
+}
+
 # format the author name of the given commit with the given tag
 # the author name is chopped and escaped according to the other
 # optional parameters (see chop_str).
@@ -1633,8 +1656,10 @@ sub format_author_html {
 	my $co = shift;
 	my $author = chop_and_escape_str($co->{'author_name'}, @_);
 	return "<$tag class=\"author\">" .
-	       git_get_avatar($co->{'author_email'}, -pad_after => 1) .
-	       $author . "</$tag>";
+	       format_search_author($co->{'author_name'}, "author",
+		       git_get_avatar($co->{'author_email'}, -pad_after => 1) .
+		       $author) .
+	       "</$tag>";
 }
 
 # format git diff header line, i.e. "diff --(git|combined|cc) ..."
@@ -3433,10 +3458,11 @@ sub git_print_authorship {
 	my $co = shift;
 	my %opts = @_;
 	my $tag = $opts{-tag} || 'div';
+	my $author = $co->{'author_name'};
 
 	my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'});
 	print "<$tag class=\"author_date\">" .
-	      esc_html($co->{'author_name'}) .
+	      format_search_author($author, "author", esc_html($author)) .
 	      " [$ad{'rfc2822'}";
 	print_local_time(%ad) if ($opts{-localtime});
 	print "]" . git_get_avatar($co->{'author_email'}, -pad_before => 1)
@@ -3455,8 +3481,12 @@ sub git_print_authorship_rows {
 	@people = ('author', 'committer') unless @people;
 	foreach my $who (@people) {
 		my %wd = parse_date($co->{"${who}_epoch"}, $co->{"${who}_tz"});
-		print "<tr><td>$who</td><td>" . esc_html($co->{$who}) . "</td>" .
-		      "<td rowspan=\"2\">" .
+		print "<tr><td>$who</td><td>" .
+		      format_search_author($co->{"${who}_name"}, $who,
+			       esc_html($co->{"${who}_name"})) . " " .
+		      format_search_author($co->{"${who}_email"}, $who,
+			       esc_html("<" . $co->{"${who}_email"} . ">")) .
+		      "</td><td rowspan=\"2\">" .
 		      git_get_avatar($co->{"${who}_email"}, -size => 'double') .
 		      "</td></tr>\n" .
 		      "<tr>" .
-- 
1.6.5.94.gb6c65

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

end of thread, other threads:[~2009-10-16  4:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-14  2:12 [PATCH] gitweb: linkify author/committer names with search Stephen Boyd
2009-10-14  9:13 ` Junio C Hamano
2009-10-14 16:55 ` Wincent Colaiuta
2009-10-14 20:24 ` [PATCHv2] " Stephen Boyd
2009-10-15 11:41 ` [PATCH] " Jakub Narebski
2009-10-15 18:30   ` Stephen Boyd
2009-10-16  4:14 ` [PATCHv3] " Stephen Boyd

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.