Changeset 114
- Timestamp:
- 12/12/10 20:10:15 (13 years ago)
- Location:
- server/trunk/web
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
server/trunk/web/lib/Sophie/Base/Result/Distribution.pm
r2 r114 6 6 7 7 __PACKAGE__->table('distributions'); 8 __PACKAGE__->add_columns(qw/distributions_key name /);8 __PACKAGE__->add_columns(qw/distributions_key name shortname/); 9 9 __PACKAGE__->set_primary_key('distributions_key'); 10 10 __PACKAGE__->has_many(Release => 'Sophie::Base::Result::Release', 'distributions'); -
server/trunk/web/lib/Sophie/Controller/Chat/Cmd.pm
r102 r114 23 23 =cut 24 24 25 =head2 end 26 27 =cut 28 29 sub end : Private { 30 my ($self, $c ) = @_; 31 my $reqspec = $c->req->arguments->[0]; 32 $reqspec->{max_line} ||= 4; 33 my $message = $c->stash->{xmlrpc}; 34 35 my @backup = @{ $message->{message} }; 36 my $needpaste = 0; 37 38 if (@{ $message->{message} } > ($reqspec->{max_line})) { 39 @{ $message->{message} } = 40 # -2 because line 0 and we remove one for paste url 41 @backup[0 .. $reqspec->{max_line} -2]; 42 $needpaste = 1; 43 } 44 45 if ($needpaste) { 46 my $id = $c->forward('/chat/paste', [ 'Bot paste', join("\n", @backup) ]); 47 push(@{ $message->{message} }, 'All results availlable here: ' . $c->uri_for('/chat', $id)); 48 } 49 50 $c->stash->{xmlrpc} = $message; 51 52 $c->forward('/end'); 53 } 54 25 55 =head1 BOT COMMAND 26 56 27 57 =head2 REPLY 28 29 =head1 AVAILLABLE FUNCTIONS30 58 31 59 =cut … … 45 73 return \@ARGV; 46 74 } 75 76 sub _fmt_location : Private { 77 my ($self, $c, $pkgid) = @_; 78 79 my @loc; 80 foreach (@{ $c->forward('/rpms/location', [ $pkgid ]) }) { 81 push @loc, sprintf( 82 '%s (%s, %s, %s)', 83 $_->{media}, 84 $_->{dist} || $_->{distribution}, 85 $_->{release}, 86 $_->{arch}, 87 ); 88 } 89 return join(', ', @loc); 90 } 91 92 =head1 AVAILLABLE FUNCTIONS 93 94 =cut 47 95 48 96 =head2 help [cmd] … … 66 114 message => [ 67 115 'availlable command:', 68 join(', ', grep { $_ !~ /^end$/ } @{ $self->_commands }),116 join(', ', sort grep { $_ !~ /^end$/ } @{ $self->_commands }), 69 117 ], 70 118 } … … 86 134 } 87 135 136 =head2 version [-s] NAME 137 138 Show the version of package C<NAME>. 139 140 =cut 141 88 142 sub version : XMLRPC { 89 143 my ($self, $c, $reqspec, @args) = @_; … … 103 157 foreach (@{ $rpmlist->{results} }) { 104 158 my $info = $c->forward('/rpms/basicinfo', [ $_ ]); 105 push @message, $info->{evr}; 106 } 107 return $c->stash->{xmlrpc} = { 108 message => \@message, 109 } 110 } 159 push @message, $info->{evr} . ' // ' . 160 $c->forward('_fmt_location', [ $_ ]); 161 } 162 return $c->stash->{xmlrpc} = { 163 message => \@message, 164 } 165 } 166 167 =head2 v 168 169 C<v> is an alias for C<version> command. 170 171 =cut 111 172 112 173 sub v : XMLRPC { … … 115 176 } 116 177 117 sub end : Private { 118 my ($self, $c ) = @_; 119 my $reqspec = $c->req->arguments->[0]; 120 $reqspec->{max_line} ||= 4; 121 my $message = $c->stash->{xmlrpc}; 122 123 my @backup = @{ $message->{message} }; 124 my $needpaste = 0; 125 126 if (@{ $message->{message} } > ($reqspec->{max_line})) { 127 @{ $message->{message} } = 128 # -2 because line 0 and we remove one for paste url 129 @backup[0 .. $reqspec->{max_line} -2]; 130 $needpaste = 1; 131 } 132 133 if ($needpaste) { 134 my $id = $c->forward('/chat/paste', [ 'Bot paste', join("\n", @backup) ]); 135 push(@{ $message->{message} }, $c->uri_for('/chat', $id)); 136 } 137 138 $c->stash->{xmlrpc} = $message; 139 140 $c->forward('/end'); 178 =head2 packager [-s] NAME 179 180 Show the packager of package C<NAME>. 181 182 =cut 183 184 sub packager : XMLRPC { 185 my ($self, $c, $reqspec, @args) = @_; 186 187 my @message; 188 $reqspec->{src} = 0; 189 190 @args = @{ $c->forward('_getopt', [ 191 { 192 'd=s' => \$reqspec->{distribution}, 193 'v=s' => \$reqspec->{release}, 194 'a=s' => \$reqspec->{arch}, 195 's' => sub { $reqspec->{src} = 1 }, 196 }, @args ]) }; 197 198 my $rpmlist = $c->forward('/search/byname', [ $reqspec, $args[0] ]); 199 foreach (@{ $rpmlist->{results} }) { 200 my $info = $c->forward('/rpms/queryformat', [ $_, '%{packager}' ]); 201 push @message, $info . ' // ' . 202 $c->forward('_fmt_location', [ $_ ]); 203 } 204 return $c->stash->{xmlrpc} = { 205 message => \@message, 206 } 207 } 208 209 =head2 p 210 211 Is an alias for C<packager> command. 212 213 =cut 214 215 sub p : XMLRPC { 216 my ($self, $c, @args) = @_; 217 $c->forward('packager', [ @args ]); 218 } 219 220 =head2 arch [-s] NAME 221 222 Show the architecture of package C<NAME>. 223 224 =cut 225 226 sub arch : XMLRPC { 227 my ($self, $c, $reqspec, @args) = @_; 228 229 my @message; 230 $reqspec->{src} = 0; 231 232 @args = @{ $c->forward('_getopt', [ 233 { 234 'd=s' => \$reqspec->{distribution}, 235 'v=s' => \$reqspec->{release}, 236 'a=s' => \$reqspec->{arch}, 237 's' => sub { $reqspec->{src} = 1 }, 238 }, @args ]) }; 239 240 my $rpmlist = $c->forward('/search/byname', [ $reqspec, $args[0] ]); 241 foreach (@{ $rpmlist->{results} }) { 242 my $info = $c->forward('/rpms/queryformat', [ $_, '%{arch}' ]); 243 push @message, $info . ' // ' . 244 $c->forward('_fmt_location', [ $_ ]); 245 } 246 return $c->stash->{xmlrpc} = { 247 message => \@message, 248 } 249 } 250 251 =head2 a 252 253 Is an alias to C<arch> command. 254 255 =cut 256 257 sub a : XMLRPC { 258 my ($self, $c, @args) = @_; 259 $c->forward('arch', [ @args ]); 260 } 261 262 =head2 buildtime [-s] NAME 263 264 Show the build time of package C<NAME>. 265 266 =cut 267 268 sub buildtime : XMLRPC { 269 my ($self, $c, $reqspec, @args) = @_; 270 271 my @message; 272 $reqspec->{src} = 0; 273 274 @args = @{ $c->forward('_getopt', [ 275 { 276 'd=s' => \$reqspec->{distribution}, 277 'v=s' => \$reqspec->{release}, 278 'a=s' => \$reqspec->{arch}, 279 's' => sub { $reqspec->{src} = 1 }, 280 }, @args ]) }; 281 282 my $rpmlist = $c->forward('/search/byname', [ $reqspec, $args[0] ]); 283 foreach (@{ $rpmlist->{results} }) { 284 my $info = $c->forward('/rpms/queryformat', [ $_, '%{buildtime:date}' ]); 285 push @message, $info . ' // ' . 286 $c->forward('_fmt_location', [ $_ ]); 287 } 288 return $c->stash->{xmlrpc} = { 289 message => \@message, 290 } 291 } 292 293 =head2 builddate 294 295 Is an alias for C<buildtime> command. 296 297 =cut 298 299 sub builddate : XMLRPC { 300 my ($self, $c, @args) = @_; 301 $c->forward('buildtime', [ @args ]); 302 } 303 304 =head2 builddate 305 306 Is an alias for C<buildtime> command. 307 308 =cut 309 310 sub b : XMLRPC { 311 my ($self, $c, @args) = @_; 312 $c->forward('builddate', [ @args ]); 313 } 314 315 =head2 qf rpmname format 316 317 Perform an rpm -q --qf on package named C<rpmname> 318 319 =cut 320 321 sub qf : XMLRPC { 322 my ($self, $c, $reqspec, @args) = @_; 323 my @message; 324 $reqspec->{src} = 0; 325 326 @args = @{ $c->forward('_getopt', [ 327 { 328 'd=s' => \$reqspec->{distribution}, 329 'v=s' => \$reqspec->{release}, 330 'a=s' => \$reqspec->{arch}, 331 's' => sub { $reqspec->{src} = 1 }, 332 }, @args ]) }; 333 334 my $rpmlist = $c->forward('/search/byname', [ $reqspec, $args[0] ]); 335 foreach (@{ $rpmlist->{results} }) { 336 my $info = $c->forward('/rpms/queryformat', [ $_, $args[1] ]); 337 push @message, $info; 338 } 339 return $c->stash->{xmlrpc} = { 340 message => \@message, 341 } 141 342 } 142 343 -
server/trunk/web/lib/Sophie/Controller/Distrib.pm
r92 r114 91 91 }, 92 92 { 93 select => [ qw(name ) ],93 select => [ qw(name shortname) ], 94 94 } 95 95 )->search_related('Release',
Note: See TracChangeset
for help on using the changeset viewer.