]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Support for simple project search form
authorPetr Baudis <redacted>
Fri, 3 Oct 2008 07:29:45 +0000 (09:29 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:50:38 +0000 (00:50 -0400)
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 <redacted>
Signed-off-by: Shawn O. Pearce <redacted>
gitweb.css
gitweb.perl

index 8035ff13d4c67e9ef2377b723a9e086ebd1034f96ce6eee013c998b02210ab2c..644d0f632f23b5d2953abe9efe45dd00312a47b538426837214cb8b0dbd39339 100644 (file)
@@ -435,6 +435,10 @@ div.search {
        right: 12px
 }
 
+p.projsearch {
+       text-align: center;
+}
+
 td.linenr {
        text-align: right;
 }
index 66596b57f57deecd851690d49a00ebae5815e34b3a86d7af79dcf7aa7028b460..0a8c9e2199b5613d8a1c9f189466edf4769027daec6d87eab0f314c390543b15 100755 (executable)
@@ -3796,11 +3796,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) {
@@ -4137,6 +4140,11 @@ sub git_project_list {
                close $fd;
                print "</div>\n";
        }
+       print $cgi->startform(-method => "get") .
+             "<p class=\"projsearch\">Search:\n" .
+             $cgi->textfield(-name => "s", -value => $searchtext) . "\n" .
+             "</p>" .
+             $cgi->end_form() . "\n";
        git_project_list_body(\@list, $order);
        git_footer_html();
 }
This page took 0.360477 seconds and 4 git commands to generate.