1/* 2 * aegis - project change supervisor 3 * Copyright (C) 1997, 1998, 2002, 2003, 2005-2008 Peter Miller 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see 17 * <http://www.gnu.org/licenses/>. 18 */ 19 20auto pn, p; 21pn = project_name(); 22p = project[pn]; 23auto ps, cs; 24ps = p.state; 25auto ph, when, n, max, href; 26 27auto script_name; 28script_name = getenv("SCRIPT_NAME"); 29if (script_name == "") 30 script_name = "http://localhost/cgi-bin/aegis.cgi"; 31 32columns({width = 1000; }); 33print("Content-Type: text/html"); 34print(""); 35print("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\""); 36print(" \"http://www.w3.org/TR/REC-html40/loose.dtd\">"); 37print("<html><head>"); 38print("<meta name=\"ROBOTS\" content=\"NOINDEX, NOFOLLOW\">"); 39print("<meta name=\"GENERATOR\" content=\"" ## script_name ## "\">"); 40print("<meta http-equiv=\"Content-Type\" " 41 ## "content=\"text/html; charset=ISO-8859-1\">"); 42print("<style type=\"text/css\"> " 43 ## "tr.even-group { background-color: #CCCCCC; }" 44 ## "body { background-color: white; }" 45 ## "</style>"); 46/* 47 * Netscape 4.x has numerous CSS bugs, two of which need mentioning. 48 * 1. If a style sheet is not present Netscape says 404 Not found, when 49 * it should silently ignore it. 2. Style sheets who's media is not 50 * "screen" will be ignored. Fortunately we can use (2) to get around (1). 51 */ 52print("<link rel=\"stylesheet\" type=\"text/css\" href=\"/aedefault.css\" " 53 ## "media=\"all\">"); 54auto stack, depth, bn; 55depth=0; 56stack[depth] = project[pn].state.name; 57while ("" != ( bn = project[stack[depth]].state.parent_name )) { 58 stack[++depth] = bn; 59} 60while ( depth >= 0) { 61 print("<link rel=\"stylesheet\" type=\"text/css\" href=\"/" ## 62 stack[depth--] ## ".css\" " ## "media=\"all\">"); 63} 64print("<title>"); 65print("Project " ## quote_html(pn) ## ", Change Histogram"); 66print("</title><head><body><h1 align=center>"); 67 68print("<a href=\"" ## script_name ## "\">Project</a>"); 69auto long_project_name; 70auto prj_name_parts; 71prj_name_parts = split(pn, '.'); 72href = script_name ## "?file@proj_menu+project@" 73 ## quote_url(prj_name_parts[0]); 74long_project_name = "<a href=\"" ## href ## "\" >" 75 ## quote_html(prj_name_parts[0]) ## "</a>"; 76auto j; 77for (j = 1; j < count(prj_name_parts); j++) 78{ 79 href ##= '.' ## prj_name_parts[j]; 80 long_project_name ##= ".<a href=\"" ## href ## "\" >" 81 ## quote_html(prj_name_parts[j]) ## "</a>"; 82}; 83long_project_name = "“" ## long_project_name ## "”,<br>"; 84/* HTTP limits lines to 510 characters */ 85for (j in wrap(long_project_name, 510)) 86 print(j); 87 88print("Change Histogram"); 89print("</h1>"); 90 91print("<div class=\"information\">"); 92auto earliest_year, latest_year; 93earliest_year = 0; 94latest_year = 0; 95auto bucket, year; 96bucket = {}; 97for (ph in ps.branch.history) 98{ 99 cs = ps.branch.change[ph.change_number]; 100 when = cs.history[count(cs.history) - 1].when; 101 year = 0 + strftime("%Y", when); 102 bucket[year]++; 103 if (earliest_year == 0 || earliest_year > year) 104 earliest_year = year; 105 if (latest_year < year) 106 latest_year = year; 107} 108 109max = 1; 110for (year in keys(bucket)) 111{ 112 n = 0 + bucket[year]; 113 if (n > max) 114 max = n; 115} 116max = 400. / max; 117 118print("<table align=center>"); 119print("<tr><th>Year</th><th>Count</th></tr>"); 120for (year = earliest_year; year <= latest_year; ++year) 121{ 122 n = 0 + bucket[year]; 123 print("<tr><td align=right>"); 124 if (n > 0) 125 { 126 href = script_name ## "?file@proj_hstg2"; 127 href ##= "+project@" ## quote_url(project_name()); 128 href ##= "+" ## year; 129 print("<a href=\"" ## href ## "\">"); 130 } 131 print(year); 132 if (n > 0) 133 print("</a>"); 134 print("</td><td align=right>"); 135 print(n); 136 print("</td><td>"); 137 if (n > 0) 138 { 139 n = round(n * max); 140 if (n < 3) 141 n = 3; 142 href = script_name ## "?file@rect+" ## n ## "+12"; 143 print("<img src=\"" ## href ## "\" width="##n##" height=12>"); 144 } 145 print("</td></tr>"); 146} 147print("</table>"); 148print("</div>"); 149 150print("<hr>"); 151print("<p align=center class=\"navbar\">["); 152print("<a href=\"" ## script_name ## "\">Project List</a> |"); 153href = script_name ## "?file@proj_menu+project@" ## quote_url(pn); 154print("<a href=\"" ## href ## "\">Project Menu</a> |"); 155href = script_name ## "?file@changes+project@" ## quote_url(pn); 156print("<a href=\"" ## href ## "\">Change List</a>"); 157print("]</p>"); 158 159print("<hr>"); 160print("This page was generated " ## now() ## "."); 161print("</body></html>"); 162