From: Jakub Narebski Date: Mon, 27 Feb 2012 01:55:20 +0000 (+0100) Subject: gitweb: Highlight matched part of project name when searching projects X-Git-Url: https://git.ladys.computer/Gitweb/commitdiff_plain/8fb8b3b4b444f368efb7d8ab4fab297372e643dd6f582db0ef8d0a5147fa76e5 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 Signed-off-by: Junio C Hamano --- diff --git a/gitweb.perl b/gitweb.perl index 3398de3..d82d6fb 100755 --- a/gitweb.perl +++ b/gitweb.perl @@ -5401,7 +5401,9 @@ sub git_project_list_rows { print "\n"; } print "" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"), - -class => "list"}, esc_html($pr->{'path'})) . "\n" . + -class => "list"}, + esc_html_match_hl($pr->{'path'}, $search_regexp)) . + "\n" . "" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"), -class => "list", -title => $pr->{'descr_long'}}, esc_html($pr->{'descr'})) . "\n" .