Skip to content

Commit a1e1b2d

Browse files
jnarebgitster
authored andcommitted
gitweb: improve usability of projects search form
Refactor generating project search form into git_project_search_form(). Make text field wider and add on mouse over explanation (via "title" attribute), add an option to use regular expressions, and replace 'Search:' label with [Search] button. Also add "List all projects" link to make it easier to go back from search result to list of all projects (note that an empty search term is disallowed). Signed-off-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4426ba2 commit a1e1b2d

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

gitweb/gitweb.perl

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5158,6 +5158,26 @@ sub git_patchset_body {
51585158

51595159
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
51605160

5161+
sub git_project_search_form {
5162+
my ($searchtext, $search_use_regexp);
5163+
5164+
print "<div class=\"projsearch\">\n";
5165+
print $cgi->startform(-method => 'get', -action => $my_uri) .
5166+
$cgi->hidden(-name => 'a', -value => 'project_list') . "\n" .
5167+
$cgi->textfield(-name => 's', -value => $searchtext,
5168+
-title => 'Search project by name and description',
5169+
-size => 60) . "\n" .
5170+
"<span title=\"Extended regular expression\">" .
5171+
$cgi->checkbox(-name => 'sr', -value => 1, -label => 're',
5172+
-checked => $search_use_regexp) .
5173+
"</span>\n" .
5174+
$cgi->submit(-name => 'btnS', -value => 'Search') .
5175+
$cgi->end_form() . "\n" .
5176+
$cgi->a({-href => href(project => undef, searchtext => undef)},
5177+
'List all projects') . "<br />\n";
5178+
print "</div>\n";
5179+
}
5180+
51615181
# fills project list info (age, description, owner, category, forks)
51625182
# for each project in the list, removing invalid projects from
51635183
# returned list
@@ -6025,11 +6045,8 @@ sub git_project_list {
60256045
insert_file($home_text);
60266046
print "</div>\n";
60276047
}
6028-
print $cgi->startform(-method => "get") .
6029-
"<p class=\"projsearch\">Search:\n" .
6030-
$cgi->textfield(-name => "s", -value => $searchtext) . "\n" .
6031-
"</p>" .
6032-
$cgi->end_form() . "\n";
6048+
6049+
git_project_search_form($searchtext, $search_use_regexp);
60336050
git_project_list_body(\@list, $order);
60346051
git_footer_html();
60356052
}

gitweb/static/gitweb.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,13 @@ div.search {
520520
right: 12px
521521
}
522522

523-
p.projsearch {
523+
div.projsearch {
524524
text-align: center;
525+
margin: 20px 0px;
526+
}
527+
528+
div.projsearch form {
529+
margin-bottom: 2px;
525530
}
526531

527532
td.linenr {

0 commit comments

Comments
 (0)