Changeset 43


Ignore:
Timestamp:
11/28/10 19:30:07 (14 years ago)
Author:
nanardon
Message:
  • add search functions
Location:
server/trunk/web
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • server/trunk/web/lib/Sophie/Base/Result/Files.pm

    r16 r43  
    66 
    77__PACKAGE__->table('files'); 
    8 __PACKAGE__->add_columns(qw/pkgid count dirname basename md5/); 
     8__PACKAGE__->add_columns(qw/pkgid count dirname basename md5 user group linkto 
     9    mode fflags size class color vflags mtime nlink/); 
    910__PACKAGE__->set_primary_key(qw/pkgid count/); 
    1011__PACKAGE__->belongs_to(Rpms => 'Sophie::Base::Result::Rpms', 'pkgid'); 
  • server/trunk/web/lib/Sophie/Controller/0Explorer.pm

    r38 r43  
    2727    $c->stash->{path} = $dir; 
    2828    $c->stash->{explorerurl} = '/explorer' . ($dir ? "/$dir" : ''); 
     29 
     30    my $rsdist = $c->forward('/search/distrib_search', [ $c->session->{__explorer} ]); 
    2931    $c->stash->{xmlrpc} = [ $c->model('Base') 
    3032      ->resultset('Files') 
    3133      ->search( 
    32           { dirname => '/' . ($dir ? "$dir/" : '') }, 
     34          { 
     35              dirname => '/' . ($dir ? "$dir/" : ''), 
     36              pkgid => { IN => $rsdist->get_column('pkgid')->as_query, }, 
     37          }, 
    3338          { 
    3439              order_by => [ 'basename' ], 
     
    4550    $c->stash->{path} = $dir; 
    4651    $c->stash->{explorerurl} = '/explorer' . ($dir ? "/$dir" : ''); 
     52 
     53    my $rsdist = $c->forward('/search/distrib_search', [ $c->session->{__explorer} ]); 
     54 
    4755    $c->stash->{xmlrpc} = [  
    4856        map { { pkgid => $_->get_column('pkgid') } } 
     
    5058      ->resultset('Files') 
    5159      ->search({ 
    52               dirname => '/' . ($dir ? "$dir/" : ''), basename => $basename 
     60              dirname => '/' . ($dir ? "$dir/" : ''), basename => $basename, 
     61              pkgid => { IN => $rsdist->get_column('pkgid')->as_query, }, 
    5362          }, 
    5463          {  
  • server/trunk/web/lib/Sophie/Controller/Explorer.pm

    r40 r43  
    2424sub index :Path { 
    2525    my ( $self, $c, @args ) = @_; 
     26 
     27    if (grep { exists($c->req->params->{$_}) } qw(distribution release arch)) { 
     28        $c->session->{explorer} = { 
     29            distribution => $c->req->param('distribution') || undef, 
     30            release => $c->req->param('release') || undef, 
     31            arch => $c->req->param('arch') || undef, 
     32        }; 
     33    } 
     34    $c->session->{__explorer} = $c->session->{explorer}; 
    2635 
    2736    $c->stash->{path} = join('/', grep { $_  } @args); 
  • server/trunk/web/lib/Sophie/Controller/Search.pm

    r40 r43  
    2323=cut 
    2424 
    25 my $search_param = { 
    26     rows => Sophie->config()->{'max_reply'} || 20000, 
    27     order_by => [ 'name', 'evr using >>', 'issrc' ], 
    28     select => [ 'pkgid' ], 
    29 }; 
    30  
    3125sub index :Path :Args(0) { 
    3226    my ( $self, $c ) = @_; 
    3327 
    34     $c->response->body('Matched Sophie::Controller::Search in Search.'); 
     28    if ($c->req->param('page')) { 
     29        $c->req->params->{search} = $c->session->{search}; 
     30    } 
     31 
     32    if ($c->req->param('search')) { 
     33        $c->session->{search} = $c->req->param('search'); 
     34        $c->forward('fuzzy', [ undef, $c->req->param('search') ]); 
     35        my $pager = $c->stash->{rs}->pager; 
     36        $c->stash->{pager} = $pager; 
     37        $c->stash->{xmlrpc} = [ 
     38            $c->stash->{rs}->get_column('pkgid')->all 
     39        ]; 
     40    } 
     41} 
     42 
     43sub search_param : Private { 
     44    my ($self, $c) = @_; 
     45    my $r = { 
     46        rows => Sophie->config()->{'max_reply'} || 20000, 
     47        order_by => [ 'name', 'evr using >>', 'issrc' ], 
     48        select => [ 'pkgid' ], 
     49    }; 
     50    if (!$c->req->xmlrpc->method) { 
     51        $r->{page} = $c->req->param('page') || 1; 
     52        $r->{rows} = 25; 
     53    } 
     54    return $r; 
    3555} 
    3656 
     
    4868            { 
    4969                $searchspec->{release} 
    50                     ? (release => $searchspec->{release}) 
     70                    ? (version => $searchspec->{release}) 
    5171                    : () 
    5272            } 
     
    84104            ]      
    85105        }, 
    86         $search_param, 
     106        $c->forward('search_param'), 
    87107    )->get_column('pkgid')->all ] 
    88108 
     
    120140            ]      
    121141        }, 
    122         $search_param, 
     142        $c->forward('search_param'), 
    123143    )->get_column('pkgid')->all ] 
    124144} 
     
    151171            ]      
    152172        }, 
    153         $search_param, 
     173        $c->forward('search_param'), 
    154174    )->get_column('pkgid')->all ] 
    155175} 
     
    165185    )->get_column('pkgid'); 
    166186 
    167     $c->stash->{xmlrpc} = [ $c->model('Base')->resultset('Rpms')->search( 
     187    $c->stash->{rs} =  
     188 
     189        $c->model('Base')->resultset('Rpms')->search( 
    168190        { 
    169191            -and => [ 
     
    185207            ]      
    186208        }, 
    187         $search_param, 
    188     )->get_column('pkgid')->all ] 
     209        $c->forward('search_param'), 
     210    ); 
     211     
     212    if ($c->req->xmlrpc->method) { 
     213        $c->stash->{xmlrpc} = [  
     214            $c->stash->{rs}->get_column('pkgid')->all 
     215        ]; 
     216    } 
    189217} 
    190218 
     
    208236        }, 
    209237        { 
    210             %$search_param, 
     238            %{$c->forward('search_param')}, 
    211239            select => [  
    212240                "ts_rank_cd(to_tsvector('english', description),to_tsquery(?)) as rank", 
  • server/trunk/web/root/templates/includes/header.tt

    r40 r43  
    1111    <meta name="REVISIT-AFTER" content="[% IF metarevisite %][% metarevisite %][% ELSE %]15[% END %] days"> 
    1212    <link rel="icon" href="[%- c.uri_for('/static', 'sophie.ico') -%]" type="image/x-icon"> 
    13     <script type="text/javascript" language="JavaScript" src="[% c.uri_for('/static', 'CalendarPopup.js') %]"></script> 
    1413    <script type="text/javascript" language="JavaScript" src="[% c.uri_for('/static', 'prototype.js') %]"></script> 
    1514    <script type="text/javascript" language="JavaScript" src="[% c.uri_for('/static', 'effects.js') %]"></script> 
     
    2423        <p id="sitename">Sophie</p> 
    2524        <p id="sophie_menu"> 
     25        <span><a href="[% c.uri_for('/search') %]">Search</a></span> 
    2626        <span><a href="[% c.uri_for('/distrib') %]">Distribution</a></span> 
    2727        <span><a href="[% c.uri_for('/explorer') %]">Explorer</a></span> 
Note: See TracChangeset for help on using the changeset viewer.