Permalink
Browse files

load cpanstats from the totals.json file

  • Loading branch information...
szabgab committed Oct 21, 2014
1 parent 77619bd commit 35c35625c67e43877090dfc22be8ba8324b45f25
Showing with 14 additions and 5 deletions.
  1. +10 −2 lib/MetaCPAN/SCO.pm
  2. +4 −0 tt/incl/footer.tt
  3. +0 −3 tt/incl/header.tt
View
@@ -2,8 +2,11 @@ package MetaCPAN::SCO;
use strict;
use warnings;
use Carp ();
use Cwd qw(abs_path);
use File::Basename qw(dirname);
use JSON qw(from_json);
use Path::Tiny qw(path);
use Plack::Builder;
use Plack::Request;
use Template;
@@ -39,10 +42,15 @@ sub run {
}
sub template {
my ( $file ) = @_;
my ( $file, $vars ) = @_;
$vars //= {};
Carp::confess 'Need to pass HASH-ref to template()'
if ref $vars ne 'HASH';
my $root = root();
$vars->{totals} = from_json path("$root/totals.json")->slurp_utf8;
my $tt = Template->new(
INCLUDE_PATH => "$root/tt",
INTERPOLATE => 0,
@@ -54,7 +62,7 @@ sub template {
POST_PROCESS => 'incl/footer.tt',
);
my $out;
$tt->process( "$file.tt", {}, \$out )
$tt->process( "$file.tt", $vars, \$out )
|| die $tt->error();
return [ '200', [ 'Content-Type' => 'text/html' ], [$out], ];
}
View
@@ -1,4 +1,8 @@
<div class="footer"><div class="cpanstats">
<% totals.distribution %> Distributions, <% totals.module %> Modules, <% totals.author %> Authors
</div></div>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.js"></script>
</body>
</html>
View
@@ -33,7 +33,4 @@
</form>
</div>
<div class="footer"><div class="cpanstats">102721 Uploads, 30564 Distributions
140336 Modules, 11782 Uploaders
</div>

0 comments on commit 35c3562

Please sign in to comment.