Skip to content

Commit

Permalink
gitweb: Support for simple project search form
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Petr Baudis authored and Shawn O. Pearce committed Oct 3, 2008
1 parent 4232611 commit 0d1d154
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions gitweb/gitweb.css
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ div.search {
right: 12px
}

p.projsearch {
text-align: center;
}

td.linenr {
text-align: right;
}
Expand Down
12 changes: 10 additions & 2 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -4108,6 +4111,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();
}
Expand Down

0 comments on commit 0d1d154

Please sign in to comment.