-
-
Save jberger/f9a71e20904976746284 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/perl | |
# | |
# cpan-github-dists | |
# | |
# Use the MetaCPAN API to build a list of CPAN distributions that have a github repo | |
# We show the 2000 most-recently released distributions | |
# | |
# See output for this at http://neilb.org/github-dists.html | |
# | |
use Mojolicious::Lite; | |
use MetaCPAN::Client; | |
helper dists => sub { | |
my $client = MetaCPAN::Client->new(); | |
my $query = { all => [ | |
{ status => 'latest' }, | |
{ 'resources.repository.url' => '*github*' } | |
] | |
}; | |
my $params = { fields => [qw(distribution author date version)] }; | |
my $result_set = $client->release($query, $params); | |
my %dist; | |
while (my $release = $result_set->next) { | |
my $distname = $release->distribution; | |
next if $distname =~ /^(Acme|Task-BeLike|Dist-Zilla-PluginBundle-Author)/; | |
if (!exists($dist{$distname}) || $dist{$distname}{date} lt $release->date) { | |
$dist{ $distname } = { date => $release->date, version => $release->version, author => $release->author }; | |
} | |
} | |
return \%dist; | |
}; | |
any '/:number' => { number => 2000 } => sub{ | |
my $c = shift; | |
$c->render( 'main' => dists => $c->dists ); | |
}; | |
app->start; | |
__DATA__ | |
@@ table_body.html.ep | |
% my $count = 0; | |
% foreach my $distname (sort { $dists->{$b}{date} cmp $dists->{$a}{date} } keys %$dists) { | |
% my $author = $dists->{$distname}{author}; | |
<tr> | |
<td><a href="https://metacpan.org/release/<%= $distname %>"><%= $distname %></a></td> | |
<td><a href="https://metacpan.org/author/<%= $author %>"><%= $author %></a></td> | |
<td><%= $dists->{$distname}{version} %></td> | |
<td><%= $dists->{$distname}{date} %></td> | |
</tr> | |
% last if ++$count >= $number; | |
% } | |
@@ main.html.ep | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>CPAN Adoption Candidates</title> | |
<link rel=stylesheet href="http://neilb.org/adoption/adoption.css" type="text/css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> | |
<script src="http://neilb.org/adoption/jquery.tablesorter.min.js"></script> | |
</head> | |
<body> | |
<h1>CPAN distributions with a github repository</h1> | |
<table> | |
<thead> | |
<tr> | |
<th align=left>Distribution</th> | |
<th align=left>Author</th> | |
<th align=left>Version</th> | |
<th align=left>Date</th> | |
</tr> | |
</thead> | |
<tbody> | |
%= include 'table_body' | |
</tbody> | |
</table> | |
<script> | |
$().ready( function () { | |
$('table').tablesorter(); | |
}); | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment