summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.css49
-rw-r--r--ui-shared.c22
2 files changed, 41 insertions, 30 deletions
diff --git a/cgit.css b/cgit.css
index 565427f..17c2712 100644
--- a/cgit.css
+++ b/cgit.css
@@ -1,438 +1,447 @@
1body, table { 1body, table {
2 padding: 0em; 2 padding: 0em;
3 margin: 0em; 3 margin: 0em;
4} 4}
5 5
6body { 6body {
7 font-family: sans; 7 font-family: sans;
8 font-size: 10pt; 8 font-size: 10pt;
9 color: #333; 9 color: #333;
10 background: white; 10 background: white;
11 padding-left: 4px; 11 padding: 4px;
12} 12}
13 13
14table { 14table {
15 border-collapse: collapse; 15 border-collapse: collapse;
16} 16}
17 17
18h2 { 18h2 {
19 font-size: 120%; 19 font-size: 120%;
20 font-weight: bold; 20 font-weight: bold;
21 margin-top: 0em; 21 margin-top: 0em;
22 margin-bottom: 0.25em; 22 margin-bottom: 0.25em;
23} 23}
24 24
25h3 { 25h3 {
26 margin-top: 0em; 26 margin-top: 0em;
27 font-size: 100%; 27 font-size: 100%;
28 font-weight: normal; 28 font-weight: normal;
29} 29}
30 30
31h4 { 31h4 {
32 margin-top: 1.5em; 32 margin-top: 1.5em;
33 margin-bottom: 0.1em; 33 margin-bottom: 0.1em;
34 font-size: 100%; 34 font-size: 100%;
35 font-weight: bold; 35 font-weight: bold;
36} 36}
37 37
38a { 38a {
39 color: #600; 39 color: #600;
40 text-decoration: none; 40 text-decoration: none;
41} 41}
42 42
43a:hover { 43a:hover {
44 background-color: #ddd; 44 background-color: #ddd;
45 text-decoration: none; 45 text-decoration: none;
46} 46}
47 47
48table.list { 48table.list {
49 border: none; 49 border: none;
50 border-collapse: collapse; 50 border-collapse: collapse;
51} 51}
52 52
53table.list tr { 53table.list tr {
54 background: white; 54 background: white;
55} 55}
56 56
57table.list tr:hover { 57table.list tr:hover {
58 background: #f8f8f8; 58 background: #f8f8f8;
59} 59}
60 60
61table.list tr.nohover:hover { 61table.list tr.nohover:hover {
62 background: white; 62 background: white;
63} 63}
64 64
65table.list th { 65table.list th {
66 font-weight: bold; 66 font-weight: bold;
67 border-bottom: solid 1px #777; 67 border-bottom: solid 1px #777;
68 padding: 0.1em 0.5em 0.1em 0.5em; 68 padding: 0.1em 0.5em 0.1em 0.5em;
69 vertical-align: baseline; 69 vertical-align: baseline;
70} 70}
71 71
72table.list td { 72table.list td {
73 border: none; 73 border: none;
74 padding: 0.1em 0.5em 0.1em 0.5em; 74 padding: 0.1em 0.5em 0.1em 0.5em;
75} 75}
76 76
77img { 77img {
78 border: none; 78 border: none;
79} 79}
80 80
81div#sidebar { 81table#layout {
82 border-collapse: collapse;
83 border: none;
84 margin: 0px;
85}
86
87td#sidebar {
82 vertical-align: top; 88 vertical-align: top;
83 width: 162px; 89 width: 162px;
84 padding: 0px 0px 0px 0px; 90 padding: 0px 0px 0px 0px;
85 margin: 4px; 91 margin: 0px;
86 float: left;
87} 92}
88 93
89div#logo { 94td#sidebar table {
95 border-collapse: separate;
96 border-spacing: 0px;
90 margin: 0px; 97 margin: 0px;
91 padding: 4px 0px 4px 0px; 98 padding: 0px;
92 text-align: center;
93 background-color: #ccc; 99 background-color: #ccc;
100}
101
102td#sidebar table.sidebar td.sidebar {
103 padding: 4px;
94 border-top: solid 1px #eee; 104 border-top: solid 1px #eee;
95 border-left: solid 1px #eee; 105 border-left: solid 1px #eee;
96 border-right: solid 1px #aaa; 106 border-right: solid 1px #aaa;
97 border-bottom: solid 1px #aaa; 107 border-bottom: solid 1px #aaa;
98} 108}
99 109
100div#sidebar div.infobox { 110div#logo {
101 margin: 0px 0px 0px 0px; 111 margin: 0px;
102 padding: 0.5em; 112 padding: 4px 0px 4px 0px;
103 text-align: left; 113 text-align: center;
104 background-color: #ccc; 114 background-color: #ccc;
105 border-top: solid 1px #eee; 115 border-top: solid 1px #eee;
106 border-left: solid 1px #eee; 116 border-left: solid 1px #eee;
107 border-right: solid 1px #aaa; 117 border-right: solid 1px #aaa;
108 border-bottom: solid 1px #aaa; 118 border-bottom: solid 1px #aaa;
109} 119}
110 120
111div#sidebar div.infobox h1 { 121td#sidebar h1 {
112 font-size: 10pt; 122 font-size: 10pt;
113 font-weight: bold; 123 font-weight: bold;
114 margin: 8px 0px 0px 0px; 124 margin: 8px 0px 0px 0px;
115} 125}
116 126
117div#sidebar div.infobox h1.first { 127td#sidebar h1.first {
118 margin-top: 0px; 128 margin-top: 0px;
119} 129}
120 130
121div#sidebar div.infobox a.menu { 131td#sidebar a.menu {
122 display: block; 132 display: block;
123 background-color: #ccc; 133 background-color: #ccc;
124 padding: 0.1em 0.5em; 134 padding: 0.1em 0.5em;
125 text-decoration: none; 135 text-decoration: none;
126} 136}
127 137
128div#sidebar div.infobox a.menu:hover { 138td#sidebar a.menu:hover {
129 background-color: #bbb; 139 background-color: #bbb;
130 text-decoration: none; 140 text-decoration: none;
131} 141}
132 142
133div#sidebar div.infobox select { 143td#sidebar select {
134 width: 100%; 144 width: 100%;
135 margin: 2px 0px 0px 0px; 145 margin: 2px 0px 0px 0px;
136} 146}
137 147
138td#branch-dropdown-cell { 148td#sidebar form {
139 width: 99%; 149 text-align: right;
140} 150}
141 151
142input#switch-btn { 152input#switch-btn {
143 width: 20px;
144 margin: 2px 0px 0px 0px; 153 margin: 2px 0px 0px 0px;
145} 154}
146 155
147div#sidebar div.infobox input.txt { 156td#sidebar input.txt {
148 width: 100%; 157 width: 100%;
149 margin: 2px 0px 0px 0px; 158 margin: 2px 0px 0px 0px;
150} 159}
151 160
152table#grid { 161table#grid {
153 margin: 0px; 162 margin: 0px;
154} 163}
155 164
156td#content { 165td#content {
157 vertical-align: top; 166 vertical-align: top;
158 padding: 1em 2em 1em 1em; 167 padding: 1em 2em 1em 1em;
159 border: none; 168 border: none;
160} 169}
161 170
162div#summary { 171div#summary {
163 vertical-align: top; 172 vertical-align: top;
164 margin-bottom: 1em; 173 margin-bottom: 1em;
165} 174}
166 175
167table#downloads { 176table#downloads {
168 float: right; 177 float: right;
169 border-collapse: collapse; 178 border-collapse: collapse;
170 border: solid 1px #777; 179 border: solid 1px #777;
171 margin-left: 0.5em; 180 margin-left: 0.5em;
172 margin-bottom: 0.5em; 181 margin-bottom: 0.5em;
173} 182}
174 183
175table#downloads th { 184table#downloads th {
176 background-color: #ccc; 185 background-color: #ccc;
177} 186}
178 187
179div#blob { 188div#blob {
180 border: solid 1px black; 189 border: solid 1px black;
181} 190}
182 191
183div.error { 192div.error {
184 color: red; 193 color: red;
185 font-weight: bold; 194 font-weight: bold;
186 margin: 1em 2em; 195 margin: 1em 2em;
187} 196}
188 197
189a.ls-blob, a.ls-dir, a.ls-mod { 198a.ls-blob, a.ls-dir, a.ls-mod {
190 font-family: monospace; 199 font-family: monospace;
191} 200}
192 201
193td.ls-size { 202td.ls-size {
194 text-align: right; 203 text-align: right;
195} 204}
196 205
197td.ls-size { 206td.ls-size {
198 font-family: monospace; 207 font-family: monospace;
199} 208}
200 209
201td.ls-mode { 210td.ls-mode {
202 font-family: monospace; 211 font-family: monospace;
203} 212}
204 213
205table.blob { 214table.blob {
206 margin-top: 0.5em; 215 margin-top: 0.5em;
207 border-top: solid 1px black; 216 border-top: solid 1px black;
208} 217}
209 218
210table.blob td.no { 219table.blob td.no {
211 border-right: solid 1px black; 220 border-right: solid 1px black;
212 color: black; 221 color: black;
213 background-color: #eee; 222 background-color: #eee;
214 text-align: right; 223 text-align: right;
215} 224}
216 225
217table.blob td.no a { 226table.blob td.no a {
218 color: black; 227 color: black;
219} 228}
220 229
221table.blob td.no a:hover { 230table.blob td.no a:hover {
222 color: black; 231 color: black;
223 text-decoration: none; 232 text-decoration: none;
224} 233}
225 234
226table.blob td.txt { 235table.blob td.txt {
227 white-space: pre; 236 white-space: pre;
228 font-family: monospace; 237 font-family: monospace;
229 padding-left: 0.5em; 238 padding-left: 0.5em;
230} 239}
231 240
232table.nowrap td { 241table.nowrap td {
233 white-space: nowrap; 242 white-space: nowrap;
234} 243}
235 244
236table.commit-info { 245table.commit-info {
237 border-collapse: collapse; 246 border-collapse: collapse;
238 margin-top: 1.5em; 247 margin-top: 1.5em;
239} 248}
240 249
241table.commit-info th { 250table.commit-info th {
242 text-align: left; 251 text-align: left;
243 font-weight: normal; 252 font-weight: normal;
244 padding: 0.1em 1em 0.1em 0.1em; 253 padding: 0.1em 1em 0.1em 0.1em;
245 vertical-align: top; 254 vertical-align: top;
246} 255}
247 256
248table.commit-info td { 257table.commit-info td {
249 font-weight: normal; 258 font-weight: normal;
250 padding: 0.1em 1em 0.1em 0.1em; 259 padding: 0.1em 1em 0.1em 0.1em;
251} 260}
252 261
253div.commit-subject { 262div.commit-subject {
254 font-weight: bold; 263 font-weight: bold;
255 font-size: 125%; 264 font-size: 125%;
256 margin: 1.5em 0em 0.5em 0em; 265 margin: 1.5em 0em 0.5em 0em;
257 padding: 0em; 266 padding: 0em;
258} 267}
259 268
260div.commit-msg { 269div.commit-msg {
261 white-space: pre; 270 white-space: pre;
262 font-family: monospace; 271 font-family: monospace;
263} 272}
264 273
265div.diffstat-header { 274div.diffstat-header {
266 font-weight: bold; 275 font-weight: bold;
267 padding-top: 1.5em; 276 padding-top: 1.5em;
268} 277}
269 278
270table.diffstat { 279table.diffstat {
271 border-collapse: collapse; 280 border-collapse: collapse;
272 border: solid 1px #aaa; 281 border: solid 1px #aaa;
273 background-color: #eee; 282 background-color: #eee;
274} 283}
275 284
276table.diffstat th { 285table.diffstat th {
277 font-weight: normal; 286 font-weight: normal;
278 text-align: left; 287 text-align: left;
279 text-decoration: underline; 288 text-decoration: underline;
280 padding: 0.1em 1em 0.1em 0.1em; 289 padding: 0.1em 1em 0.1em 0.1em;
281 font-size: 100%; 290 font-size: 100%;
282} 291}
283 292
284table.diffstat td { 293table.diffstat td {
285 padding: 0.2em 0.2em 0.1em 0.1em; 294 padding: 0.2em 0.2em 0.1em 0.1em;
286 font-size: 100%; 295 font-size: 100%;
287 border: none; 296 border: none;
288} 297}
289 298
290table.diffstat td.mode { 299table.diffstat td.mode {
291 white-space: nowrap; 300 white-space: nowrap;
292} 301}
293 302
294table.diffstat td span.modechange { 303table.diffstat td span.modechange {
295 padding-left: 1em; 304 padding-left: 1em;
296 color: red; 305 color: red;
297} 306}
298 307
299table.diffstat td.add a { 308table.diffstat td.add a {
300 color: green; 309 color: green;
301} 310}
302 311
303table.diffstat td.del a { 312table.diffstat td.del a {
304 color: red; 313 color: red;
305} 314}
306 315
307table.diffstat td.upd a { 316table.diffstat td.upd a {
308 color: blue; 317 color: blue;
309} 318}
310 319
311table.diffstat td.graph { 320table.diffstat td.graph {
312 width: 500px; 321 width: 500px;
313 vertical-align: middle; 322 vertical-align: middle;
314} 323}
315 324
316table.diffstat td.graph table { 325table.diffstat td.graph table {
317 border: none; 326 border: none;
318} 327}
319 328
320table.diffstat td.graph td { 329table.diffstat td.graph td {
321 padding: 0px; 330 padding: 0px;
322 border: 0px; 331 border: 0px;
323 height: 7pt; 332 height: 7pt;
324} 333}
325 334
326table.diffstat td.graph td.add { 335table.diffstat td.graph td.add {
327 background-color: #5c5; 336 background-color: #5c5;
328} 337}
329 338
330table.diffstat td.graph td.rem { 339table.diffstat td.graph td.rem {
331 background-color: #c55; 340 background-color: #c55;
332} 341}
333 342
334div.diffstat-summary { 343div.diffstat-summary {
335 color: #888; 344 color: #888;
336 padding-top: 0.5em; 345 padding-top: 0.5em;
337} 346}
338 347
339table.diff { 348table.diff {
340 width: 100%; 349 width: 100%;
341} 350}
342 351
343table.diff td { 352table.diff td {
344 font-family: monospace; 353 font-family: monospace;
345 white-space: pre; 354 white-space: pre;
346} 355}
347 356
348table.diff td div.head { 357table.diff td div.head {
349 font-weight: bold; 358 font-weight: bold;
350 margin-top: 1em; 359 margin-top: 1em;
351 background-color: #eee; 360 background-color: #eee;
352} 361}
353 362
354table.diff td div.hunk { 363table.diff td div.hunk {
355 color: #009; 364 color: #009;
356} 365}
357 366
358table.diff td div.add { 367table.diff td div.add {
359 color: green; 368 color: green;
360} 369}
361 370
362table.diff td div.del { 371table.diff td div.del {
363 color: red; 372 color: red;
364} 373}
365 374
366.sha1 { 375.sha1 {
367 font-family: monospace; 376 font-family: monospace;
368 font-size: 90%; 377 font-size: 90%;
369} 378}
370 379
371.left { 380.left {
372 text-align: left; 381 text-align: left;
373} 382}
374 383
375.right { 384.right {
376 text-align: right; 385 text-align: right;
377} 386}
378 387
379table.list td.repogroup { 388table.list td.repogroup {
380 font-style: italic; 389 font-style: italic;
381 color: #888; 390 color: #888;
382} 391}
383 392
384a.button { 393a.button {
385 font-size: 80%; 394 font-size: 80%;
386 color: #aaa; 395 color: #aaa;
387 background-color: #eee; 396 background-color: #eee;
388 border: solid 1px #aaa; 397 border: solid 1px #aaa;
389 padding: 0em 0.5em; 398 padding: 0em 0.5em;
390 margin: 0.1em 0.25em; 399 margin: 0.1em 0.25em;
391} 400}
392 401
393a.button:hover { 402a.button:hover {
394 text-decoration: none; 403 text-decoration: none;
395 color: #333; 404 color: #333;
396 background-color: #ccc; 405 background-color: #ccc;
397} 406}
398 407
399a.primary { 408a.primary {
400 font-size: 100%; 409 font-size: 100%;
401} 410}
402 411
403a.secondary { 412a.secondary {
404 font-size: 90%; 413 font-size: 90%;
405} 414}
406 415
407td.toplevel-repo { 416td.toplevel-repo {
408 417
409} 418}
410 419
411table.list td.sublevel-repo { 420table.list td.sublevel-repo {
412 padding-left: 1.5em; 421 padding-left: 1.5em;
413} 422}
414 423
415span.age-mins { 424span.age-mins {
416 font-weight: bold; 425 font-weight: bold;
417 color: #080; 426 color: #080;
418} 427}
419 428
420span.age-hours { 429span.age-hours {
421 color: #080; 430 color: #080;
422} 431}
423 432
424span.age-days { 433span.age-days {
425 color: #040; 434 color: #040;
426} 435}
427 436
428span.age-weeks { 437span.age-weeks {
429 color: #444; 438 color: #444;
430} 439}
431 440
432span.age-months { 441span.age-months {
433 color: #888; 442 color: #888;
434} 443}
435 444
436span.age-years { 445span.age-years {
437 color: #bbb; 446 color: #bbb;
438} 447}
diff --git a/ui-shared.c b/ui-shared.c
index 2f771da..4c0613a 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -76,464 +76,466 @@ char *cgit_fileurl(const char *reponame, const char *pagename,
76 tmp = fmt("%s%s%s", tmp, delim, query); 76 tmp = fmt("%s%s%s", tmp, delim, query);
77 return tmp; 77 return tmp;
78} 78}
79 79
80char *cgit_pageurl(const char *reponame, const char *pagename, 80char *cgit_pageurl(const char *reponame, const char *pagename,
81 const char *query) 81 const char *query)
82{ 82{
83 return cgit_fileurl(reponame,pagename,0,query); 83 return cgit_fileurl(reponame,pagename,0,query);
84} 84}
85 85
86const char *cgit_repobasename(const char *reponame) 86const char *cgit_repobasename(const char *reponame)
87{ 87{
88 /* I assume we don't need to store more than one repo basename */ 88 /* I assume we don't need to store more than one repo basename */
89 static char rvbuf[1024]; 89 static char rvbuf[1024];
90 int p; 90 int p;
91 const char *rv; 91 const char *rv;
92 strncpy(rvbuf,reponame,sizeof(rvbuf)); 92 strncpy(rvbuf,reponame,sizeof(rvbuf));
93 if(rvbuf[sizeof(rvbuf)-1]) 93 if(rvbuf[sizeof(rvbuf)-1])
94 die("cgit_repobasename: truncated repository name '%s'", reponame); 94 die("cgit_repobasename: truncated repository name '%s'", reponame);
95 p = strlen(rvbuf)-1; 95 p = strlen(rvbuf)-1;
96 /* strip trailing slashes */ 96 /* strip trailing slashes */
97 while(p && rvbuf[p]=='/') rvbuf[p--]=0; 97 while(p && rvbuf[p]=='/') rvbuf[p--]=0;
98 /* strip trailing .git */ 98 /* strip trailing .git */
99 if(p>=3 && !strncmp(&rvbuf[p-3],".git",4)) { 99 if(p>=3 && !strncmp(&rvbuf[p-3],".git",4)) {
100 p -= 3; rvbuf[p--] = 0; 100 p -= 3; rvbuf[p--] = 0;
101 } 101 }
102 /* strip more trailing slashes if any */ 102 /* strip more trailing slashes if any */
103 while( p && rvbuf[p]=='/') rvbuf[p--]=0; 103 while( p && rvbuf[p]=='/') rvbuf[p--]=0;
104 /* find last slash in the remaining string */ 104 /* find last slash in the remaining string */
105 rv = strrchr(rvbuf,'/'); 105 rv = strrchr(rvbuf,'/');
106 if(rv) 106 if(rv)
107 return ++rv; 107 return ++rv;
108 return rvbuf; 108 return rvbuf;
109} 109}
110 110
111char *cgit_currurl() 111char *cgit_currurl()
112{ 112{
113 if (!cgit_virtual_root) 113 if (!cgit_virtual_root)
114 return cgit_script_name; 114 return cgit_script_name;
115 else if (cgit_query_page) 115 else if (cgit_query_page)
116 return fmt("%s/%s/%s/", cgit_virtual_root, cgit_query_repo, cgit_query_page); 116 return fmt("%s/%s/%s/", cgit_virtual_root, cgit_query_repo, cgit_query_page);
117 else if (cgit_query_repo) 117 else if (cgit_query_repo)
118 return fmt("%s/%s/", cgit_virtual_root, cgit_query_repo); 118 return fmt("%s/%s/", cgit_virtual_root, cgit_query_repo);
119 else 119 else
120 return fmt("%s/", cgit_virtual_root); 120 return fmt("%s/", cgit_virtual_root);
121} 121}
122 122
123static char *repolink(char *title, char *class, char *page, char *head, 123static char *repolink(char *title, char *class, char *page, char *head,
124 char *path) 124 char *path)
125{ 125{
126 char *delim = "?"; 126 char *delim = "?";
127 127
128 html("<a"); 128 html("<a");
129 if (title) { 129 if (title) {
130 html(" title='"); 130 html(" title='");
131 html_attr(title); 131 html_attr(title);
132 html("'"); 132 html("'");
133 } 133 }
134 if (class) { 134 if (class) {
135 html(" class='"); 135 html(" class='");
136 html_attr(class); 136 html_attr(class);
137 html("'"); 137 html("'");
138 } 138 }
139 html(" href='"); 139 html(" href='");
140 if (cgit_virtual_root) { 140 if (cgit_virtual_root) {
141 html_attr(cgit_virtual_root); 141 html_attr(cgit_virtual_root);
142 if (cgit_virtual_root[strlen(cgit_virtual_root) - 1] != '/') 142 if (cgit_virtual_root[strlen(cgit_virtual_root) - 1] != '/')
143 html("/"); 143 html("/");
144 html_attr(cgit_repo->url); 144 html_attr(cgit_repo->url);
145 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') 145 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/')
146 html("/"); 146 html("/");
147 if (page) { 147 if (page) {
148 html(page); 148 html(page);
149 html("/"); 149 html("/");
150 if (path) 150 if (path)
151 html_attr(path); 151 html_attr(path);
152 } 152 }
153 } else { 153 } else {
154 html(cgit_script_name); 154 html(cgit_script_name);
155 html("?url="); 155 html("?url=");
156 html_attr(cgit_repo->url); 156 html_attr(cgit_repo->url);
157 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') 157 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/')
158 html("/"); 158 html("/");
159 if (page) { 159 if (page) {
160 html(page); 160 html(page);
161 html("/"); 161 html("/");
162 if (path) 162 if (path)
163 html_attr(path); 163 html_attr(path);
164 } 164 }
165 delim = "&amp;"; 165 delim = "&amp;";
166 } 166 }
167 if (head && strcmp(head, cgit_repo->defbranch)) { 167 if (head && strcmp(head, cgit_repo->defbranch)) {
168 html(delim); 168 html(delim);
169 html("h="); 169 html("h=");
170 html_attr(head); 170 html_attr(head);
171 delim = "&amp;"; 171 delim = "&amp;";
172 } 172 }
173 return fmt("%s", delim); 173 return fmt("%s", delim);
174} 174}
175 175
176static void reporevlink(char *page, char *name, char *title, char *class, 176static void reporevlink(char *page, char *name, char *title, char *class,
177 char *head, char *rev, char *path) 177 char *head, char *rev, char *path)
178{ 178{
179 char *delim; 179 char *delim;
180 180
181 delim = repolink(title, class, page, head, path); 181 delim = repolink(title, class, page, head, path);
182 if (rev && strcmp(rev, cgit_query_head)) { 182 if (rev && strcmp(rev, cgit_query_head)) {
183 html(delim); 183 html(delim);
184 html("id="); 184 html("id=");
185 html_attr(rev); 185 html_attr(rev);
186 } 186 }
187 html("'>"); 187 html("'>");
188 html_txt(name); 188 html_txt(name);
189 html("</a>"); 189 html("</a>");
190} 190}
191 191
192void cgit_tree_link(char *name, char *title, char *class, char *head, 192void cgit_tree_link(char *name, char *title, char *class, char *head,
193 char *rev, char *path) 193 char *rev, char *path)
194{ 194{
195 reporevlink("tree", name, title, class, head, rev, path); 195 reporevlink("tree", name, title, class, head, rev, path);
196} 196}
197 197
198void cgit_log_link(char *name, char *title, char *class, char *head, 198void cgit_log_link(char *name, char *title, char *class, char *head,
199 char *rev, char *path, int ofs, char *grep, char *pattern) 199 char *rev, char *path, int ofs, char *grep, char *pattern)
200{ 200{
201 char *delim; 201 char *delim;
202 202
203 delim = repolink(title, class, "log", head, path); 203 delim = repolink(title, class, "log", head, path);
204 if (rev && strcmp(rev, cgit_query_head)) { 204 if (rev && strcmp(rev, cgit_query_head)) {
205 html(delim); 205 html(delim);
206 html("id="); 206 html("id=");
207 html_attr(rev); 207 html_attr(rev);
208 delim = "&"; 208 delim = "&";
209 } 209 }
210 if (grep && pattern) { 210 if (grep && pattern) {
211 html(delim); 211 html(delim);
212 html("qt="); 212 html("qt=");
213 html_attr(grep); 213 html_attr(grep);
214 delim = "&"; 214 delim = "&";
215 html(delim); 215 html(delim);
216 html("q="); 216 html("q=");
217 html_attr(pattern); 217 html_attr(pattern);
218 } 218 }
219 if (ofs > 0) { 219 if (ofs > 0) {
220 html(delim); 220 html(delim);
221 html("ofs="); 221 html("ofs=");
222 htmlf("%d", ofs); 222 htmlf("%d", ofs);
223 } 223 }
224 html("'>"); 224 html("'>");
225 html_txt(name); 225 html_txt(name);
226 html("</a>"); 226 html("</a>");
227} 227}
228 228
229void cgit_commit_link(char *name, char *title, char *class, char *head, 229void cgit_commit_link(char *name, char *title, char *class, char *head,
230 char *rev) 230 char *rev)
231{ 231{
232 if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { 232 if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) {
233 name[cgit_max_msg_len] = '\0'; 233 name[cgit_max_msg_len] = '\0';
234 name[cgit_max_msg_len - 1] = '.'; 234 name[cgit_max_msg_len - 1] = '.';
235 name[cgit_max_msg_len - 2] = '.'; 235 name[cgit_max_msg_len - 2] = '.';
236 name[cgit_max_msg_len - 3] = '.'; 236 name[cgit_max_msg_len - 3] = '.';
237 } 237 }
238 reporevlink("commit", name, title, class, head, rev, NULL); 238 reporevlink("commit", name, title, class, head, rev, NULL);
239} 239}
240 240
241void cgit_refs_link(char *name, char *title, char *class, char *head, 241void cgit_refs_link(char *name, char *title, char *class, char *head,
242 char *rev, char *path) 242 char *rev, char *path)
243{ 243{
244 reporevlink("refs", name, title, class, head, rev, path); 244 reporevlink("refs", name, title, class, head, rev, path);
245} 245}
246 246
247void cgit_snapshot_link(char *name, char *title, char *class, char *head, 247void cgit_snapshot_link(char *name, char *title, char *class, char *head,
248 char *rev, char *archivename) 248 char *rev, char *archivename)
249{ 249{
250 reporevlink("snapshot", name, title, class, head, rev, archivename); 250 reporevlink("snapshot", name, title, class, head, rev, archivename);
251} 251}
252 252
253void cgit_diff_link(char *name, char *title, char *class, char *head, 253void cgit_diff_link(char *name, char *title, char *class, char *head,
254 char *new_rev, char *old_rev, char *path) 254 char *new_rev, char *old_rev, char *path)
255{ 255{
256 char *delim; 256 char *delim;
257 257
258 delim = repolink(title, class, "diff", head, path); 258 delim = repolink(title, class, "diff", head, path);
259 if (new_rev && strcmp(new_rev, cgit_query_head)) { 259 if (new_rev && strcmp(new_rev, cgit_query_head)) {
260 html(delim); 260 html(delim);
261 html("id="); 261 html("id=");
262 html_attr(new_rev); 262 html_attr(new_rev);
263 delim = "&amp;"; 263 delim = "&amp;";
264 } 264 }
265 if (old_rev) { 265 if (old_rev) {
266 html(delim); 266 html(delim);
267 html("id2="); 267 html("id2=");
268 html_attr(old_rev); 268 html_attr(old_rev);
269 } 269 }
270 html("'>"); 270 html("'>");
271 html_txt(name); 271 html_txt(name);
272 html("</a>"); 272 html("</a>");
273} 273}
274 274
275void cgit_object_link(struct object *obj) 275void cgit_object_link(struct object *obj)
276{ 276{
277 char *page, *arg, *url; 277 char *page, *arg, *url;
278 278
279 if (obj->type == OBJ_COMMIT) { 279 if (obj->type == OBJ_COMMIT) {
280 cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, 280 cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL,
281 cgit_query_head, sha1_to_hex(obj->sha1)); 281 cgit_query_head, sha1_to_hex(obj->sha1));
282 return; 282 return;
283 } else if (obj->type == OBJ_TREE) { 283 } else if (obj->type == OBJ_TREE) {
284 page = "tree"; 284 page = "tree";
285 arg = "id"; 285 arg = "id";
286 } else if (obj->type == OBJ_TAG) { 286 } else if (obj->type == OBJ_TAG) {
287 page = "tag"; 287 page = "tag";
288 arg = "id"; 288 arg = "id";
289 } else { 289 } else {
290 page = "blob"; 290 page = "blob";
291 arg = "id"; 291 arg = "id";
292 } 292 }
293 293
294 url = cgit_pageurl(cgit_query_repo, page, 294 url = cgit_pageurl(cgit_query_repo, page,
295 fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); 295 fmt("%s=%s", arg, sha1_to_hex(obj->sha1)));
296 html_link_open(url, NULL, NULL); 296 html_link_open(url, NULL, NULL);
297 htmlf("%s %s", typename(obj->type), 297 htmlf("%s %s", typename(obj->type),
298 sha1_to_hex(obj->sha1)); 298 sha1_to_hex(obj->sha1));
299 html_link_close(); 299 html_link_close();
300} 300}
301 301
302void cgit_print_date(time_t secs, char *format) 302void cgit_print_date(time_t secs, char *format)
303{ 303{
304 char buf[64]; 304 char buf[64];
305 struct tm *time; 305 struct tm *time;
306 306
307 time = gmtime(&secs); 307 time = gmtime(&secs);
308 strftime(buf, sizeof(buf)-1, format, time); 308 strftime(buf, sizeof(buf)-1, format, time);
309 html_txt(buf); 309 html_txt(buf);
310} 310}
311 311
312void cgit_print_age(time_t t, time_t max_relative, char *format) 312void cgit_print_age(time_t t, time_t max_relative, char *format)
313{ 313{
314 time_t now, secs; 314 time_t now, secs;
315 315
316 time(&now); 316 time(&now);
317 secs = now - t; 317 secs = now - t;
318 318
319 if (secs > max_relative && max_relative >= 0) { 319 if (secs > max_relative && max_relative >= 0) {
320 cgit_print_date(t, format); 320 cgit_print_date(t, format);
321 return; 321 return;
322 } 322 }
323 323
324 if (secs < TM_HOUR * 2) { 324 if (secs < TM_HOUR * 2) {
325 htmlf("<span class='age-mins'>%.0f min.</span>", 325 htmlf("<span class='age-mins'>%.0f min.</span>",
326 secs * 1.0 / TM_MIN); 326 secs * 1.0 / TM_MIN);
327 return; 327 return;
328 } 328 }
329 if (secs < TM_DAY * 2) { 329 if (secs < TM_DAY * 2) {
330 htmlf("<span class='age-hours'>%.0f hours</span>", 330 htmlf("<span class='age-hours'>%.0f hours</span>",
331 secs * 1.0 / TM_HOUR); 331 secs * 1.0 / TM_HOUR);
332 return; 332 return;
333 } 333 }
334 if (secs < TM_WEEK * 2) { 334 if (secs < TM_WEEK * 2) {
335 htmlf("<span class='age-days'>%.0f days</span>", 335 htmlf("<span class='age-days'>%.0f days</span>",
336 secs * 1.0 / TM_DAY); 336 secs * 1.0 / TM_DAY);
337 return; 337 return;
338 } 338 }
339 if (secs < TM_MONTH * 2) { 339 if (secs < TM_MONTH * 2) {
340 htmlf("<span class='age-weeks'>%.0f weeks</span>", 340 htmlf("<span class='age-weeks'>%.0f weeks</span>",
341 secs * 1.0 / TM_WEEK); 341 secs * 1.0 / TM_WEEK);
342 return; 342 return;
343 } 343 }
344 if (secs < TM_YEAR * 2) { 344 if (secs < TM_YEAR * 2) {
345 htmlf("<span class='age-months'>%.0f months</span>", 345 htmlf("<span class='age-months'>%.0f months</span>",
346 secs * 1.0 / TM_MONTH); 346 secs * 1.0 / TM_MONTH);
347 return; 347 return;
348 } 348 }
349 htmlf("<span class='age-years'>%.0f years</span>", 349 htmlf("<span class='age-years'>%.0f years</span>",
350 secs * 1.0 / TM_YEAR); 350 secs * 1.0 / TM_YEAR);
351} 351}
352 352
353void cgit_print_docstart(char *title, struct cacheitem *item) 353void cgit_print_docstart(char *title, struct cacheitem *item)
354{ 354{
355 html("Content-Type: text/html; charset=" PAGE_ENCODING "\n"); 355 html("Content-Type: text/html; charset=" PAGE_ENCODING "\n");
356 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); 356 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime));
357 htmlf("Expires: %s\n", http_date(item->st.st_mtime + 357 htmlf("Expires: %s\n", http_date(item->st.st_mtime +
358 ttl_seconds(item->ttl))); 358 ttl_seconds(item->ttl)));
359 html("\n"); 359 html("\n");
360 html(cgit_doctype); 360 html(cgit_doctype);
361 html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); 361 html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n");
362 html("<head>\n"); 362 html("<head>\n");
363 html("<title>"); 363 html("<title>");
364 html_txt(title); 364 html_txt(title);
365 html("</title>\n"); 365 html("</title>\n");
366 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); 366 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
367 if (cgit_robots && *cgit_robots) 367 if (cgit_robots && *cgit_robots)
368 htmlf("<meta name='robots' content='%s'/>\n", cgit_robots); 368 htmlf("<meta name='robots' content='%s'/>\n", cgit_robots);
369 html("<link rel='stylesheet' type='text/css' href='"); 369 html("<link rel='stylesheet' type='text/css' href='");
370 html_attr(cgit_css); 370 html_attr(cgit_css);
371 html("'/>\n"); 371 html("'/>\n");
372 html("</head>\n"); 372 html("</head>\n");
373 html("<body>\n"); 373 html("<body>\n");
374} 374}
375 375
376void cgit_print_docend() 376void cgit_print_docend()
377{ 377{
378 html("</td>\n</tr>\n</table>\n</body>\n</html>\n"); 378 html("</td>\n</tr>\n</table>\n</body>\n</html>\n");
379} 379}
380 380
381int print_branch_option(const char *refname, const unsigned char *sha1, 381int print_branch_option(const char *refname, const unsigned char *sha1,
382 int flags, void *cb_data) 382 int flags, void *cb_data)
383{ 383{
384 char *name = (char *)refname; 384 char *name = (char *)refname;
385 html_option(name, name, cgit_query_head); 385 html_option(name, name, cgit_query_head);
386 return 0; 386 return 0;
387} 387}
388 388
389int print_archive_ref(const char *refname, const unsigned char *sha1, 389int print_archive_ref(const char *refname, const unsigned char *sha1,
390 int flags, void *cb_data) 390 int flags, void *cb_data)
391{ 391{
392 struct tag *tag; 392 struct tag *tag;
393 struct taginfo *info; 393 struct taginfo *info;
394 struct object *obj; 394 struct object *obj;
395 char buf[256], *url; 395 char buf[256], *url;
396 unsigned char fileid[20]; 396 unsigned char fileid[20];
397 int *header = (int *)cb_data; 397 int *header = (int *)cb_data;
398 398
399 if (prefixcmp(refname, "refs/archives")) 399 if (prefixcmp(refname, "refs/archives"))
400 return 0; 400 return 0;
401 strncpy(buf, refname+14, sizeof(buf)); 401 strncpy(buf, refname+14, sizeof(buf));
402 obj = parse_object(sha1); 402 obj = parse_object(sha1);
403 if (!obj) 403 if (!obj)
404 return 1; 404 return 1;
405 if (obj->type == OBJ_TAG) { 405 if (obj->type == OBJ_TAG) {
406 tag = lookup_tag(sha1); 406 tag = lookup_tag(sha1);
407 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) 407 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag)))
408 return 0; 408 return 0;
409 hashcpy(fileid, tag->tagged->sha1); 409 hashcpy(fileid, tag->tagged->sha1);
410 } else if (obj->type != OBJ_BLOB) { 410 } else if (obj->type != OBJ_BLOB) {
411 return 0; 411 return 0;
412 } else { 412 } else {
413 hashcpy(fileid, sha1); 413 hashcpy(fileid, sha1);
414 } 414 }
415 if (!*header) { 415 if (!*header) {
416 html("<h1>download</h1>\n"); 416 html("<h1>download</h1>\n");
417 *header = 1; 417 *header = 1;
418 } 418 }
419 url = cgit_pageurl(cgit_query_repo, "blob", 419 url = cgit_pageurl(cgit_query_repo, "blob",
420 fmt("id=%s&amp;path=%s", sha1_to_hex(fileid), 420 fmt("id=%s&amp;path=%s", sha1_to_hex(fileid),
421 buf)); 421 buf));
422 html_link_open(url, NULL, "menu"); 422 html_link_open(url, NULL, "menu");
423 html_txt(strlpart(buf, 20)); 423 html_txt(strlpart(buf, 20));
424 html_link_close(); 424 html_link_close();
425 return 0; 425 return 0;
426} 426}
427 427
428void add_hidden_formfields(int incl_head, int incl_search, char *page) 428void add_hidden_formfields(int incl_head, int incl_search, char *page)
429{ 429{
430 char *url; 430 char *url;
431 431
432 if (!cgit_virtual_root) { 432 if (!cgit_virtual_root) {
433 url = fmt("%s/%s", cgit_query_repo, page); 433 url = fmt("%s/%s", cgit_query_repo, page);
434 if (cgit_query_path) 434 if (cgit_query_path)
435 url = fmt("%s/%s", url, cgit_query_path); 435 url = fmt("%s/%s", url, cgit_query_path);
436 html_hidden("url", url); 436 html_hidden("url", url);
437 } 437 }
438 438
439 if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) 439 if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch))
440 html_hidden("h", cgit_query_head); 440 html_hidden("h", cgit_query_head);
441 441
442 if (cgit_query_sha1) 442 if (cgit_query_sha1)
443 html_hidden("id", cgit_query_sha1); 443 html_hidden("id", cgit_query_sha1);
444 if (cgit_query_sha2) 444 if (cgit_query_sha2)
445 html_hidden("id2", cgit_query_sha2); 445 html_hidden("id2", cgit_query_sha2);
446 446
447 if (incl_search) { 447 if (incl_search) {
448 if (cgit_query_grep) 448 if (cgit_query_grep)
449 html_hidden("qt", cgit_query_grep); 449 html_hidden("qt", cgit_query_grep);
450 if (cgit_query_search) 450 if (cgit_query_search)
451 html_hidden("q", cgit_query_search); 451 html_hidden("q", cgit_query_search);
452 } 452 }
453} 453}
454 454
455void cgit_print_pageheader(char *title, int show_search) 455void cgit_print_pageheader(char *title, int show_search)
456{ 456{
457 static const char *default_info = "This is cgit, a fast webinterface for git repositories"; 457 static const char *default_info = "This is cgit, a fast webinterface for git repositories";
458 int header = 0; 458 int header = 0;
459 459
460 html("<div id='sidebar'>\n"); 460 html("<table id='layout' summary=''>\n");
461 html("<div id='logo'><a href='"); 461 html("<tr><td id='sidebar'>\n");
462 html("<table class='sidebar' summary=''>\n");
463 html("<tr><td class='sidebar'>\n<a href='");
462 html_attr(cgit_rooturl()); 464 html_attr(cgit_rooturl());
463 htmlf("'><img src='%s' alt='cgit'/></a></div>\n", 465 htmlf("'><img src='%s' alt='cgit'/></a>\n",
464 cgit_logo); 466 cgit_logo);
465 html("<div class='infobox'>"); 467 html("</td></tr>\n<tr><td class='sidebar'>\n");
466 if (cgit_query_repo) { 468 if (cgit_query_repo) {
467 html("<h1 class='first'>"); 469 html("<h1 class='first'>");
468 html_txt(strrpart(cgit_repo->name, 20)); 470 html_txt(strrpart(cgit_repo->name, 20));
469 html("</h1>\n"); 471 html("</h1>\n");
470 html_txt(cgit_repo->desc); 472 html_txt(cgit_repo->desc);
471 if (cgit_repo->owner) { 473 if (cgit_repo->owner) {
472 html("<h1>owner</h1>\n"); 474 html("<h1>owner</h1>\n");
473 html_txt(cgit_repo->owner); 475 html_txt(cgit_repo->owner);
474 } 476 }
475 html("<h1>navigate</h1>\n"); 477 html("<h1>navigate</h1>\n");
476 reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, 478 reporevlink(NULL, "summary", NULL, "menu", cgit_query_head,
477 NULL, NULL); 479 NULL, NULL);
478 cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL, 480 cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL,
479 0, NULL, NULL); 481 0, NULL, NULL);
480 cgit_tree_link("tree", NULL, "menu", cgit_query_head, 482 cgit_tree_link("tree", NULL, "menu", cgit_query_head,
481 cgit_query_sha1, NULL); 483 cgit_query_sha1, NULL);
482 cgit_commit_link("commit", NULL, "menu", cgit_query_head, 484 cgit_commit_link("commit", NULL, "menu", cgit_query_head,
483 cgit_query_sha1); 485 cgit_query_sha1);
484 cgit_diff_link("diff", NULL, "menu", cgit_query_head, 486 cgit_diff_link("diff", NULL, "menu", cgit_query_head,
485 cgit_query_sha1, cgit_query_sha2, NULL); 487 cgit_query_sha1, cgit_query_sha2, NULL);
486 488
487 for_each_ref(print_archive_ref, &header); 489 for_each_ref(print_archive_ref, &header);
488 490
489 html("<h1>branch</h1>\n"); 491 html("<h1>branch</h1>\n");
490 html("<form method='get' action=''>\n"); 492 html("<form method='get' action=''>\n");
491 add_hidden_formfields(0, 1, cgit_query_page); 493 add_hidden_formfields(0, 1, cgit_query_page);
492 html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>"); 494 // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>");
493 html("<select name='h' onchange='this.form.submit();'>\n"); 495 html("<select name='h' onchange='this.form.submit();'>\n");
494 for_each_branch_ref(print_branch_option, cgit_query_head); 496 for_each_branch_ref(print_branch_option, cgit_query_head);
495 html("</select>\n"); 497 html("</select>\n");
496 html("</td><td>"); 498 // html("</td><td>");
497 html("<noscript><input type='submit' id='switch-btn' value='..'/></noscript>\n"); 499 html("<noscript><input type='submit' id='switch-btn' value='switch'/></noscript>\n");
498 html("</td></tr></table>"); 500 // html("</td></tr></table>");
499 html("</form>\n"); 501 html("</form>\n");
500 502
501 html("<h1>search</h1>\n"); 503 html("<h1>search</h1>\n");
502 html("<form method='get' action='"); 504 html("<form method='get' action='");
503 if (cgit_virtual_root) 505 if (cgit_virtual_root)
504 html_attr(cgit_fileurl(cgit_query_repo, "log", 506 html_attr(cgit_fileurl(cgit_query_repo, "log",
505 cgit_query_path, NULL)); 507 cgit_query_path, NULL));
506 html("'>\n"); 508 html("'>\n");
507 add_hidden_formfields(1, 0, "log"); 509 add_hidden_formfields(1, 0, "log");
508 html("<select name='qt'>\n"); 510 html("<select name='qt'>\n");
509 html_option("grep", "log msg", cgit_query_grep); 511 html_option("grep", "log msg", cgit_query_grep);
510 html_option("author", "author", cgit_query_grep); 512 html_option("author", "author", cgit_query_grep);
511 html_option("committer", "committer", cgit_query_grep); 513 html_option("committer", "committer", cgit_query_grep);
512 html("</select>\n"); 514 html("</select>\n");
513 html("<input class='txt' type='text' name='q' value='"); 515 html("<input class='txt' type='text' name='q' value='");
514 html_attr(cgit_query_search); 516 html_attr(cgit_query_search);
515 html("'/>\n"); 517 html("'/>\n");
516 html("</form>\n"); 518 html("</form>\n");
517 } else { 519 } else {
518 if (!cgit_index_info || html_include(cgit_index_info)) 520 if (!cgit_index_info || html_include(cgit_index_info))
519 html(default_info); 521 html(default_info);
520 } 522 }
521 523
522 html("</div>\n"); 524 html("</td></tr></table></td>\n");
523 525
524 html("</div>\n<table summary='page content' class='grid'><tr><td id='content'>\n"); 526 html("<td id='content'>\n");
525} 527}
526 528
527 529
528void cgit_print_snapshot_start(const char *mimetype, const char *filename, 530void cgit_print_snapshot_start(const char *mimetype, const char *filename,
529 struct cacheitem *item) 531 struct cacheitem *item)
530{ 532{
531 htmlf("Content-Type: %s\n", mimetype); 533 htmlf("Content-Type: %s\n", mimetype);
532 htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); 534 htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename);
533 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); 535 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime));
534 htmlf("Expires: %s\n", http_date(item->st.st_mtime + 536 htmlf("Expires: %s\n", http_date(item->st.st_mtime +
535 ttl_seconds(item->ttl))); 537 ttl_seconds(item->ttl)));
536 html("\n"); 538 html("\n");
537} 539}
538 540
539/* vim:set sw=8: */ 541/* vim:set sw=8: */