diff --git a/www/index.pl b/www/index.pl index 9b8ad6d..20b04d4 100755 --- a/www/index.pl +++ b/www/index.pl @@ -40,6 +40,7 @@ TUWF::set( TUWF::register( qr// => \&home, qr{info/about} => \&about, + qr{browse/search} => \&browsesearch, qr{browse/([^/]+)} => \&browsesys, qr{browse/([^/]+)/([^/]+)(?:/([^/]+))?} => \&browsepkg, qr{xml/search\.xml} => \&xmlsearch, @@ -208,6 +209,32 @@ sub about { } +sub browsesearch { + my $self = shift; + my $q = $self->reqGet('q')||''; + my $man = $self->dbSearch($q, 150); + + $self->htmlHeader(title => 'Search results for '.$q); + h1 'Search results for '.$q; + txt 'Note: This is just a simple case-insensitive prefix match on the man names. In the future we\'ll have more powerful search functionality. Hopefully.'; + if(@$man) { + ul id => 'searchres'; + for(@$man) { + li; + a href => "/$_->{name}.".substr($_->{section},0,1), $_->{name}; + i $_->{section}; + end; + } + end; + } else { + br; br; + b 'No results :-('; + } + + $self->htmlFooter; +} + + sub browsesys { my($self, $short) = @_; @@ -502,7 +529,7 @@ sub htmlHeader { div id => 'header'; a href => '/', 'manned.org'; - form action => '/', method => 'get'; + form action => '/browse/search', method => 'get'; input type => 'text', name => 'q', id => 'q'; input type => 'submit', value => ' '; end; diff --git a/www/man.css b/www/man.css index dc23ff9..2a185fe 100644 --- a/www/man.css +++ b/www/man.css @@ -67,6 +67,11 @@ td { padding: 1px 5px; font-size: 12px; border-left: 1px solid #ccc; } #packages i { color: #aaa; font-size: 13px; } #packages a { padding-right: 5px } +#searchres { margin: 20px 0; -webkit-column-width: 300px; -moz-column-width: 300px; column-width: 300px } +#searchres li { display: block; } +#searchres i { color: #aaa; font-size: 13px; } +#searchres a { padding-right: 5px } + #manuals { margin: 20px 0; -webkit-column-width: 500px; -moz-column-width: 500px; column-width: 500px } #manuals li { display: block; } #manuals i { color: #aaa; font-size: 13px; }