1/*
2 *	aegis - project change supervisor
3 *	Copyright (C) 1997, 1998, 2000-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 */
19auto href;
20
21auto script_name;
22script_name = getenv("SCRIPT_NAME");
23if (script_name == "")
24    script_name = "http://localhost/cgi-bin/aegis.cgi";
25
26columns({width = 1000; });
27print("Content-Type: text/html");
28print("");
29print("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\""
30        ## "\"http://www.w3.org/TR/REC-html40/loose.dtd\">");
31print("<html><head>");
32print("<meta name=\"ROBOTS\" content=\"NOINDEX, NOFOLLOW\">");
33print("<meta name=\"GENERATOR\" content=\"" ## script_name ## "\">");
34print("<meta http-equiv=\"Content-Type\" "
35        ## "content=\"text/html; charset=ISO-8859-1\">");
36print("<style type=\"text/css\"> "
37        ## "tr.even-group { background-color: #CCCCCC; }"
38        ## "body { background-color: white; }"
39        ## "</style>");
40/*
41 * Netscape 4.x has numerous CSS bugs, two of which need mentioning.
42 * 1. If a style sheet is not present Netscape says 404 Not found, when
43 * it should silently ignore it.  2. Style sheets who's media is not
44 * "screen" will be ignored.  Fortunately we can use (2) to get around (1).
45 */
46print("<link rel=\"stylesheet\" type=\"text/css\" href=\"/aedefault.css\" "
47    ## "media=\"all\">");
48auto pn;
49pn = project_name();
50auto stack, depth, n;
51depth=0;
52stack[depth] = project[pn].state.name;
53while ("" != ( n = project[stack[depth]].state.parent_name )) {
54  stack[++depth] = n;
55}
56while ( depth >= 0) {
57    print("<link rel=\"stylesheet\" type=\"text/css\" href=\"/" ##
58      stack[depth--] ## ".css\" " ## "media=\"all\">");
59}
60/* get change type filter */
61auto c_type, c_not, a;
62c_type = "undefined";
63c_not = false;
64for (a in arg)
65{
66    if (a ~~ "state:")
67        c_type = substr(a, 6, 9999);
68}
69if (substr(c_type, 0, 1) == "-")
70{
71    c_not = true;
72    c_type = substr(c_type, 1, 9999);
73}
74auto c_desc,  sample_cmdln;
75c_desc = capitalize(subst("_", " ", c_type));
76sample_cmdln = "aegis -l chan_" ## c_type;
77if (c_type == "undefined")
78{
79    c_not = true;
80    c_desc = "";
81    sample_cmdln = "ael c -p " ## quote_html(pn);
82}
83if (c_type == "being_developed")
84{
85    sample_cmdln = "aede -l -p " ## quote_html(pn);
86}
87else if (c_type == "awaiting_review")
88{
89    sample_cmdln = "aerb -l -p " ## quote_html(pn);
90}
91else if (c_type == "being_reviewed")
92{
93    sample_cmdln = "aerfail -l -p " ## quote_html(pn);
94}
95else if (c_type == "awaiting_integration")
96{
97    sample_cmdln = "aeib -l -p " ## quote_html(pn);
98}
99else if (c_type == "being_integrated")
100{
101    sample_cmdln = "aeifail -l -p " ## quote_html(pn);
102}
103else if (c_type == "completed")
104{
105    if (c_not)
106	sample_cmdln = "ael oc " ## quote_html(pn);
107    else
108	sample_cmdln = "ael phi " ## quote_html(pn);
109}
110
111print("<title>");
112print("Project " ## quote_html(pn) ## " Changes");
113if (c_desc != "")
114	print((c_not ? "not " : "") ## c_desc);
115print("</title></head><body><h1 align=center>");
116
117print("<a href=\"" ## script_name ## "\">Project</a>");
118auto long_project_name;
119auto prj_name_parts;
120prj_name_parts = split(pn, '.');
121href = script_name ## "?file@proj_menu+project@"
122	## quote_url(prj_name_parts[0]);
123long_project_name = "<a href=\"" ## href ## "\" >"
124	## quote_html(prj_name_parts[0]) ## "</a>";
125auto j;
126for (j = 1; j < count(prj_name_parts); j++)
127{
128    href ##= '.' ## prj_name_parts[j];
129    long_project_name ##= ".<a href=\"" ## href ## "\" >"
130    	## quote_html(prj_name_parts[j]) ## "</a>";
131};
132long_project_name = "&ldquo;" ## long_project_name ## "&rdquo;,<br>";
133/* HTTP limits lines to 510 characters */
134for (j in wrap(long_project_name, 510))
135    print(j);
136
137print("List of Changes");
138if (c_desc != "")
139{
140    print("<br>");
141    print((c_not ? "not " : "") ## c_desc);
142}
143print("</h1>");
144print("<div class=\"information\">");
145print("<table align=\"center\">");
146print("<tr class=\"even-group\">");
147print("<th>Change</th><th>State</th><th>Description</th><th>Download</th>");
148print("</tr>");
149
150auto ps;
151ps = project[pn].state.branch;
152auto cn, rownum; rownum = 0;
153for (cn in sort(keys(ps.change)))
154{
155    auto cs;
156    cs = ps.change[cn];
157    if (c_not)
158    {
159	if (cs.state == c_type)
160	    continue;
161    }
162    else
163    {
164	if (cs.state != c_type)
165	    continue;
166    }
167    if (rownum % 6 < 3)
168        print("<tr class=\"odd-group\">");
169    else
170        print("<tr class=\"even-group\">");
171    rownum++;
172    print("<td valign=\"top\" align=\"right\">");
173    auto junk;
174    href = "file@chan_menu+project@" ## quote_url(pn) ## "+change@" ## cn;
175    try
176    {
177       	if (count(keys(cs.branch)))
178	    href = "file@proj_menu+project@" ## quote_url(pn) ## "." ## cn;
179    }
180    catch (junk)
181       	;
182    href = script_name ## "?" ## href;
183    print("<a href=\"" ## href ## "\">" ## cn ## "</a>");
184    print("</td><td valign=\"top\">");
185    print(cs.state);
186    if
187    (
188	(cs.state == being_developed || cs.state == being_integrated)
189    &&
190	!count(keys(cs.branch))
191    )
192    {
193	auto who, hi, h, email, long_name;
194	for (hi = count(cs.history) - 1; hi >= 0; --hi)
195	{
196	    h = cs.history[hi];
197	    if
198	    (
199		h.what == develop_begin
200	    ||
201		h.what == develop_end
202	    ||
203		h.what == integrate_begin
204	    ||
205		h.what == integrate_pass
206	    )
207	    {
208		who = h.who;
209		email = h.who;
210		try { email = user[h.who].email_address; }
211		catch (email) { email = ""; }
212		if (email == "")
213		    email = h.who;
214		href = "mailto:" ## email;
215		long_name = h.who;
216		try { long_name = passwd[who].pw_comment; }
217		catch (long_name) { long_name = h.who; }
218		print("<br><a href=\"" ## href ## "\"><i>" ##
219		    quote_html(long_name) ## "</i></a>");
220		break;
221	    }
222	}
223    }
224    print("</td><td valign=\"top\">");
225    auto part;
226    for (part in wrap_html(quote_html(cs.brief_description), 80))
227       	print(part);
228    print("</td>");
229    print("<td valign=top>");
230    if (cs.state != awaiting_development)
231    {
232	href = script_name ## "/" ## quote_url(pn) ## ".C" ## cn
233	    ## ".patch?file@aepatch+project@" ## quote_url(pn)
234	    ## "+change@" ## cn;
235	print("<a href=\"" ## href ## "\"><code>patch</code></a>,");
236
237	href = script_name ## "/" ## quote_url(pn) ## ".C" ## cn
238	    ## ".tar.gz?file@aetar+project@" ## quote_url(pn)
239	    ## "+change@" ## cn;
240	print("<a href=\"" ## href ## "\"><code>tar.gz</code></a>,");
241
242	href = script_name ## "/" ## quote_url(pn) ## ".C" ## cn
243	    ## ".ae?file@aedist+project@" ## quote_url(pn)
244	    ## "+change@" ## cn;
245	print("<a href=\"" ## href ## "\"><code>aedist</code></a>");
246    }
247    print("</td>");
248    print("</tr>");
249}
250print("<tr><td colspan=\"2\">");
251print("Listed " ## rownum ## " changes.");
252print("</td></tr></table>");
253print("</div>");
254print("<hr>");
255print("<div class=\"report-cmd\">");
256print("A similar report may be obtained from the command line, with");
257print("<blockquote><samp>");
258print(sample_cmdln);
259print("</samp></blockquote>");
260print("</div>");
261
262print("<hr>");
263print("<p align=\"center\" class=\"navbar\">[");
264print("<a href=\"" ## script_name ## "\">Project List</a>");
265print("|");
266href = script_name ## "?file@proj_menu+project@" ## quote_url(pn);
267print("<a href=\"" ## href ## "\">Project Menu</a>");
268print("]</p>");
269print("<hr>");
270print("This page was generated " ## now() ## ".");
271print("</body></html>");
272