Browse files

emit JSONp

  • Loading branch information...
1 parent bfc6fb0 commit 2dbfa0fc6c69f4f9b16e729d3686f0bb0d5f3c8f @miyagawa committed Mar 18, 2013
Showing with 5 additions and 32 deletions.
  1. +3 −2 script/daily.sh
  2. +2 −30 script/drawchart.pl
View
5 script/daily.sh
@@ -2,5 +2,6 @@
cd `dirname $0`
DATE=`date +%Y%m%d`
mkdir ../static/versions 2>/dev/null
-tail -100000 ../access_log | perl drawchart.pl > ../static/versions/index.html
-cp ../static/versions/index.html ../static/versions/$DATE.html
+tail -100000 ../access_log | perl drawchart.pl > ../static/versions/current.js
+cp ../static/versions/current.js ../static/versions/$DATE.js
+
View
32 script/drawchart.pl
@@ -21,34 +21,6 @@ sub versionify {
my $js_data = join ",\n", map { "[ '@{[versionify($_)]}', $versions{$_} ]" } sort keys %versions;
my $time = Time::Piece->new;
-my $date = $time->ymd;
+my $date = join ",", $time->year, $time->mon, $time->mday;
-print <<HTML;
-<html>
- <head>
- <title>Perl versions used with cpanm: $date</title>
- <script type="text/javascript" src="https://www.google.com/jsapi"></script>
- <script type="text/javascript">
- google.load("visualization", "1", {packages:["corechart"]});
- google.setOnLoadCallback(drawChart);
- function drawChart() {
- var data = google.visualization.arrayToDataTable([
- ['Version', 'Requests'],
- $js_data
- ]);
-
- var options = {
- title: 'Perl versions used with cpanm'
- };
-
- var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
- chart.draw(data, options);
- }
- </script>
- </head>
- <body>
- <div id="chart_div" style="width: 900px; height: 500px;"></div>
- <p class="note">Updated on <span class="date">$date</span>. This graph is based on the sample requests sent to the <a href="http://cpanmetadb.plackperl.org/">CPAN Meta DB</a> from cpanm (version 1.6004 or later).</p>
- </body>
-</html>
-HTML
+print qq/callback({"date": [$date], "data": [ ['Version', 'Requests'], $js_data ]});/;

0 comments on commit 2dbfa0f

Please sign in to comment.