@matheusbsbs / matheus-bagliano / commits / 0d1d154dbe
Fork 0

gitweb: Support for simple project search form

This is a trivial patch adding support for searching projects by name and description, making use of the "infrastructure" provided by the tag cloud generation. Signed-off-by: Petr Baudis <petr.baudis@novartis.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Petr Baudis committed Oct 3, 2008 at 09:29 UTC 0d1d154dbe4d16a802c2e357de96e349f04d2f2c
2 files changed +14 -2
gitweb/gitweb.css
+4
@@ -435,6 +435,10 @@ div.search {
435 right: 12px
436 }
437
438 +p.projsearch {
439 + text-align: center;
440 +}
441 +
442 td.linenr {
443 text-align: right;
444 }
gitweb/gitweb.perl
+10 -2
@@ -3767,11 +3767,14 @@ sub git_project_list_body {
3767 my $pr = $projects[$i];
3768
3769 next if $tagfilter and $show_ctags and not grep { lc $_ eq lc $tagfilter } keys %{$pr->{'ctags'}};
3770 - # Weed out forks
3770 + next if $searchtext and not $pr->{'path'} =~ /$searchtext/
3771 + and not $pr->{'descr_long'} =~ /$searchtext/;
3772 + # Weed out forks or non-matching entries of search
3773 if ($check_forks) {
3774 my $forkbase = $project; $forkbase ||= ''; $forkbase =~ s#\.git$#/#;
3775 $forkbase="^$forkbase" if $forkbase;
3774 - next if not $tagfilter and $pr->{'path'} =~ m#$forkbase.*/.*#; # regexp-safe
3776 + next if not $searchtext and not $tagfilter and $show_ctags
3777 + and $pr->{'path'} =~ m#$forkbase.*/.*#; # regexp-safe
3778 }
3779
3780 if ($alternate) {
@@ -4108,6 +4111,11 @@ sub git_project_list {
4111 close $fd;
4112 print "</div>\n";
4113 }
4114 + print $cgi->startform(-method => "get") .
4115 + "<p class=\"projsearch\">Search:\n" .
4116 + $cgi->textfield(-name => "s", -value => $searchtext) . "\n" .
4117 + "</p>" .
4118 + $cgi->end_form() . "\n";
4119 git_project_list_body(\@list, $order);
4120 git_footer_html();
4121 }