4 # Purpose: to create rotating html web pages based on summary.html
5 # Author: pc2@ecs.csus.edu
6 # Revised: Sun May 1 13:09:03 PDT 2005
8 # $Id: rotate_summary,v 1.2 2006/04/12 15:35:59 boudreat Exp $
14 # summary.html in current directory.
18 # Creates a number of new summary html files in current directory
19 # named in the form of summary#.html where summary1.html is the first
25 $perpage=14; # number of teams per page
27 # set this to 1, run script once at cutoff time
34 # the number of attempts we try to read the html file
37 # set to "" not print a banner
38 $banner="../banner.png";
45 for($retry=0;(($retry < $maxretry ) && $done == 0); $retry++) {
46 open(IN
,"$f") || die("Unable to read $f: $!\n");
50 if ($firstrow eq "") {
51 s/tr/tr BGCOLOR="#EEEEFF"/ if $rowcount % 2 == 0;
53 } elsif (/\<td\>\<\/td\
>/i
) { # color line
54 s/tr/tr BGCOLOR="#EEEEFF"/ if $rowcount % 2 == 0;
56 } elsif (/\<td\>Submitted/i) {
58 $summary =~ s
@tr@tr><td
> 
;</td></tr
><tr BGCOLOR
="#EEEEFF"@
;
59 $summary =~ s
#<td>(\d+/(--|\d+)(/\d+)?)</td>#<td align=center>$1</td>#g;
60 } elsif (/\<td cellwid?th/i) { # v8.7-1115 has this misspelled
61 next; # blank line before summary
64 s/tr/tr BGCOLOR="#EEEEFF"/ if $rowcount % 2 == 0;
65 s
#<td>(\d+/(--|\d+))</td>#<td align=center>$1</td>#g;
66 s
#<td>(\d+)</td><td>(\d+)</td>#<td align="center">$1</td><td align="right">$2</td>#g;
67 s
#<td>(\c+)</td>#<td align=right>$1 </td>#g;
70 } elsif (/^Created by/i) {
71 $created="Created by California State University, Sacramento PC<sup>2</sup><br>\nhttp://www.ecs.csus.edu/pc2/<br>\n";
73 $created.= <IN
>; # Last Updated
74 $created.= <IN
>; # Date
76 $done=1 if (/\<\/html\
>/);
79 sleep 1 if ($done == 0);
82 die("Unable to read a complete $f\n");
85 @nextpage=&gen_page_seq
($#rows, $perpage);
86 # page sequence already contains padding 1st value
89 foreach($page=1;$page <= $maxpage; $page++) {
90 &print_page
($page,$nextpage[$page],($page-1)*$perpage+1,$page*$perpage);
94 my($rowcount, $rows_per_page)=@_;
95 my(@result)=(-1); # 1st value is ignored
96 my($pages)=int($rowcount/$rows_per_page);
97 if ($pages * $rows_per_page != $rowcount) {
98 # we have a non-full page
101 # push a dummy value, so we can do $page[thispage] to get the next page
103 foreach($p=2; $p <= $pages ; $p++) {
106 push(@pages,1); # and back to the 1st page
111 my($thispage,$nextpage,$start,$end)=@_;
112 # warn("print_page($thispage,$nextpage,$start,$end)\n");
114 open(OUT
,">summary$thispage.html")
115 || warn("Unable to write summary$thispage.html");
116 $nextfile="summary$nextpage.html";
119 <!-- next page is summary$nextpage.html -->
120 <META HTTP-EQUIV="REFRESH" CONTENT="$refresh; URL=$nextfile">
121 <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="no-cache">
122 <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
131 if ($banner ne "" && -f
$banner) {
133 <IMG SRC="$banner" align="center">
137 <table border=0 cellpadding=2>
140 $end=$#rows+1 if $end > ($#rows+1);
141 foreach($i=$start ; $i <= $end; $i++) {
142 print OUT
$rows[$i-1]."\n";
148 <font size=-1 face="verdana, arial, helvetica">
149 <p align=right>Page $page of $maxpage</p>
151 if ($nomoreupdates==1) {
152 # print OUT "<p align=center><font size=+2><b>No More Updates</b></font></p>";
153 print OUT
"<p align=center><font size=+1><b>Standings with $cutofftime left. There will be no more scoreboard updates.</b></font></p>";
155 print OUT
"<br><br>";