4 ## Copyright (C) 2006 Daigo Moriwaki <daigo at debian dot org>
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 2 of the License, or
9 ## (at your option) any later version.
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ## GNU General Public License for more details.
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program; if not, write to the Free Software
18 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # This generates html pages from players.yaml.
24 # $ ./mk_html < players.yaml > rating.html
33 time.strftime("%Y-%m-%d")
48 file = YAML::load(lines)
49 erb = ERB.new( DATA.read, nil, "%>" )
52 file["players"].each do |key, yaml|
53 sorted_keys = yaml.keys.sort {|a,b| yaml[b]['rate'] <=> yaml[a]['rate']}
55 table = ERB.new(<<ENDTABLE, nil, "%>")
56 % sorted_keys.each do |key|
58 win = yaml[key]['win']
59 loss = yaml[key]['loss']
60 win_rate = win.to_f / (win + loss)
61 last_modified = yaml[key]['last_modified']
64 <td class="name"> <%= h yaml[key]['name'] %> </td>
65 <td class="rate"> <%= "%5d" % [ yaml[key]['rate'] ] %> </td>
66 <td class="ngames"> <%= "%5d" % [ win ] %> </td>
67 <td class="ngames"> <%= "%5d" % [ loss ] %> </td>
68 <td class="win_rate"> <%= "%.3f" % [win_rate] %> </td>
69 <td class="last_modified"><%= show_date(last_modified) %> </td>
74 tables << table.result(binding)
77 body = erb.result(binding)
85 # vim: ts=2 sw=2 sts=0
90 <title>Shogi Server Rating</title>
91 <link rel="StyleSheet" type="text/css" href="http://wdoor.c.u-tokyo.ac.jp/shogi/shogi.css">
92 <style type="text/css"><!--
93 BODY {margin: 10px 60px;
95 TABLE {margin-left: auto;
97 border-collapse: collapse;
99 CAPTION { caption-side: left;}
100 TH {border: solid 1px;}
101 TD {padding-left: 10px;
104 .name {text-align: center;}
105 .rate, .ngames, .win_rate {text-align: right;}
106 .last_modified {text-align: left;}
108 DIV.footer {text-align: right;
114 <h1>Shogi Server Rating</h1>
116 % tables.each_with_index do |t, index|
118 <caption>Group: <%=index%></caption>
124 <col class="win_rate">
125 <col class="last_modified">
134 <th>last_modified</th>
142 <hr style="width:50%; margin:1em auto;">
146 <p>Groups are independently rated. You can not compare rates across them.
147 <p>The average of the rates in a group is always 1000.
148 <p><a href="http://wdoor.c.u-tokyo.ac.jp/shogi/">BACK</a>
153 <p>Last modified at <%=Time.now%>