Changeset 57 for server/trunk
- Timestamp:
- 12/02/10 03:58:43 (14 years ago)
- Location:
- server/trunk/web
- Files:
-
- 7 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
server/trunk/web/lib/Sophie/Controller/Distrib.pm
r55 r57 81 81 : () 82 82 }, 83 { 84 select => [ qw(name) ], 85 } 83 86 )->search_related('Release', 84 87 { … … 86 89 ? (version => $distrib->{release}) 87 90 : () 91 }, 92 { 93 select => [ qw(version) ], 88 94 } 89 95 )->search_related('Arch', … … 92 98 ? (arch => $distrib->{arch}) 93 99 : () 100 }, 101 { 102 select => [ qw(arch) ], 94 103 } 95 104 )->search_related('Medias', … … 100 109 : ()), 101 110 }, 111 { 112 select => [ qw(label group_label) ], 113 } 102 114 ); 103 115 } … … 298 310 $c->stash->{dist}{src} = 0; 299 311 ($c->stash->{pkgid}) = @{ $c->forward('/search/bytag', 300 [ $c->stash->{dist}, 'name', $name ]) };312 [ $c->stash->{dist}, 'name', $name ])->{results} }; 301 313 $c->go('/404/index') unless ($c->stash->{pkgid}); 302 314 $c->go('/rpms/rpms', [ $c->stash->{pkgid} ]); … … 306 318 my ( $self, $c, $pkgid ) = @_; 307 319 if ($pkgid) { 308 if (@{ $c->forward('/search/bypkgid', [ $c->stash->{dist}, $pkgid ]) } ) { 320 if (@{ $c->forward('/search/bypkgid', [ $c->stash->{dist}, $pkgid ]) 321 }->{results} ) { 309 322 $c->go('/rpms/rpms', [ $pkgid ]); 310 323 } else { … … 334 347 335 348 sub media_rpm_bypkgid :Chained('_media_list_rpms') PathPart('by-pkgid') { 336 my ( $self, $c, $pkgid ) = @_;349 my ( $self, $c, $pkgid, $part ) = @_; 337 350 if ($pkgid) { 338 if (@{ $c->forward('/search/bypkgid', [ $c->stash->{dist}, $pkgid ]) } ) { 339 $c->go('/rpms/rpms', [ $pkgid ]); 351 if (@{ $c->forward('/search/bypkgid', [ $c->stash->{dist}, $pkgid 352 ])->{results} } ) { 353 $c->stash->{pkgid} = $pkgid; 354 $c->go('/rpms/rpms', [ $pkgid, $part ]); 340 355 } else { 341 356 $c->go('/404/index'); -
server/trunk/web/lib/Sophie/Controller/Rpms.pm
r52 r57 104 104 } 105 105 106 sub alldeps: XMLRPCLocal {106 sub location : XMLRPCLocal { 107 107 my ($self, $c, $pkgid) = @_; 108 109 $c->stash->{xmlrpc} = [ 110 map { 111 { 112 distribution => $_->get_column('name'), 113 release => $_->get_column('version'), 114 arch => $_->get_column('arch'), 115 media => $_->get_column('label'), 116 media_group => $_->get_column('group_label'), 117 } 118 } 119 $c->forward('/distrib/distrib_rs', [ {} ]) 120 ->search_related('MediasPaths') 121 ->search_related('Paths') 122 ->search_related('Rpmfiles', 123 { pkgid => $pkgid }, 124 { 125 select => [ qw(name version arch label group_label) ], 126 } 127 )->all ] 128 129 130 } 131 132 sub rpms_ :PathPrefix :Chained :CaptureArgs(1) { 133 my ( $self, $c, $pkgid ) = @_; 134 $c->stash->{pkgid} = $pkgid if($pkgid); 135 { 136 my $match = $c->stash->{pkgid}; 137 ($c->stash->{rpmurl}) = $c->req->path =~ 138 m{(.*/\Q$match\E)(?:/[^/]+)?$}; 139 } 140 #$c->model('Base')->resultset('Rpms')->search(pkgid => $pkgid)->next; 141 $c->stash->{rpms}{info} = 142 $c->forward('info', [ $c->stash->{pkgid} ]); 143 $c->stash->{rpms}{location} = 144 $c->forward('location', [ $c->stash->{pkgid} ]); 145 } 146 147 sub rpms : Private { 148 my ( $self, $c, $pkgid, $subpart) = @_; 149 # Because $c->forward don't take into account Chained sub 150 $c->forward('rpms_', [ $pkgid ]); 151 for ($subpart || '') { 152 /^deps$/ and $c->go('alldeps', [ $pkgid ]); 153 /^files$/ and $c->go('files', [ $pkgid ]); 154 /^changelog$/ and $c->go('changelog', [ $pkgid ]); 155 } 156 157 return $c->stash->{xmlrpc} = $c->stash->{rpms}; 158 } 159 160 sub rpms__ : Chained('/rpms/rpms_') :PathPart('') :Args(0) :XMLRPCLocal { 161 my ( $self, $c ) = @_; 162 163 $c->go('rpms', [ $c->stash->{pkgid} ]); 164 } 165 166 167 sub alldeps :Chained('rpms_') :PathPart('deps') :Args(0) :XMLRPCLocal { 168 my ( $self, $c, $pkgid ) = @_; 169 $pkgid ||= $c->stash->{pkgid}; 108 170 109 171 my %deps; … … 133 195 } 134 196 135 sub files : XMLRPCLocal { 136 my ($self, $c, $pkgid) = @_; 197 sub files :Chained('rpms_') :PathPart('files') :Args(0) :XMLRPCLocal { 198 my ( $self, $c, $pkgid ) = @_; 199 $pkgid ||= $c->stash->{pkgid}; 137 200 138 201 my @col = qw(dirname basename md5 size); … … 163 226 } 164 227 165 sub changelog : XMLRPCLocal { 166 my ($self, $c, $pkgid) = @_; 228 sub changelog :Chained('rpms_') :PathPart('changelog') :Args(0) { 229 my ( $self, $c, $pkgid ) = @_; 230 $pkgid ||= $c->stash->{pkgid}; 167 231 168 232 my @ch; … … 189 253 } 190 254 191 192 sub rpms : Chained : PathPart :XMLRPCLocal {193 my ( $self, $c, $pkgid ) = @_;194 $c->stash->{pkgid} = $c->model('Base')->resultset('Rpms')->search(pkgid => $pkgid)->next;195 $c->stash->{xmlrpc} = {196 info => $c->forward('info', [ $pkgid ]),197 changelog => $c->forward('changelog', [ $pkgid ]),198 files => $c->forward('files', [ $pkgid ]),199 deps => $c->forward('alldeps', [ $pkgid ]),200 };201 }202 203 255 =head1 AUTHOR 204 256 -
server/trunk/web/lib/Sophie/Controller/Search.pm
r55 r57 93 93 } 94 94 $c->stash->{xmlrpc}{results} = [ $rs->get_column('pkgid')->all ]; 95 return $c->stash->{xmlrpc}; 95 96 } 96 97 -
server/trunk/web/root/static/sophie.css
r54 r57 9 9 } 10 10 11 #sophie_rpm_description p { 12 padding-left: 1em; 13 padding-right: 1em; 14 } 15 11 16 .pkgid { 12 17 font-family: monospace; 13 18 } 19 20 .filename { 21 font-family: monospace; 22 } 23 24 .filename td { 25 padding-left: 1em; 26 padding-right: 1em; 27 font-size: 1.2em; 28 } -
server/trunk/web/root/templates/html/rpms/rpms.html
r27 r57 1 1 <!-- $Id$ --> 2 2 3 [% INCLUDE 'rpms/menu.tt' %] 4 3 5 [% INCLUDE 'rpms/rpms.tt' %] -
server/trunk/web/root/templates/html/rpms/rpms.tt
r50 r57 1 1 <!-- $Id$ --> 2 2 3 <div id="sophie_ tags">3 <div id="sophie_info"> 4 4 <ul id="sophie_tag"> 5 5 <li class="tag">Name: [% xmlrpc.info.name | html %]</li> … … 14 14 </ul> 15 15 16 Description: 17 <p>[% xmlrpc.info.description | html %]</p> 16 <h2>Description:</h2> 17 <div id="sophie_rpm_description"> 18 [% xmlrpc.info.description | html | html_para %] 19 </div> 18 20 </div> 19 21 20 <div id="sophie_deps">21 22 [% BLOCK deps %]23 [% FOREACH dep = deplist %]24 [% '<ul class="sophie_deps">' IF loop.first %]25 <li>26 [% dep.name | html %]27 [% IF dep.evr %][% dep.sense | html %] [% dep.evr | html %][% END %]28 </li>29 [% '</ul>' IF loop.last %]30 [% END %]31 [% END %]32 33 [% IF xmlrpc.deps.P.size %]34 Provides:35 [% PROCESS deps deplist = xmlrpc.deps.P %]36 [% END %]37 38 [% IF xmlrpc.deps.R.size %]39 Requires:40 [% PROCESS deps deplist = xmlrpc.deps.R %]41 [% END %]42 43 [% IF xmlrpc.deps.C.size %]44 Conflict:45 [% PROCESS deps deplist = xmlrpc.deps.C %]46 [% END %]47 48 [% IF xmlrpc.deps.O.size %]49 Obsoletes:50 [% PROCESS deps deplist = xmlrpc.deps.O %]51 [% END %]52 53 [% IF xmlrpc.deps.E.size %]54 Enhanced:55 [% PROCESS deps deplist = xmlrpc.deps.E %]56 [% END %]57 58 [% IF xmlrpc.deps.S.size %]59 Suggest:60 [% PROCESS deps deplist = xmlrpc.deps.S %]61 [% END %]62 63 <div id="sophie_files">64 Files:65 66 [% FOREACH file = xmlrpc.files %]67 [%- IF loop.first -%]68 <table border=0 style="font-family: monospace">69 [%- END -%]70 <tr><td>[% file.perm %]</td><td>[% file.size | format('%6d') %]</td><td>[%71 file.user | format('%10s') -%]</td>72 <td>[%- file.group | format('%10s') %]</td><td>[% file.filename %]</td>73 <td>[% file.has_content %]</tr>74 [%- IF loop.last -%]75 </table>76 [%- END -%]77 [% END %]78 </div> -
server/trunk/web/t/controller_Distrib.t
r53 r57 7 7 # know existing data: 8 8 my $distribution = 'Mandriva'; 9 my $release = ' cooker';10 my $arch = ' i586';9 my $release = '2010.1'; 10 my $arch = 'x86_64'; 11 11 my $media = 'main-release'; 12 my $pkgid = '45db73adf5f9ceabc8f9ea1dabccffcc'; 13 my $rpmname = 'rpm'; 12 14 13 15 BEGIN { use_ok 'Catalyst::Test', 'Sophie' } … … 32 34 ok( request("/distrib/$distribution/$release/$arch")->is_success, 'Request should succeed' ); 33 35 ok( request("/distrib/$distribution/$release/$arch/media")->is_success, 'Request should succeed' ); 36 warn "/distrib/$distribution/$release/$arch/media/$media/by-pkgid/$pkgid"; 37 ok( 38 request("/distrib/$distribution/$release/$arch/media/$media/by-pkgid/$pkgid") 39 ->is_success, "request media/pkgid"); 40 ok( 41 request("/distrib/$distribution/$release/$arch/media/$media/by-pkgid/$pkgid/deps") 42 ->is_success, "request media/pkgid/deps"); 43 ok( 44 request("/distrib/$distribution/$release/$arch/media/$media/by-pkgid/$pkgid/files") 45 ->is_success, "request media/pkgid/files"); 46 ok( 47 request("/distrib/$distribution/$release/$arch/media/$media/by-pkgid/$pkgid/changelog") 48 ->is_success, "request media/pkgid/changelog"); 34 49 done_testing(); -
server/trunk/web/t/controller_Rpms.t
r4 r57 6 6 BEGIN { use_ok 'Sophie::Controller::Rpms' } 7 7 8 my $pkgid = '45db73adf5f9ceabc8f9ea1dabccffcc'; 9 8 10 ok( request('/rpms')->is_success, 'Request should succeed' ); 11 ok( request("/rpms/$pkgid")->is_success, 'Request a pkgid should succeed' ); 12 ok( request("/rpms/$pkgid/deps")->is_success, 'Request a pkgid/deps should succeed' ); 13 ok( request("/rpms/$pkgid/files")->is_success, 'Request a pkgid/files should succeed' ); 14 ok( request("/rpms/$pkgid/changelog")->is_success, 'Request a pkgid/changelog should succeed' ); 9 15 done_testing();
Note: See TracChangeset
for help on using the changeset viewer.