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 <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jakub Narebski committed
Jan 31, 2012 at 01:20 UTC
a1e1b2d77b9fc5866d12bf984214b15f1dccf4a8
2 files changed
+28
-6
gitweb/gitweb.perl
+22
-5
@@ -5158,6 +5158,26 @@ sub git_patchset_body {
5158
5159
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5160
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
+
5181
# fills project list info (age, description, owner, category, forks)
5182
# for each project in the list, removing invalid projects from
5183
# returned list
@@ -6025,11 +6045,8 @@ sub git_project_list {
6045
insert_file($home_text);
6046
print "</div>\n";
6047
}
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);
6050
git_project_list_body(\@list, $order);
6051
git_footer_html();
6052
}
gitweb/static/gitweb.css
+6
-1
@@ -520,8 +520,13 @@ div.search {
520
right: 12px
521
}
522
523
-p.projsearch {
523
+div.projsearch {
524
text-align: center;
525
+ margin: 20px 0px;
526
+}
527
+
528
+div.projsearch form {
529
+ margin-bottom: 2px;
530
}
531
532
td.linenr {