Skip to content

Commit 07a4006

Browse files
jnarebgitster
authored andcommitted
gitweb: Highlight matched part of project name when searching projects
Use esc_html_match_hl() introduced in previous commit to escape HTML and mark match, using span element with 'match' class. Currently only the 'path' part (i.e. the project name) is highlighted; match might be on the project description. Highlighting match in description is left for next commit. The code makes use of the fact that defined $search_regexp means that there was search going on. Signed-off-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 337da8d commit 07a4006

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

gitweb/gitweb.perl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5400,7 +5400,9 @@ sub git_project_list_rows {
54005400
print "</td>\n";
54015401
}
54025402
print "<td>" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"),
5403-
-class => "list"}, esc_html($pr->{'path'})) . "</td>\n" .
5403+
-class => "list"},
5404+
esc_html_match_hl($pr->{'path'}, $search_regexp)) .
5405+
"</td>\n" .
54045406
"<td>" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"),
54055407
-class => "list", -title => $pr->{'descr_long'}},
54065408
esc_html($pr->{'descr'})) . "</td>\n" .

0 commit comments

Comments
 (0)