Changeset 270


Ignore:
Timestamp:
01/02/11 03:37:43 (13 years ago)
Author:
nanardon
Message:
  • readd whatis command
Location:
server/trunk/web/lib/Sophie/Controller
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • server/trunk/web/lib/Sophie/Controller/Chat/Cmd.pm

    r269 r270  
    217217} 
    218218 
     219sub whatis : XMLRPC { 
     220    my ($self, $c, $reqspec, @args) = @_; 
     221 
     222    $reqspec->{src} = 0; 
     223 
     224    @args = @{ $c->forward('_getopt', [ 
     225        { 
     226            'd=s' => \$reqspec->{distribution}, 
     227            'v=s' => \$reqspec->{release}, 
     228            'a=s' => \$reqspec->{arch}, 
     229            's'   => sub { $reqspec->{src} = 1 }, 
     230        }, @args ]) }; 
     231    my $res = $c->forward('/search/rpm/description', [ $reqspec, @args ]); 
     232 
     233    if (@{ $res }) { 
     234        if (@{ $res } > 100) { 
     235            return $c->stash->{xmlrpc} = { 
     236                message => [ 'I have ' . @{ $res } . ' results' ], 
     237            }; 
     238        } else { 
     239            my @names = (); 
     240            foreach (@{ $res }) { 
     241                my $info = $c->forward('/rpms/basicinfo', [ $_ ]); 
     242                push(@names, $info->{name}); 
     243            } 
     244            my @message = 'rpm name matching `' . $args[0] . '\':'; 
     245            while (@names) { 
     246                my $str = ''; 
     247                while (length($str) < 70) { 
     248                    my $item = shift(@names) or last; 
     249                    $str .= ', ' if ($str); 
     250                    $str .= $item; 
     251                } 
     252                push(@message, $str); 
     253            } 
     254            return $c->stash->{xmlrpc} = { 
     255                message => \@message, 
     256            }; 
     257        } 
     258    } else { 
     259        return $c->stash->{xmlrpc} = { 
     260            message => [ 'No rpm description matches this keywords' ], 
     261        }; 
     262    } 
     263} 
     264 
    219265=head2 version [-s] NAME 
    220266 
  • server/trunk/web/lib/Sophie/Controller/Search/Rpm.pm

    r232 r270  
    212212} 
    213213 
    214 sub description : XMLRPCPath('description') { 
     214sub description : Private { 
     215    my ($self, $c, $searchspec, @keywords) = @_; 
     216    return [ $c->forward('description_rpc')->get_column('pkgid')->all ]; 
     217} 
     218 
     219sub description_rpc : XMLRPCPath('description') { 
    215220    my ($self, $c, $searchspec, @keywords) = @_; 
    216221    $searchspec ||= {}; 
Note: See TracChangeset for help on using the changeset viewer.