Show
Ignore:
Timestamp:
12/11/07 03:34:35 (13 months ago)
Author:
coji
Message:

lang/ruby/coderepos_stat: added size CGI parameter

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/coderepos_stat/data/index.rb

    r3014 r3030  
    66# $Id$ 
    77# 
     8require 'cgi' 
     9 
    810stat = {} 
    911Dir.glob("*/*.yaml").sort.each do |f| 
    1012  date = File.dirname(f) 
    1113  stat[date] ||= 0 
    12   stat[date]+= 1 
     14  stat[date] += 1 
     15end 
     16 
     17cgi = CGI.new 
     18size = '200x150' 
     19if cgi.has_key? 'size' 
     20  m = /(\d+)x(\d+)/.match(cgi['size']) 
     21  size = '%sx%s' % [m[1], m[2]] if m and m.size == 3 
    1322end 
    1423 
    1524sorted_keys = stat.keys.sort 
    16 sorted_label = sorted_keys.map{|k| "#{k[5..6]}-#{k[8..9]}"} 
     25sorted_label = sorted_keys.map{|k| "#{k[4..5]}-#{k[6..7]}"} 
    1726sorted_data = sorted_keys.map{|k| stat[k]} 
    18 max = stat.values.max 
    1927 
    2028params = Array.new 
    21 params << "chs=200x150" 
     29params << "chs=#{CGI.escape(size)}" 
    2230params << "cht=lc" 
    2331params << "chxt=x,y" 
    24 params << "chxl=0:|#{sorted_label.join('|')}|1:||#{max}" 
     32params << "chxl=0:|#{sorted_label.join('|')}|1:||100" 
    2533params << "chd=t:#{sorted_data.join(',')}" 
     34params << "chtt=CodeRepos%20commits/day" 
    2635 
    2736puts "Location: http://chart.apis.google.com/chart?#{params.join('&')}" 
    2837puts 
    29  
    30