1 //
2 // aegis - project change supervisor
3 // Copyright (C) 2003-2008, 2011, 2012 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 (at
8 // 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 GNU
13 // 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 <http://www.gnu.org/licenses/>.
17 //
18
19 #include <common/ac/assert.h>
20 #include <common/ac/stdio.h>
21
22 #include <common/debug.h>
23 #include <common/nstring.h>
24 #include <common/str_list.h>
25 #include <libaegis/change/file.h>
26 #include <libaegis/change.h>
27 #include <libaegis/fstate.fmtgen.h>
28 #include <libaegis/http.h>
29 #include <libaegis/project/file.h>
30 #include <libaegis/project.h>
31
32 #include <aeget/get/file/menu.h>
33
34
35 void
get_file_menu(change::pointer cp,string_ty * filename,string_list_ty *)36 get_file_menu(change::pointer cp, string_ty *filename, string_list_ty *)
37 {
38 //
39 // Emit the page title.
40 //
41 html_header(0, cp);
42 printf("<title>Project\n");
43 html_encode_string(project_name_get(cp->pp));
44 if (!cp->bogus)
45 printf(", Change %ld\n", magic_zero_decode(cp->number));
46 printf(", File ");
47 html_encode_string(filename);
48 printf("</title></head><body>\n");
49
50 //
51 // Emit the page heading.
52 //
53 html_header_ps(0, cp);
54 printf("<h1 align=center>\n");
55 emit_change(cp);
56 printf(",<br>File “");
57 html_encode_string(filename);
58 printf("”</h1>\n");
59
60 //
61 // Make sure the file exists.
62 //
63 fstate_src_ty *src = 0;
64 if (!cp->bogus)
65 {
66 src = cp->file_find(nstring(filename), view_path_first);
67 if (!src)
68 {
69 printf("This file is not part of this change.\n");
70 if (cp->pp->file_find(filename, view_path_simple))
71 {
72 printf("You may like to see the ");
73 cp->bogus = 1;
74 emit_file_href(cp, filename, "menu");
75 cp->bogus = 0;
76 printf("project file menu</a> instead.\n");
77 }
78 else
79 {
80 printf("It may be created by the build; ");
81 emit_file_href(cp, filename, 0);
82 printf("if it exists</a> it is unmanaged.");
83 }
84
85 //
86 // Emit the page footer.
87 //
88 html_footer(0, cp);
89 return;
90 }
91 }
92 else
93 {
94 src = cp->pp->file_find(filename, view_path_simple);
95 if (!src)
96 {
97 printf("This file is not controlled by Aegis.\n");
98 printf("It may have been created by the build;\n");
99 emit_file_href(cp, filename, 0);
100 printf("if it exists</a> it is unmanaged.");
101
102 //
103 // Emit the page footer.
104 //
105 html_footer(0, cp);
106 return;
107 }
108 }
109 assert(src);
110
111 printf("<div class=\"information\">\n");
112 printf("<dl>\n");
113 if (src->uuid)
114 {
115 printf("<td>UUID<dd><tt>");
116 html_escape_string(src->uuid);
117 printf("</tt><p>\n");
118 }
119
120 if (!cp->bogus)
121 {
122 printf("<dt>");
123 cp->bogus = 1;
124 emit_file_href(cp, filename, "menu");
125 cp->bogus = 0;
126 printf("Project File</a><dd>\n");
127 printf("This item directs you to the corresponding file menu\n");
128 printf("for the project.\n");
129 printf("<p>\n");
130 }
131 if (src->attribute && src->attribute->length)
132 {
133 printf("<dt>Attributes<dd>\n");
134 printf("<table>\n");
135 printf("<tr><th>Name</th><th>Value</th></tr>\n");
136 attributes_list_ty *alp = src->attribute;
137 for (size_t j = 0; j < alp->length; ++j)
138 {
139 attributes_ty *ap = alp->list[j];
140 printf("<tr><td>\n");
141 if (ap->name)
142 printf("%s\n", nstring(ap->name).html_quote().c_str());
143 printf("</td><td>\n");
144 if (ap->value)
145 printf("%s\n", nstring(ap->value).html_quote().c_str());
146 printf("</td></tr>\n");
147 }
148 printf("</table>\n");
149 printf("<p>\n");
150 }
151
152 printf("<dt>");
153 emit_file_href(cp, filename, "activity");
154 printf("File Activity</a><dd>\n");
155 printf("This item will provide you with a listing of changes which\n");
156 printf("are actively modifying this file. The list includes who\n");
157 printf("is working on the changes, and a brief description of each\n");
158 printf("change. Where a file is common to more than one change,\n");
159 printf("all changes are listed against the file.\n");
160
161 printf("<p><dt>");
162 emit_file_href(cp, filename, "conflict");
163 printf("File Conflict</a><dd>\n");
164 printf("This item will provide you with a listing of changes which are\n");
165 printf("actively modifying this file <strong>if</strong> more than\n");
166 printf("<em>one</em> change is modifying the file.\n");
167
168 printf("<p><dt>");
169 int hold_bogus = cp->bogus;
170 cp->bogus = 1;
171 emit_file_href(cp, filename, "file+history");
172 cp->bogus = hold_bogus;
173 printf("File History</a><dd>\n");
174 printf("This item will provide you with a listing of all completed\n");
175 printf("changes which affected this file in the past. The\n");
176 emit_file_href(cp, filename, "file+history+detailed");
177 printf("detailed version</a> will take longer to generate.\n");
178 printf("<p>\n");
179 printf("For historical versions of this file, click on the\n");
180 printf("links in the <strong>Edit</strong> column. Each links\n");
181 printf("you to contents of the version of the file integrated\n");
182 printf("for that change.\n");
183
184 if (cp->bogus)
185 {
186 if (src->deleted_by)
187 {
188 printf("<p><dt>Baseline<dd>\n");
189 printf("The file no longer exists in the baseline.\n");
190 // FIXME: add link.
191 printf("It was deleted by change %ld.\n", src->deleted_by);
192 }
193 else
194 {
195 printf("<p><dt>");
196 emit_file_href(cp, filename, 0);
197 printf("Baseline</a><dd>\n");
198 printf("This item gives access to the file contents as it\n");
199 printf("exists in the curremt project baseline.\n");
200 }
201 }
202 else
203 {
204 switch (src->action)
205 {
206 case file_action_create:
207 if (!cp->is_completed())
208 {
209 printf("<p><dt>Baseline<dd>\n");
210 printf("The file does not yet exist in the baseline.\n");
211 printf("It is being created by this change, which is not\n");
212 printf("yet integrated\n");
213 break;
214 }
215 // fall through...
216
217 case file_action_modify:
218 case file_action_remove:
219 case file_action_insulate:
220 case file_action_transparent:
221 #ifndef DEBUG
222 default:
223 #endif
224 printf("<p><dt>");
225 cp->bogus = 1;
226 emit_file_href(cp, filename, 0);
227 cp->bogus = 0;
228 printf("Baseline</a><dd>\n");
229 printf("This item will show you the contents of the file in\n");
230 printf("the project baseline, the <strong>current</strong>\n");
231 printf("master version.\n");
232 break;
233 }
234 }
235
236 if (cp->bogus || cp->is_completed())
237 {
238 printf("<p><dt>");
239 emit_file_href(cp, filename, "diff+detailed");
240 printf("Differences</a><dd>\n");
241 printf("This item will show you a grid of historical\n");
242 printf("file versions, allowing you to obtain diff(1)\n");
243 printf("patches between all of the versions shown.\n");
244 }
245
246 printf("</dl>\n");
247 printf("</div>\n");
248
249 //
250 // Emit the navigation bar.
251 //
252 printf("<hr>\n");
253 printf("<p align=center class=\"navbar\">[\n");
254 printf("<a href=\"%s/\">Project List</a> |\n", http_script_name());
255 emit_project_href(cp->pp, "menu");
256 printf("Project Menu</a> |\n");
257 if (!cp->bogus)
258 {
259 emit_change_href(cp, "menu");
260 printf("Change Menu</a> |\n");
261 }
262 emit_change_href(cp, "files");
263 printf("File List</a>\n");
264 printf("]</p>\n");
265
266 //
267 // Emit page footer.
268 //
269 html_footer(0, cp);
270 }
271
272
273 // vim: set ts=8 sw=4 et :
274