OSDN Git Service

Comments are converted to EUC-JP and then written in a log.
[shogi-server/shogi-server.git] / mk_html
diff --git a/mk_html b/mk_html
index d8c6c53..cf29e4e 100755 (executable)
--- a/mk_html
+++ b/mk_html
@@ -40,6 +40,14 @@ USAGE: #{$0}
   exit 1
 end
 
+def remove_long_to_see_players(file)
+  return unless file["players"][999] # only for Not-Yet-Rated players
+
+  file["players"][999].delete_if do |key, value|
+    value['last_modified'] < Time.now - 24*3600*30 # 30 days
+  end
+end
+
 def main
   lines = ""
   while l = gets do
@@ -56,11 +64,20 @@ def main
       group_names << "Not-Yet-Rated Players"
     end
   end
+  remove_long_to_see_players(file)
 
   popup_id = 0
-
+        
   file["players"].sort.each do |key, yaml| # sort groups in the order written in players.yaml
-  sorted_keys = yaml.keys.sort {|a,b| yaml[b]['rate'] <=> yaml[a]['rate']} # sort players in a group by one's rate
+  sorted_keys = yaml.keys.sort do |a,b| 
+    # sort players in a group by one's rate
+    if yaml[b]['rate'] == 0 && yaml[a]['rate'] == 0
+      # mainly for not-rated-yet players
+      yaml[b]['last_modified'] <=> yaml[a]['last_modified']
+    else
+      yaml[b]['rate'] <=> yaml[a]['rate']
+    end
+  end 
   top_rate = nil  
   table = ERB.new(<<ENDTABLE, nil, "%>")
 % sorted_keys.each do |key|
@@ -89,7 +106,7 @@ def main
   %>
   <tr class="<%=player_decoration%>">
     <td class="name">
-        <span id="popup<%=popup_id+=1%>"><%= h yaml[key]['name'] %></span>
+        <a id="popup<%=popup_id+=1%>" href="http://wdoor.c.u-tokyo.ac.jp/shogi/tools/view/show-player.cgi?event=LATEST&amp;filter=floodgate&amp;show_self_play=1&amp;user=<%= h yaml[key]['name'] %>"><%= h yaml[key]['name'] %></a>
         <script type="text/javascript">
           var tooltip<%=popup_id%> = new YAHOO.widget.Tooltip("myTooltip", {
             context:"popup<%=popup_id%>",