From: Petr Baudis Date: Fri, 3 Oct 2008 07:29:45 +0000 (+0200) Subject: gitweb: Support for simple project search form X-Git-Tag: v1.6.1-rc1~158^2^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0d1d154dbe4d16a802c2e357de96e349f04d2f2c;p=git.git 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 Signed-off-by: Shawn O. Pearce --- diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css index 07f5b5378..a01eac814 100644 --- a/gitweb/gitweb.css +++ b/gitweb/gitweb.css @@ -435,6 +435,10 @@ div.search { right: 12px } +p.projsearch { + text-align: center; +} + td.linenr { text-align: right; } diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 99fdb13f1..b46af77da 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -3767,11 +3767,14 @@ sub git_project_list_body { my $pr = $projects[$i]; next if $tagfilter and $show_ctags and not grep { lc $_ eq lc $tagfilter } keys %{$pr->{'ctags'}}; - # Weed out forks + next if $searchtext and not $pr->{'path'} =~ /$searchtext/ + and not $pr->{'descr_long'} =~ /$searchtext/; + # Weed out forks or non-matching entries of search if ($check_forks) { my $forkbase = $project; $forkbase ||= ''; $forkbase =~ s#\.git$#/#; $forkbase="^$forkbase" if $forkbase; - next if not $tagfilter and $pr->{'path'} =~ m#$forkbase.*/.*#; # regexp-safe + next if not $searchtext and not $tagfilter and $show_ctags + and $pr->{'path'} =~ m#$forkbase.*/.*#; # regexp-safe } if ($alternate) { @@ -4108,6 +4111,11 @@ sub git_project_list { close $fd; print "\n"; } + print $cgi->startform(-method => "get") . + "

Search:\n" . + $cgi->textfield(-name => "s", -value => $searchtext) . "\n" . + "

" . + $cgi->end_form() . "\n"; git_project_list_body(\@list, $order); git_footer_html(); }