Skip to content

Commit 0d1d154

Browse files
Petr Baudisspearce
authored andcommitted
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 <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 4232611 commit 0d1d154

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

gitweb/gitweb.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,10 @@ div.search {
435435
right: 12px
436436
}
437437

438+
p.projsearch {
439+
text-align: center;
440+
}
441+
438442
td.linenr {
439443
text-align: right;
440444
}

gitweb/gitweb.perl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3767,11 +3767,14 @@ sub git_project_list_body {
37673767
my $pr = $projects[$i];
37683768

37693769
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
37713773
if ($check_forks) {
37723774
my $forkbase = $project; $forkbase ||= ''; $forkbase =~ s#\.git$#/#;
37733775
$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
37753778
}
37763779

37773780
if ($alternate) {
@@ -4108,6 +4111,11 @@ sub git_project_list {
41084111
close $fd;
41094112
print "</div>\n";
41104113
}
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";
41114119
git_project_list_body(\@list, $order);
41124120
git_footer_html();
41134121
}

0 commit comments

Comments
 (0)