Skip to content

Instantly share code, notes, and snippets.

@jokergoo
Created March 13, 2017 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jokergoo/6085c26eeecb108f158f863367fb8cb0 to your computer and use it in GitHub Desktop.
Save jokergoo/6085c26eeecb108f158f863367fb8cb0 to your computer and use it in GitHub Desktop.
#!c:/perl/bin/perl -w
use strict;
use LWP::Simple;
use CGI;
my $package = param("package")
if($package eq "ComplexHeatmap" or
$package eq "EnrichedHeatmap" or
$package eq "HilbertCurve" or
$package eq "gtrellis" or
$package eq "rGREAT") {
print "Content-type: image/svg+xml;\n\n";
print generate_svg($package);
} else {
print "Content-type: text/html;\n\n";
print "<html><body>not supported</body></html>\n";
}
sub generate_svg {
my $package = shift;
my $content = get("http://bioconductor.org/packages/stats/bioc/$package/$package"."_stats.tab");
die "Couldn't get it!" unless defined $content;
my @lines = split "\n", $content;
my $download = 0;
for(my $i = 1; $i < scalar(@lines); $i ++) {
my @tmp = split "\t", $lines[$i];
$download += $tmp[3];
}
my $svg = qq(<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="114" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="114" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h69v20H0z"/><path fill="#007ec6" d="M69 0h45v20H69z"/><path fill="url(#b)" d="M0 0h114v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="34.5" y="15" fill="#010101" fill-opacity=".3">downloads</text><text x="34.5" y="14">downloads</text><text x="90.5" y="15" fill="#010101" fill-opacity=".3">$download</text><text x="90.5" y="14">$download</text></g></svg>
);
return $svg;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment