Permalink
Browse files

Have 'make update' fetch recent stats and RSS and rebuild appropriately

  • Loading branch information...
1 parent d0980b5 commit 97f7eab0f7ea61f7630022f26e5c64ed9335ca4b @abh abh committed Mar 20, 2011
Showing with 37 additions and 20 deletions.
  1. +1 −0 Makefile
  2. +10 −0 bin/update_data
  3. +0 −2 data/cpan_stats.json
  4. +9 −0 lib/tpl/data/cpan-stats
  5. +4 −13 lib/tpl/defaults
  6. +7 −3 src/index.html
  7. +4 −1 src/misc/cpan-faq.html
  8. +2 −1 tt.rc
View
1 Makefile
@@ -18,6 +18,7 @@ build:
update-data:
@./bin/cpanorg_rss_fetch
+ @./bin/update_data
install:
cpanm Template JSON Template::Plugin::Comma Template::Plugin::JSON \
View
10 bin/update_data
@@ -0,0 +1,10 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use LWP::Simple qw(mirror);
+
+mirror("http://www.cpan.org/indices/cpan-stats.json", "data/cpan-stats.json");
+
+
+
+
View
2 data/cpan_stats.json
@@ -1,2 +0,0 @@
-{ "authors": 8813, "modules": 90994,"mirrors": 200 }
-
View
9 lib/tpl/data/cpan-stats
@@ -0,0 +1,9 @@
+[%- json_data = INSERT "cpan-stats.json" %]
+[%
+ data = JSON.json_decode(json_data);
+ cpan_stats.import(data);
+%]
+CPAN STAST!
+[% USE Dumper %]
+
+[% Dumper.dump_html(cpan_stats, data) %]
View
17 lib/tpl/defaults
@@ -1,4 +1,6 @@
[%-
+ USE JSON;
+
page = {
title = template.title,
style = template.style or 'cpan.html'
@@ -10,8 +12,8 @@
name => 'www.cpan.org',
crum => '<a href="/">Home</a>',
};
-
- # Defaults ( should be overwritten through tpl/cpan_stats.html )
+
+ # Defaults ( should be overwritten through tpl/data/cpan-stats )
SET cpan_stats = {
modules => 90000,
authors => 8000,
@@ -22,7 +24,6 @@
[%- BLOCK rss_feed %]
[% TRY %]
[% json_data = INSERT $conf.json_file %]
- [% USE JSON %]
[% items = JSON.json_decode(json_data) %]
<ul>
[% FOREACH item = items %]
@@ -33,13 +34,3 @@
[% CATCH %]
[% END %]
[% END -%]
-
-[%- TRY -%]
-[%- USE JSON %]
-[%- json_data = INSERT "cpan_stats.json" %]
-[%
- data = JSON.json_decode(json_data);
- cpan_stats.import(data);
-%]
-[%- CATCH -%]
-[%- END -%]
View
10 src/index.html
@@ -7,6 +7,8 @@
USE Comma;
+ PROCESS "tpl/data/cpan-stats";
+
%][% page.head = BLOCK %]
<!-- Copyright Jarkko Hietaniemi <jhi@iki.fi>
1998,1999,2000,2001,2003,2003,2004,2005,2008
@@ -63,7 +65,7 @@
<tr>
<td id="strapline" colspan="3">
<p>
- CPAN holds [% cpan_stats.modules | comma %] open source Perl modules ready for you to download and use.<br />
+ CPAN holds [% cpan_stats.modules.count | comma %] open source Perl modules ready for you to download and use.<br />
Stop reinventing wheels, start building space rockets.
</p>
</td>
@@ -108,8 +110,10 @@ <h1 id="searchtitle">
<td class="third">
<h2>Welcome to CPAN</h2>
<p>
- CPAN currently has <a href="http://cpan.perl.org/modules/">[% cpan_stats.modules | comma %] Perl modules</a>, written by [% cpan_stats.authors | comma %] authors,
- <a href="SITES.html">mirrored</a> on [% cpan_stats.mirrors | comma %] servers.
+
+ CPAN currently has <a href="http://cpan.perl.org/modules/">[% cpan_stats.modules.count | comma %] Perl modules</a>, written by [% cpan_stats.authors.count | comma %] authors,
+ <a href="SITES.html">mirrored</a> on [% cpan_stats.mirrors.count | comma %] servers.
+
</p>
<p>The archive has been online since October 1995 and is constantly growing.</p>
<ul>
View
5 src/misc/cpan-faq.html
@@ -4,6 +4,9 @@
section => 'home',
stub => '../',
});
+
+ PROCESS "tpl/data/cpan-stats";
+
%]
[% page.head = BLOCK %]
@@ -335,7 +338,7 @@
</h3>
<p>
CPAN works with the generosity and cooperation of thousands of developers,
- over [% cpan_stats.mirrors %] participating mirrors, many companies,
+ over [% cpan_stats.mirrors.count %] participating mirrors, many companies,
institutions and individuals donating the network bandwidth, storage space
and computing power, volunteers who help keep everything together and users
whose interest in Perl keep the archive alive and growing.
View
3 tt.rc
@@ -6,7 +6,8 @@ ignore = \.tt$
depend *=tpl/wrapper,tpl/defaults,style/cpan.html
depend SITES.html=SITES-list.html
-depend index.html=recent.json
+depend index.html=recent.json,cpan-stats.json
+depend misc/cpan-faq.html=cpan-stats.json
copy = \.(gif|png|pdf|jpg)$

0 comments on commit 97f7eab

Please sign in to comment.