summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
Unidiff
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/ui-shared.c b/ui-shared.c
index a03661a..88dd6b8 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1,171 +1,173 @@
1/* ui-shared.c: common web output functions 1/* ui-shared.c: common web output functions
2 * 2 *
3 * Copyright (C) 2006 Lars Hjemli 3 * Copyright (C) 2006 Lars Hjemli
4 * 4 *
5 * Licensed under GNU General Public License v2 5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text) 6 * (see COPYING for full license text)
7 */ 7 */
8 8
9#include "cgit.h" 9#include "cgit.h"
10 10
11const char cgit_doctype[] = 11const char cgit_doctype[] =
12"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" 12"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n"
13" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; 13" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
14 14
15static char *http_date(time_t t) 15static char *http_date(time_t t)
16{ 16{
17 static char day[][4] = 17 static char day[][4] =
18 {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; 18 {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
19 static char month[][4] = 19 static char month[][4] =
20 {"Jan", "Feb", "Mar", "Apr", "May", "Jun", 20 {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
21 "Jul", "Aug", "Sep", "Oct", "Now", "Dec"}; 21 "Jul", "Aug", "Sep", "Oct", "Now", "Dec"};
22 struct tm *tm = gmtime(&t); 22 struct tm *tm = gmtime(&t);
23 return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], 23 return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday],
24 tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year, 24 tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year,
25 tm->tm_hour, tm->tm_min, tm->tm_sec); 25 tm->tm_hour, tm->tm_min, tm->tm_sec);
26} 26}
27 27
28static long ttl_seconds(long ttl) 28static long ttl_seconds(long ttl)
29{ 29{
30 if (ttl<0) 30 if (ttl<0)
31 return 60 * 60 * 24 * 365; 31 return 60 * 60 * 24 * 365;
32 else 32 else
33 return ttl * 60; 33 return ttl * 60;
34} 34}
35 35
36void cgit_print_error(char *msg) 36void cgit_print_error(char *msg)
37{ 37{
38 html("<div class='error'>"); 38 html("<div class='error'>");
39 html_txt(msg); 39 html_txt(msg);
40 html("</div>\n"); 40 html("</div>\n");
41} 41}
42 42
43char *cgit_rooturl() 43char *cgit_rooturl()
44{ 44{
45 if (cgit_virtual_root) 45 if (cgit_virtual_root)
46 return fmt("%s/", cgit_virtual_root); 46 return fmt("%s/", cgit_virtual_root);
47 else 47 else
48 return cgit_script_name; 48 return cgit_script_name;
49} 49}
50 50
51char *cgit_repourl(const char *reponame) 51char *cgit_repourl(const char *reponame)
52{ 52{
53 if (cgit_virtual_root) { 53 if (cgit_virtual_root) {
54 return fmt("%s/%s/", cgit_virtual_root, reponame); 54 return fmt("%s/%s/", cgit_virtual_root, reponame);
55 } else { 55 } else {
56 return fmt("?r=%s", reponame); 56 return fmt("?r=%s", reponame);
57 } 57 }
58} 58}
59 59
60char *cgit_fileurl(const char *reponame, const char *pagename, 60char *cgit_fileurl(const char *reponame, const char *pagename,
61 const char *filename, const char *query) 61 const char *filename, const char *query)
62{ 62{
63 char *tmp;
64 char *delim;
65
63 if (cgit_virtual_root) { 66 if (cgit_virtual_root) {
64 if (query) 67 tmp = fmt("%s/%s/%s/%s", cgit_virtual_root, reponame,
65 return fmt("%s/%s/%s/%s?%s", cgit_virtual_root, reponame, 68 pagename, (filename ? filename:""));
66 pagename, filename?filename:"", query); 69 delim = "?";
67 else
68 return fmt("%s/%s/%s/", cgit_virtual_root, reponame,
69 pagename);
70 } else { 70 } else {
71 if (query) 71 tmp = fmt("?url=%s/%s/%s", reponame, pagename,
72 return fmt("?r=%s&amp;p=%s&amp;%s", reponame, pagename, query); 72 (filename ? filename : ""));
73 else 73 delim = "&";
74 return fmt("?r=%s&amp;p=%s", reponame, pagename);
75 } 74 }
75 if (query)
76 tmp = fmt("%s%s%s", tmp, delim, query);
77 return tmp;
76} 78}
77 79
78char *cgit_pageurl(const char *reponame, const char *pagename, 80char *cgit_pageurl(const char *reponame, const char *pagename,
79 const char *query) 81 const char *query)
80{ 82{
81 return cgit_fileurl(reponame,pagename,0,query); 83 return cgit_fileurl(reponame,pagename,0,query);
82} 84}
83 85
84const char *cgit_repobasename(const char *reponame) 86const char *cgit_repobasename(const char *reponame)
85{ 87{
86 /* 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 */
87 static char rvbuf[1024]; 89 static char rvbuf[1024];
88 int p; 90 int p;
89 const char *rv; 91 const char *rv;
90 strncpy(rvbuf,reponame,sizeof(rvbuf)); 92 strncpy(rvbuf,reponame,sizeof(rvbuf));
91 if(rvbuf[sizeof(rvbuf)-1]) 93 if(rvbuf[sizeof(rvbuf)-1])
92 die("cgit_repobasename: truncated repository name '%s'", reponame); 94 die("cgit_repobasename: truncated repository name '%s'", reponame);
93 p = strlen(rvbuf)-1; 95 p = strlen(rvbuf)-1;
94 /* strip trailing slashes */ 96 /* strip trailing slashes */
95 while(p && rvbuf[p]=='/') rvbuf[p--]=0; 97 while(p && rvbuf[p]=='/') rvbuf[p--]=0;
96 /* strip trailing .git */ 98 /* strip trailing .git */
97 if(p>=3 && !strncmp(&rvbuf[p-3],".git",4)) { 99 if(p>=3 && !strncmp(&rvbuf[p-3],".git",4)) {
98 p -= 3; rvbuf[p--] = 0; 100 p -= 3; rvbuf[p--] = 0;
99 } 101 }
100 /* strip more trailing slashes if any */ 102 /* strip more trailing slashes if any */
101 while( p && rvbuf[p]=='/') rvbuf[p--]=0; 103 while( p && rvbuf[p]=='/') rvbuf[p--]=0;
102 /* find last slash in the remaining string */ 104 /* find last slash in the remaining string */
103 rv = strrchr(rvbuf,'/'); 105 rv = strrchr(rvbuf,'/');
104 if(rv) 106 if(rv)
105 return ++rv; 107 return ++rv;
106 return rvbuf; 108 return rvbuf;
107} 109}
108 110
109char *cgit_currurl() 111char *cgit_currurl()
110{ 112{
111 if (!cgit_virtual_root) 113 if (!cgit_virtual_root)
112 return cgit_script_name; 114 return cgit_script_name;
113 else if (cgit_query_page) 115 else if (cgit_query_page)
114 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);
115 else if (cgit_query_repo) 117 else if (cgit_query_repo)
116 return fmt("%s/%s/", cgit_virtual_root, cgit_query_repo); 118 return fmt("%s/%s/", cgit_virtual_root, cgit_query_repo);
117 else 119 else
118 return fmt("%s/", cgit_virtual_root); 120 return fmt("%s/", cgit_virtual_root);
119} 121}
120 122
121static char *repolink(char *title, char *class, char *page, char *head, 123static char *repolink(char *title, char *class, char *page, char *head,
122 char *path) 124 char *path)
123{ 125{
124 char *delim = "?"; 126 char *delim = "?";
125 127
126 html("<a"); 128 html("<a");
127 if (title) { 129 if (title) {
128 html(" title='"); 130 html(" title='");
129 html_attr(title); 131 html_attr(title);
130 html("'"); 132 html("'");
131 } 133 }
132 if (class) { 134 if (class) {
133 html(" class='"); 135 html(" class='");
134 html_attr(class); 136 html_attr(class);
135 html("'"); 137 html("'");
136 } 138 }
137 html(" href='"); 139 html(" href='");
138 if (cgit_virtual_root) { 140 if (cgit_virtual_root) {
139 html_attr(cgit_virtual_root); 141 html_attr(cgit_virtual_root);
140 if (cgit_virtual_root[strlen(cgit_virtual_root) - 1] != '/') 142 if (cgit_virtual_root[strlen(cgit_virtual_root) - 1] != '/')
141 html("/"); 143 html("/");
142 html_attr(cgit_repo->url); 144 html_attr(cgit_repo->url);
143 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') 145 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/')
144 html("/"); 146 html("/");
145 if (page) { 147 if (page) {
146 html(page); 148 html(page);
147 html("/"); 149 html("/");
148 if (path) 150 if (path)
149 html_attr(path); 151 html_attr(path);
150 } 152 }
151 } else { 153 } else {
152 html(cgit_script_name); 154 html(cgit_script_name);
153 html("?url="); 155 html("?url=");
154 html_attr(cgit_repo->url); 156 html_attr(cgit_repo->url);
155 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') 157 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/')
156 html("/"); 158 html("/");
157 if (page) { 159 if (page) {
158 html(page); 160 html(page);
159 html("/"); 161 html("/");
160 if (path) 162 if (path)
161 html_attr(path); 163 html_attr(path);
162 } 164 }
163 delim = "&amp;"; 165 delim = "&amp;";
164 } 166 }
165 if (head && strcmp(head, cgit_repo->defbranch)) { 167 if (head && strcmp(head, cgit_repo->defbranch)) {
166 html(delim); 168 html(delim);
167 html("h="); 169 html("h=");
168 html_attr(head); 170 html_attr(head);
169 delim = "&amp;"; 171 delim = "&amp;";
170 } 172 }
171 return fmt("%s", delim); 173 return fmt("%s", delim);
@@ -328,201 +330,205 @@ void cgit_print_age(time_t t, time_t max_relative, char *format)
328 htmlf("<span class='age-hours'>%.0f hours</span>", 330 htmlf("<span class='age-hours'>%.0f hours</span>",
329 secs * 1.0 / TM_HOUR); 331 secs * 1.0 / TM_HOUR);
330 return; 332 return;
331 } 333 }
332 if (secs < TM_WEEK * 2) { 334 if (secs < TM_WEEK * 2) {
333 htmlf("<span class='age-days'>%.0f days</span>", 335 htmlf("<span class='age-days'>%.0f days</span>",
334 secs * 1.0 / TM_DAY); 336 secs * 1.0 / TM_DAY);
335 return; 337 return;
336 } 338 }
337 if (secs < TM_MONTH * 2) { 339 if (secs < TM_MONTH * 2) {
338 htmlf("<span class='age-weeks'>%.0f weeks</span>", 340 htmlf("<span class='age-weeks'>%.0f weeks</span>",
339 secs * 1.0 / TM_WEEK); 341 secs * 1.0 / TM_WEEK);
340 return; 342 return;
341 } 343 }
342 if (secs < TM_YEAR * 2) { 344 if (secs < TM_YEAR * 2) {
343 htmlf("<span class='age-months'>%.0f months</span>", 345 htmlf("<span class='age-months'>%.0f months</span>",
344 secs * 1.0 / TM_MONTH); 346 secs * 1.0 / TM_MONTH);
345 return; 347 return;
346 } 348 }
347 htmlf("<span class='age-years'>%.0f years</span>", 349 htmlf("<span class='age-years'>%.0f years</span>",
348 secs * 1.0 / TM_YEAR); 350 secs * 1.0 / TM_YEAR);
349} 351}
350 352
351void cgit_print_docstart(char *title, struct cacheitem *item) 353void cgit_print_docstart(char *title, struct cacheitem *item)
352{ 354{
353 html("Content-Type: text/html; charset=utf-8\n"); 355 html("Content-Type: text/html; charset=utf-8\n");
354 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); 356 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime));
355 htmlf("Expires: %s\n", http_date(item->st.st_mtime + 357 htmlf("Expires: %s\n", http_date(item->st.st_mtime +
356 ttl_seconds(item->ttl))); 358 ttl_seconds(item->ttl)));
357 html("\n"); 359 html("\n");
358 html(cgit_doctype); 360 html(cgit_doctype);
359 html("<html>\n"); 361 html("<html>\n");
360 html("<head>\n"); 362 html("<head>\n");
361 html("<title>"); 363 html("<title>");
362 html_txt(title); 364 html_txt(title);
363 html("</title>\n"); 365 html("</title>\n");
364 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); 366 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
365 html("<link rel='stylesheet' type='text/css' href='"); 367 html("<link rel='stylesheet' type='text/css' href='");
366 html_attr(cgit_css); 368 html_attr(cgit_css);
367 html("'/>\n"); 369 html("'/>\n");
368 html("</head>\n"); 370 html("</head>\n");
369 html("<body>\n"); 371 html("<body>\n");
370} 372}
371 373
372void cgit_print_docend() 374void cgit_print_docend()
373{ 375{
374 html("</td>\n</tr>\n<table>\n</body>\n</html>\n"); 376 html("</td>\n</tr>\n<table>\n</body>\n</html>\n");
375} 377}
376 378
377int print_branch_option(const char *refname, const unsigned char *sha1, 379int print_branch_option(const char *refname, const unsigned char *sha1,
378 int flags, void *cb_data) 380 int flags, void *cb_data)
379{ 381{
380 char *name = (char *)refname; 382 char *name = (char *)refname;
381 html_option(name, name, cgit_query_head); 383 html_option(name, name, cgit_query_head);
382 return 0; 384 return 0;
383} 385}
384 386
385int print_archive_ref(const char *refname, const unsigned char *sha1, 387int print_archive_ref(const char *refname, const unsigned char *sha1,
386 int flags, void *cb_data) 388 int flags, void *cb_data)
387{ 389{
388 struct tag *tag; 390 struct tag *tag;
389 struct taginfo *info; 391 struct taginfo *info;
390 struct object *obj; 392 struct object *obj;
391 char buf[256], *url; 393 char buf[256], *url;
392 unsigned char fileid[20]; 394 unsigned char fileid[20];
393 int *header = (int *)cb_data; 395 int *header = (int *)cb_data;
394 396
395 if (prefixcmp(refname, "refs/archives")) 397 if (prefixcmp(refname, "refs/archives"))
396 return 0; 398 return 0;
397 strncpy(buf, refname+14, sizeof(buf)); 399 strncpy(buf, refname+14, sizeof(buf));
398 obj = parse_object(sha1); 400 obj = parse_object(sha1);
399 if (!obj) 401 if (!obj)
400 return 1; 402 return 1;
401 if (obj->type == OBJ_TAG) { 403 if (obj->type == OBJ_TAG) {
402 tag = lookup_tag(sha1); 404 tag = lookup_tag(sha1);
403 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) 405 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag)))
404 return 0; 406 return 0;
405 hashcpy(fileid, tag->tagged->sha1); 407 hashcpy(fileid, tag->tagged->sha1);
406 } else if (obj->type != OBJ_BLOB) { 408 } else if (obj->type != OBJ_BLOB) {
407 return 0; 409 return 0;
408 } else { 410 } else {
409 hashcpy(fileid, sha1); 411 hashcpy(fileid, sha1);
410 } 412 }
411 if (!*header) { 413 if (!*header) {
412 html("<p><h1>download</h1>"); 414 html("<p><h1>download</h1>");
413 *header = 1; 415 *header = 1;
414 } 416 }
415 url = cgit_pageurl(cgit_query_repo, "blob", 417 url = cgit_pageurl(cgit_query_repo, "blob",
416 fmt("id=%s&amp;path=%s", sha1_to_hex(fileid), 418 fmt("id=%s&amp;path=%s", sha1_to_hex(fileid),
417 buf)); 419 buf));
418 html_link_open(url, NULL, "menu"); 420 html_link_open(url, NULL, "menu");
419 html_txt(strlpart(buf, 20)); 421 html_txt(strlpart(buf, 20));
420 html_link_close(); 422 html_link_close();
421 return 0; 423 return 0;
422} 424}
423 425
424void add_hidden_formfields(int incl_head, int incl_search) 426void add_hidden_formfields(int incl_head, int incl_search, char *page)
425{ 427{
428 char *url;
429
426 if (!cgit_virtual_root) { 430 if (!cgit_virtual_root) {
427 if (cgit_query_repo) 431 url = fmt("%s/%s", cgit_query_repo, page);
428 html_hidden("r", cgit_query_repo); 432 if (cgit_query_path)
429 if (cgit_query_page) 433 url = fmt("%s/%s", url, cgit_query_path);
430 html_hidden("p", cgit_query_page); 434 html_hidden("url", url);
431 } 435 }
432 436
433 if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) 437 if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch))
434 html_hidden("h", cgit_query_head); 438 html_hidden("h", cgit_query_head);
435 439
436 if (cgit_query_sha1) 440 if (cgit_query_sha1)
437 html_hidden("id", cgit_query_sha1); 441 html_hidden("id", cgit_query_sha1);
438 if (cgit_query_sha2) 442 if (cgit_query_sha2)
439 html_hidden("id2", cgit_query_sha2); 443 html_hidden("id2", cgit_query_sha2);
440 444
441 if (incl_search) { 445 if (incl_search) {
442 if (cgit_query_grep) 446 if (cgit_query_grep)
443 html_hidden("qt", cgit_query_grep); 447 html_hidden("qt", cgit_query_grep);
444 if (cgit_query_search) 448 if (cgit_query_search)
445 html_hidden("q", cgit_query_search); 449 html_hidden("q", cgit_query_search);
446 } 450 }
447} 451}
448 452
449void cgit_print_pageheader(char *title, int show_search) 453void cgit_print_pageheader(char *title, int show_search)
450{ 454{
451 static const char *default_info = "This is cgit, a fast webinterface for git repositories"; 455 static const char *default_info = "This is cgit, a fast webinterface for git repositories";
452 int header = 0; 456 int header = 0;
453 457
454 html("<div id='sidebar'>\n"); 458 html("<div id='sidebar'>\n");
455 html("<a href='"); 459 html("<a href='");
456 html_attr(cgit_rooturl()); 460 html_attr(cgit_rooturl());
457 htmlf("'><div id='logo'><img src='%s' alt='cgit'/></div></a>\n", 461 htmlf("'><div id='logo'><img src='%s' alt='cgit'/></div></a>\n",
458 cgit_logo); 462 cgit_logo);
459 html("<div class='infobox'>"); 463 html("<div class='infobox'>");
460 if (cgit_query_repo) { 464 if (cgit_query_repo) {
461 html("<h1>"); 465 html("<h1>");
462 html_txt(strrpart(cgit_repo->name, 20)); 466 html_txt(strrpart(cgit_repo->name, 20));
463 html("</h1>\n"); 467 html("</h1>\n");
464 html_txt(cgit_repo->desc); 468 html_txt(cgit_repo->desc);
465 if (cgit_repo->owner) { 469 if (cgit_repo->owner) {
466 html("<p>\n<h1>owner</h1>\n"); 470 html("<p>\n<h1>owner</h1>\n");
467 html_txt(cgit_repo->owner); 471 html_txt(cgit_repo->owner);
468 } 472 }
469 html("<p>\n<h1>navigate</h1>\n"); 473 html("<p>\n<h1>navigate</h1>\n");
470 reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, 474 reporevlink(NULL, "summary", NULL, "menu", cgit_query_head,
471 NULL, NULL); 475 NULL, NULL);
472 cgit_log_link("log", NULL, "menu", cgit_query_head, 476 cgit_log_link("log", NULL, "menu", cgit_query_head,
473 cgit_query_sha1, cgit_query_path, 0, NULL, NULL); 477 cgit_query_sha1, cgit_query_path, 0, NULL, NULL);
474 cgit_tree_link("tree", NULL, "menu", cgit_query_head, 478 cgit_tree_link("tree", NULL, "menu", cgit_query_head,
475 cgit_query_sha1, NULL); 479 cgit_query_sha1, NULL);
476 cgit_commit_link("commit", NULL, "menu", cgit_query_head, 480 cgit_commit_link("commit", NULL, "menu", cgit_query_head,
477 cgit_query_sha1); 481 cgit_query_sha1);
478 cgit_diff_link("diff", NULL, "menu", cgit_query_head, 482 cgit_diff_link("diff", NULL, "menu", cgit_query_head,
479 cgit_query_sha1, cgit_query_sha2, 483 cgit_query_sha1, cgit_query_sha2,
480 cgit_query_path); 484 cgit_query_path);
481 485
482 for_each_ref(print_archive_ref, &header); 486 for_each_ref(print_archive_ref, &header);
483 487
484 html("<p>\n<h1>branch</h1>\n"); 488 html("<p>\n<h1>branch</h1>\n");
485 html("<form method='get' action=''>\n"); 489 html("<form method='get' action=''>\n");
486 add_hidden_formfields(0, 1); 490 add_hidden_formfields(0, 1, cgit_query_page);
487 html("<select name='h' onchange='this.form.submit();'>\n"); 491 html("<select name='h' onchange='this.form.submit();'>\n");
488 for_each_branch_ref(print_branch_option, cgit_query_head); 492 for_each_branch_ref(print_branch_option, cgit_query_head);
489 html("</select>\n"); 493 html("</select>\n");
490 html("</form>\n"); 494 html("</form>\n");
491 495
492 html("<p>\n<h1>search</h1>\n"); 496 html("<p>\n<h1>search</h1>\n");
493 html("<form method='get' action='"); 497 html("<form method='get' action='");
494 html_attr(cgit_pageurl(cgit_query_repo, "log", NULL)); 498 if (cgit_virtual_root)
499 html_attr(cgit_fileurl(cgit_query_repo, "log",
500 cgit_query_path, NULL));
495 html("'>\n"); 501 html("'>\n");
496 add_hidden_formfields(1, 0); 502 add_hidden_formfields(1, 0, "log");
497 html("<select name='qt'>\n"); 503 html("<select name='qt'>\n");
498 html_option("grep", "log msg", cgit_query_grep); 504 html_option("grep", "log msg", cgit_query_grep);
499 html_option("author", "author", cgit_query_grep); 505 html_option("author", "author", cgit_query_grep);
500 html_option("committer", "committer", cgit_query_grep); 506 html_option("committer", "committer", cgit_query_grep);
501 html("</select>\n"); 507 html("</select>\n");
502 html("<input class='txt' type='text' name='q' value='"); 508 html("<input class='txt' type='text' name='q' value='");
503 html_attr(cgit_query_search); 509 html_attr(cgit_query_search);
504 html("'/>\n"); 510 html("'/>\n");
505 html("</form>\n"); 511 html("</form>\n");
506 } else { 512 } else {
507 if (!cgit_index_info || html_include(cgit_index_info)) 513 if (!cgit_index_info || html_include(cgit_index_info))
508 html(default_info); 514 html(default_info);
509 } 515 }
510 516
511 html("</div>\n"); 517 html("</div>\n");
512 518
513 html("</div>\n<table class='grid'><tr><td id='content'>\n"); 519 html("</div>\n<table class='grid'><tr><td id='content'>\n");
514} 520}
515 521
516 522
517void cgit_print_snapshot_start(const char *mimetype, const char *filename, 523void cgit_print_snapshot_start(const char *mimetype, const char *filename,
518 struct cacheitem *item) 524 struct cacheitem *item)
519{ 525{
520 htmlf("Content-Type: %s\n", mimetype); 526 htmlf("Content-Type: %s\n", mimetype);
521 htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); 527 htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename);
522 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); 528 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime));
523 htmlf("Expires: %s\n", http_date(item->st.st_mtime + 529 htmlf("Expires: %s\n", http_date(item->st.st_mtime +
524 ttl_seconds(item->ttl))); 530 ttl_seconds(item->ttl)));
525 html("\n"); 531 html("\n");
526} 532}
527 533
528/* vim:set sw=8: */ 534/* vim:set sw=8: */