- Location:
- /server/trunk/web
- Files:
-
- 14 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
/server/trunk/web/Makefile.PL
r20 r30 10 10 all_from 'lib/Sophie.pm'; 11 11 12 requires 'DBD::Pg'; 13 requires 'DBIx::Class'; 14 12 15 requires 'Catalyst::Runtime' => '5.80025'; 13 16 requires 'Catalyst::Plugin::ConfigLoader'; … … 16 19 requires 'Moose'; 17 20 requires 'namespace::autoclean'; 21 requires 'Catalyst::Plugin::Authentication' => '0'; 22 requires 'Catalyst::Plugin::Session' => '0'; 23 requires 'Catalyst::Plugin::Session::Store::DBI' => '0'; 24 requires 'Catalyst::Plugin::Session::State::Cookie' => '0'; 25 requires 'Catalyst::Plugin::Prototype' => '0'; 26 requires 'Catalyst::View::TT' => '0'; 27 requires 'Catalyst::View::JSON' => '0'; 28 requires 'Catalyst::Plugin::Compress::Zlib'; 29 requires 'Catalyst::Plugin::Server'; 30 requires 'Catalyst::Plugin::Server::XMLRPC'; 18 31 requires 'Config::General'; # This should reflect the config file format you've chosen 19 32 # See Catalyst::Plugin::ConfigLoader for supported formats … … 22 35 23 36 install_script glob('script/*.pl'); 24 auto_install; 25 WriteAll; 37 38 WriteMakefile( 39 macro => { 40 DESTRPMDIR => '$(shell pwd)', 41 }, 42 ); 43 44 package MY; 45 46 sub install { 47 my ($self) = @_; 48 my $section = $self->SUPER::install(); 49 50 $section =~ s/(^install ::.*)/$1 install_config/m; 51 52 $section .= qq[ 53 install_config: sophie.conf.in 54 \tinstall -d \$(DESTDIR)/etc 55 \tinstall -d \$(DESTDIR)/etc/sophie 56 \tinstall sophie.conf.in \$(DESTDIR)/etc/sophie/sophie.conf 57 58 ]; 59 60 $section 61 } 62 63 sub postamble { 64 <<EOF; 65 # .PHONY .= svnmanifest 66 67 svnmanifest: 68 \tsvn ls -R| grep -v "/\$\$" > MANIFEST 69 70 ChangeLog: 71 \tsvn log > ChangeLog 72 73 \$(DISTNAME).spec: \$(DISTNAME).spec.in Makefile 74 \tsed -e 's/\@VERSION@/\$(VERSION)/' < \$< > \$@ 75 76 rpm: \$(DISTVNAME).tar.gz \$(DISTNAME).spec 77 \tmkdir \$(DESTRPMDIR)/noarch || : 78 \trpmbuild -ba --clean\\ 79 \t --define "_sourcedir `pwd`" \\ 80 \t --define "_specdir `pwd`" \\ 81 \t --define "_srcrpmdir \$(DESTRPMDIR)" \\ 82 \t --define "_rpmdir \$(DESTRPMDIR)" \\ 83 \t \$(DISTNAME).spec 84 85 svnrpm: \$(DISTVNAME).tar.gz \$(DISTNAME).spec 86 \tmkdir \$(DESTRPMDIR)/noarch || : 87 \trpmbuild -ba --clean\\ 88 \t --define "_sourcedir `pwd`" \\ 89 \t --define "_specdir `pwd`" \\ 90 \t --define "_srcrpmdir \$(DESTRPMDIR)" \\ 91 \t --define "_rpmdir \$(DESTRPMDIR)" \\ 92 \t --define "svnrelease `LC_ALL=C svn info | grep '^Revision:' | sed 's/Revision: //'`" \\ 93 \t \$(DISTNAME).spec 94 95 EOF 96 } -
/server/trunk/web/lib/Sophie/Base.pm
r20 r30 6 6 use base qw/DBIx::Class::Schema/; 7 7 use FindBin qw($Bin); 8 use Config::General; 8 9 9 10 __PACKAGE__->load_namespaces(); … … 18 19 sub db { 19 20 my ($self) = @_; 20 require Config::General; 21 my $cg = Config::General->new("$Bin/../sophie.conf"); 22 my $config = { $cg->getall() }; 21 my $config; 22 foreach my $file ('sophie.conf', "$Bin/../sophie.conf", 23 '/etc/sophie/sophie.conf') { 24 -f $file or next; 25 my $cg = Config::General->new($file); 26 $config = { $cg->getall() }; 27 } 28 $config or die "No config found"; 23 29 24 30 DBI->connect_cached( -
/server/trunk/web/lib/Sophie/Controller/Distrib.pm
r20 r30 33 33 my $rs = $c->model('Base')->resultset('Distribution'); 34 34 if (!$distribution) { 35 return $c->stash->{xmlrpc} = [ map { $_->name } $rs->all ]; 35 return $c->stash->{xmlrpc} = [ map { $_->name } 36 $rs->search(undef, { order_by => ['name'] })->all ]; 36 37 } 37 38 $rs = $rs->search(name => $distribution)->search_related('Release'); 38 39 if (!$release) { 39 return $c->stash->{xmlrpc} = [ map { $_->version } $rs->all ];40 40 return $c->stash->{xmlrpc} = [ map { $_->version } 41 $rs->search(undef, { order_by => ['version'] })->all ]; 41 42 } 42 43 $rs = $rs->search(version => $release)->search_related('Arch'); 43 44 if (!$arch) { 44 return $c->stash->{xmlrpc} = [ map { $_->arch } $rs->all ]; 45 return $c->stash->{xmlrpc} = [ map { $_->arch } 46 $rs->search(undef, { order_by => ['arch'] })->all ]; 45 47 } 46 48 $rs = $rs->search(arch => $arch)->search_related('Medias'); 47 $c->stash->{xmlrpc} = [ map { $_->label } $rs->all ];48 $c->stash->{xmlrpc}49 return $c->stash->{xmlrpc} = [ map { $_->label } 50 $rs->search(undef, { order_by => ['label'] })->all ]; 49 51 } 50 52 … … 117 119 sub distrib :Chained('distrib_view') PathPart('') { 118 120 my ( $self, $c ) = @_; 119 $c->forward('list', $c->stash->{dist}); 120 $c->forward('rpms', $c->stash->{dist}); 121 $c->forward('list', [ $c->stash->{dist} ]); 121 122 # TODO store properly results 122 123 # No call from json here … … 208 209 sub rpm_by_name :Chained('distrib_view') PathPart('rpms/by-name') Args(1) { 209 210 } 210 sub rpm_by_pkid :Chained('distrib_view') PathPart(' rpms/by-pkgid') Args(1) {211 sub rpm_by_pkid :Chained('distrib_view') PathPart('by-pkgid') Args(1) { 211 212 } 212 213 … … 250 251 $c->forward('media_rpms', [ $c->stash->{dist}, $c->stash->{media} ]); 251 252 } 252 sub media_rpm_byname :Chained('_media_list_rpms') PathPart('rpms/by_name') { 253 my ( $self, $c ) = @_; 254 } 255 sub media_srpm_byname :Chained('_media_list_rpms') PathPart('srpms/by_name') { 256 my ( $self, $c ) = @_; 257 } 258 sub media_rpm_bypkgid :Chained('_media_list_rpms') PathPart('rpms/by_pkgid') { 259 my ( $self, $c ) = @_; 253 254 sub media_rpm_byname :Chained('_media_list_rpms') PathPart('rpms/by-name') { 255 my ( $self, $c ) = @_; 256 } 257 sub media_srpm_byname :Chained('_media_list_rpms') PathPart('srpms/by-name') { 258 my ( $self, $c ) = @_; 259 } 260 sub media_rpm_bypkgid :Chained('_media_list_rpms') PathPart('by-pkgid') { 261 my ( $self, $c, $pkgid ) = @_; 262 $c->forward('/rpms/rpms', [ $pkgid ]); 260 263 } 261 264 -
/server/trunk/web/lib/Sophie/Controller/Rpms.pm
r20 r30 2 2 use Moose; 3 3 use namespace::autoclean; 4 use Encode::Guess; 5 use Encode; 4 6 5 7 BEGIN {extends 'Catalyst::Controller'; } … … 30 32 sub queryformat : XMLRPCLocal { 31 33 my ( $self, $c, $pkgid, $qf ) = @_; 32 @{$c->stash->{xmlrpc}} = map { $_->get_column('qf') } $c->model('Base')->resultset('Rpms')->search(34 $c->stash->{xmlrpc} = $c->model('base')->resultset('Rpms')->search( 33 35 { pkgid => $pkgid }, 34 36 { … … 37 39 bind => [ $qf ], 38 40 } 39 )-> all;41 )->next->get_column('qf'); 40 42 } 41 43 42 44 sub tag : XMLRPCLocal { 43 45 my ( $self, $c, $pkgid, $tag ) = @_; 44 @{$c->stash->{xmlrpc}} =map { $_->get_column('tag') } $c->model('Base')->resultset('Rpms')->search(46 $c->stash->{xmlrpc} = [ map { $_->get_column('tag') } $c->model('Base')->resultset('Rpms')->search( 45 47 { pkgid => $pkgid }, 46 48 { … … 49 51 bind => [ $tag ], 50 52 } 51 )->all; 52 } 53 )->all ] 54 } 55 56 57 sub info : XMLRPCLocal { 58 my ($self, $c, $pkgid, $deptype) = @_; 59 60 my %info; 61 foreach (qw(name version release epoch url group size packager 62 url summary description sourcerpm license buildhost 63 pkgid builddate arch distribution)) { 64 if (my $r = $c->model('base')->resultset('Rpms')->search( 65 { pkgid => $pkgid }, 66 { 67 select => [ qq{rpmqueryformat("header", ?)} ], 68 as => [ 'qf' ], 69 bind => [ "%{$_}" ], 70 } 71 )->next) { 72 $info{$_} = $r->get_column('qf'); 73 } 74 } 75 76 return $c->stash->{xmlrpc} = \%info; 77 } 78 53 79 54 80 sub deps : XMLRPCLocal { … … 81 107 my ($self, $c, $pkgid) = @_; 82 108 109 my %deps; 83 110 foreach ( 84 111 $c->model('Base')->resultset('Deps')->search( … … 94 121 }, 95 122 )->all) { 96 push( @{ $ c->stash->{xmlrpc}{deps}{$_->get_column('deptype')} },123 push( @{ $deps{$_->get_column('deptype')} }, 97 124 { 98 125 name => $_->get_column('depname'), … … 103 130 ); 104 131 } 132 $c->stash->{xmlrpc} = \%deps; 105 133 } 106 134 … … 108 136 my ($self, $c, $pkgid) = @_; 109 137 110 @{ $c->stash->{xmlrpc}{files} } =map {138 $c->stash->{xmlrpc} = [ map { 111 139 { 112 140 filename => $_->get_column('dirname') . $_->get_column('basename'), … … 121 149 122 150 }, 123 )->all; 151 )->all ]; 152 } 153 154 sub changelog : XMLRPCLocal { 155 my ($self, $c, $pkgid) = @_; 156 157 my @ch; 158 foreach ($c->model('Base')->resultset('RpmsChangelog')->search({}, 159 { 160 bind => [ $pkgid ], 161 order_by => [ 'time::int desc' ], 162 }, 163 )->all) { 164 my $chentry; 165 my $enc = guess_encoding($_->get_column('text'), qw/latin1/); 166 $chentry->{text} = $enc && ref $enc 167 ? encode('utf8', $_->get_column('text')) 168 : $_->get_column('text'); 169 $enc = guess_encoding($_->get_column('name'), qw/latin1/); 170 $chentry->{name} = $enc && ref $enc 171 ? encode('utf8', $_->get_column('name')) 172 : $_->get_column('name'); 173 $chentry->{time} = $_->get_column('time'); 174 push(@ch, $chentry); 175 } 176 177 $c->stash->{xmlrpc} = \@ch; 124 178 } 125 179 … … 127 181 sub rpms : Chained : PathPart { 128 182 my ( $self, $c, $pkgid ) = @_; 129 $c->stash->{pkgid} = $c->model('Base::Rpms')->search(pkgid => $pkgid)->next; 130 $c->log->debug('rpms ' . $c->stash->{pkgid}); 183 $c->stash->{pkgid} = $c->model('Base')->resultset('Rpms')->search(pkgid => $pkgid)->next; 184 $c->stash->{xmlrpc} = { 185 info => $c->forward('info', [ $pkgid ]), 186 changelog => $c->forward('changelog', [ $pkgid ]), 187 files => $c->forward('files', [ $pkgid ]), 188 deps => $c->forward('alldeps', [ $pkgid ]), 189 }; 131 190 } 132 191 -
/server/trunk/web/root/templates/includes/header.tt
r20 r30 18 18 <div style="float:left"> 19 19 <p id="sitename">Sophie</p> 20 <p id="sophie_menu">fff</p> 20 <p id="sophie_menu"> 21 <span><a href="[% c.uri_for('/distrib') %]">Distribution</a></span> 22 </p> 21 23 </div> 22 24 <div style="clear:both"></div> -
/server/trunk/web/t/controller_Distrib.t
r20 r30 7 7 # know existing data: 8 8 my $distribution = 'Mandriva'; 9 my $release = 'cooker'; 10 my $arch = 'i586'; 9 11 10 12 BEGIN { use_ok 'Catalyst::Test', 'Sophie' } … … 26 28 ok( request( xmlrpcreq('distrib.list') ), "XMLRPC"); 27 29 ok( request( xmlrpcreq('distrib.list', $distribution) ), "XMLRPC"); 30 ok( request("/distrib/$distribution/$release")->is_success, 'Request should succeed' ); 31 ok( request("/distrib/$distribution/$release/$arch")->is_success, 'Request should succeed' ); 28 32 done_testing();
Note: See TracChangeset
for help on using the changeset viewer.