Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 42 additions & 10 deletions lib/CPAN/Testers/Web.pm
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,44 @@ sub startup ( $app ) {
catdir( dist_dir( 'CPAN-Testers-Web' ), 'public' );
unshift @{ $app->commands->namespaces }, 'CPAN::Testers::Web::Command';


$app->moniker( 'web' );
# This application has no configuration yet
$app->plugin( Config => {
default => {
api_host => 'api.cpantesters.org',
dist_modules => [qw/
Mojolicious
Moose
Moo
DBIx-Class
App-cpanminus
DBI
Plack
DateTime
Devel-NYTProf
Test-Simple
Path-Tiny
Dist-Zilla
Scalar-List-Utils
App-perlbrew
Try-Tiny
libwww-perl
AnyEvent
Catalyst-Runtime
Data-Printer
Dancer
Template-Toolkit
Type-Tiny
Perl-Tidy
Dancer2
Perl-Critic
ack
Carton
Getopt-Long
List-MoreUtils
Task-Kensho
/]
},
} );

Expand Down Expand Up @@ -214,20 +247,19 @@ sub startup ( $app ) {
$c->render( 'user/dist/settings' );
} );

$r->get( '/dist/:dist/#version', [ format => [qw( html rss )] ], { format => 'html', version => 'latest' } )
->name( 'reports.dist' )
->to( 'reports#dist_reports' );

$r->get( '/release/:dist', [ format => [qw( json )] ], { format => 'json' } )
->name( 'release.dist' )
->to( 'reports#dist_versions' );

$r->get( '/dist' )
->name( 'dist-search' )
->to( cb => sub {
my ( $c ) = @_;
$c->render( 'dist-search' );
} );
$r->get( '/dist/:dist' )->name( 'dist-view' )->to( 'dist#view', [ format => [qw(html)] ], { format => 'html', version => 'latest' } );
$r->get( '/dist/:dist/releases' )->name( 'dist-releases' )->to( 'dist#releases' );

$r->get( '/dist/:dist/releases/#version' )->name( 'dist-reports' )->to( 'dist#reports' );

$r->get( '/dist/:dist/#version' )->name( 'dist-view' )->to( 'dist#view', [ format => [qw(html)] ], { format => 'html', version => 'latest' } );
$r->get( '/dist' )->name( 'dist-search' )->to( 'dist#search' );
$r->post( '/dist' )->name( 'dist-recent' )->to( 'dist#recent' );
$r->post( '/dist/valid' )->name( 'dist-valid' )->to( 'dist#valid' );

$r->get( '/author/:author', [ format => [qw( html rss json)] ] )
->name( 'reports.author' )
Expand Down
156 changes: 156 additions & 0 deletions lib/CPAN/Testers/Web/Controller/Dist.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
package CPAN::Testers::Web::Controller::Dist;
our $VERSION = '0.001';
# ABSTRACT: Endpoints for viewing and managing distributions

=head1 DESCRIPTION

=head1 SEE ALSO

=cut

use Mojo::Base 'Mojolicious::Controller';
use CPAN::Testers::Web::Base;
use CPAN::Testers::Web::Controller::Legacy;

=method search

Landing page for /dist

Lists modules configured in the config

=cut

sub search ( $c ) {
$c->render('dist/search',
dists => $c->config->{dist_modules}
);
}

=method view

Render Dist view

=cut

sub view ( $c ) {
my $version = $c->param('version') || 'latest';
$version =~ s/\.(html|rss)$//;
$c->render('dist/view',
dist => $c->param('dist'),
version => $version
);
}

=method recent

Expects a list of dists and will return the most recent for each.

=cut

sub recent ( $c ) {
my $join = $c->schema->perl5->resultset('Release')->search({
dist => { -in => $c->req->json->{dists} }
}, {
group_by => [qw( me.dist )],
select => [qw/dist/, \('MAX(version)')],
as => [qw/dist version/]
});

if (!$join->count) {
return $c->render( json => { dists => [] } );
}

my $rs = $c->schema->perl5->resultset('Release')->search({
-or => [
map +{ 'me.dist' => $_->dist, 'me.version' => $_->version }, $join->all()
],
}, {
join => 'upload'
});

$c->render( json => {
dists => [
map +{
$_->get_inflated_columns,
released => $_->upload->released->datetime( ' ' ),
},
$rs->all
]

} );
}

=method valid

validate that a dist exists

=cut

sub valid ( $c ) {
my $rs = $c->schema->perl5->resultset('Release')->search({
dist => { like => $c->req->json->{dist} . '%' }
}, {
distinct => 1,
select => ['dist'],
as => ['dist'],
rows => 50
});

$c->render( json => {
dists => [
map { $_->dist }
$rs->all
]
} );
}

=method releases

Returns all releases for the dist

=cut

sub releases ( $c ) {
my $rs = $c->schema->perl5->resultset('Release')->search({
'me.dist' => $c->param('dist')
}, {
join => 'upload',
order_by => 'upload.released'
});

$c->render( json => {
dists => [
map +{
$_->get_inflated_columns,
released => $_->upload->released->datetime( ' ' ),
},
$rs->all
]
} );
}

=method reports

Returns all reports for the specific dist version

=cut

sub reports ( $c ) {
my $rs = $c->schema->perl5->resultset('Stats')->search({
'me.dist' => $c->param('dist'),
'me.version' => $c->param('version'),
}, {
order_by => { -desc => 'fulldate' }
});

$c->render( json => {
reports => [
map +{
$_->get_inflated_columns,
},
$rs->all
]
} );
}

1;
64 changes: 64 additions & 0 deletions share/public/css/cpantesters.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,67 @@ body {
margin-bottom: 1em;
}


#popular tr th:first-child {
min-width: 150px;
}

.loading-content {
position: relative;
width: 100%;
height: 400px;
margin-top: 1em;
overflow: hidden;
border: 1px solid rgb(220, 224, 227);
background-color: rgb(240, 244, 247);
}
.loading-content:after {
content: "";
display: block;
position: absolute;
height: 100%;
width: 20%;
top: 0;
animation: load 1s 1s infinite;
background-image: linear-gradient(
to right,
rgba(255, 255, 255, 0) 0%,
rgba(255, 255, 255, 0.5) 50%,
rgba(255, 255, 255, 0) 100%
);
}
.loading-content.small-graph, .small-graph {
height: 300px;
width: 25%;
}
.loading-content.loading-content-short-height {
height: 110px;
}
.flex {
display: flex;
width: 100%;
}
.flex-justify {
justify-content: space-between;
align-content: center;
align-items: center;
}
.bg-unknown {
background: #f6ddc3;
}


@keyframes load {
from {
left: -100px;
}
to {
left: 100%;
}
}

@media only screen and (max-width: 600px) {
#popular tr th:first-child {
min-width: auto;
}
}
Loading