summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
Unidiff
Diffstat (limited to 'ui-shared.c') (more/less context) (show whitespace changes)
-rw-r--r--ui-shared.c112
1 files changed, 51 insertions, 61 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 2eff79d..2596023 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1,84 +1,76 @@
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#include "html.h" 10#include "html.h"
11 11
12const char cgit_doctype[] = 12const char cgit_doctype[] =
13"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" 13"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n"
14" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; 14" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
15 15
16static char *http_date(time_t t) 16static char *http_date(time_t t)
17{ 17{
18 static char day[][4] = 18 static char day[][4] =
19 {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; 19 {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
20 static char month[][4] = 20 static char month[][4] =
21 {"Jan", "Feb", "Mar", "Apr", "May", "Jun", 21 {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
22 "Jul", "Aug", "Sep", "Oct", "Now", "Dec"}; 22 "Jul", "Aug", "Sep", "Oct", "Now", "Dec"};
23 struct tm *tm = gmtime(&t); 23 struct tm *tm = gmtime(&t);
24 return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], 24 return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday],
25 tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year, 25 tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year,
26 tm->tm_hour, tm->tm_min, tm->tm_sec); 26 tm->tm_hour, tm->tm_min, tm->tm_sec);
27} 27}
28 28
29static long ttl_seconds(long ttl)
30{
31 if (ttl<0)
32 return 60 * 60 * 24 * 365;
33 else
34 return ttl * 60;
35}
36
37void cgit_print_error(char *msg) 29void cgit_print_error(char *msg)
38{ 30{
39 html("<div class='error'>"); 31 html("<div class='error'>");
40 html_txt(msg); 32 html_txt(msg);
41 html("</div>\n"); 33 html("</div>\n");
42} 34}
43 35
44char *cgit_rooturl() 36char *cgit_rooturl()
45{ 37{
46 if (ctx.cfg.virtual_root) 38 if (ctx.cfg.virtual_root)
47 return fmt("%s/", ctx.cfg.virtual_root); 39 return fmt("%s/", ctx.cfg.virtual_root);
48 else 40 else
49 return ctx.cfg.script_name; 41 return ctx.cfg.script_name;
50} 42}
51 43
52char *cgit_repourl(const char *reponame) 44char *cgit_repourl(const char *reponame)
53{ 45{
54 if (ctx.cfg.virtual_root) { 46 if (ctx.cfg.virtual_root) {
55 return fmt("%s/%s/", ctx.cfg.virtual_root, reponame); 47 return fmt("%s/%s/", ctx.cfg.virtual_root, reponame);
56 } else { 48 } else {
57 return fmt("?r=%s", reponame); 49 return fmt("?r=%s", reponame);
58 } 50 }
59} 51}
60 52
61char *cgit_fileurl(const char *reponame, const char *pagename, 53char *cgit_fileurl(const char *reponame, const char *pagename,
62 const char *filename, const char *query) 54 const char *filename, const char *query)
63{ 55{
64 char *tmp; 56 char *tmp;
65 char *delim; 57 char *delim;
66 58
67 if (ctx.cfg.virtual_root) { 59 if (ctx.cfg.virtual_root) {
68 tmp = fmt("%s/%s/%s/%s", ctx.cfg.virtual_root, reponame, 60 tmp = fmt("%s/%s/%s/%s", ctx.cfg.virtual_root, reponame,
69 pagename, (filename ? filename:"")); 61 pagename, (filename ? filename:""));
70 delim = "?"; 62 delim = "?";
71 } else { 63 } else {
72 tmp = fmt("?url=%s/%s/%s", reponame, pagename, 64 tmp = fmt("?url=%s/%s/%s", reponame, pagename,
73 (filename ? filename : "")); 65 (filename ? filename : ""));
74 delim = "&"; 66 delim = "&";
75 } 67 }
76 if (query) 68 if (query)
77 tmp = fmt("%s%s%s", tmp, delim, query); 69 tmp = fmt("%s%s%s", tmp, delim, query);
78 return tmp; 70 return tmp;
79} 71}
80 72
81char *cgit_pageurl(const char *reponame, const char *pagename, 73char *cgit_pageurl(const char *reponame, const char *pagename,
82 const char *query) 74 const char *query)
83{ 75{
84 return cgit_fileurl(reponame,pagename,0,query); 76 return cgit_fileurl(reponame,pagename,0,query);
@@ -316,271 +308,269 @@ void cgit_print_date(time_t secs, char *format)
316 time = gmtime(&secs); 308 time = gmtime(&secs);
317 strftime(buf, sizeof(buf)-1, format, time); 309 strftime(buf, sizeof(buf)-1, format, time);
318 html_txt(buf); 310 html_txt(buf);
319} 311}
320 312
321void cgit_print_age(time_t t, time_t max_relative, char *format) 313void cgit_print_age(time_t t, time_t max_relative, char *format)
322{ 314{
323 time_t now, secs; 315 time_t now, secs;
324 316
325 if (!t) 317 if (!t)
326 return; 318 return;
327 time(&now); 319 time(&now);
328 secs = now - t; 320 secs = now - t;
329 321
330 if (secs > max_relative && max_relative >= 0) { 322 if (secs > max_relative && max_relative >= 0) {
331 cgit_print_date(t, format); 323 cgit_print_date(t, format);
332 return; 324 return;
333 } 325 }
334 326
335 if (secs < TM_HOUR * 2) { 327 if (secs < TM_HOUR * 2) {
336 htmlf("<span class='age-mins'>%.0f min.</span>", 328 htmlf("<span class='age-mins'>%.0f min.</span>",
337 secs * 1.0 / TM_MIN); 329 secs * 1.0 / TM_MIN);
338 return; 330 return;
339 } 331 }
340 if (secs < TM_DAY * 2) { 332 if (secs < TM_DAY * 2) {
341 htmlf("<span class='age-hours'>%.0f hours</span>", 333 htmlf("<span class='age-hours'>%.0f hours</span>",
342 secs * 1.0 / TM_HOUR); 334 secs * 1.0 / TM_HOUR);
343 return; 335 return;
344 } 336 }
345 if (secs < TM_WEEK * 2) { 337 if (secs < TM_WEEK * 2) {
346 htmlf("<span class='age-days'>%.0f days</span>", 338 htmlf("<span class='age-days'>%.0f days</span>",
347 secs * 1.0 / TM_DAY); 339 secs * 1.0 / TM_DAY);
348 return; 340 return;
349 } 341 }
350 if (secs < TM_MONTH * 2) { 342 if (secs < TM_MONTH * 2) {
351 htmlf("<span class='age-weeks'>%.0f weeks</span>", 343 htmlf("<span class='age-weeks'>%.0f weeks</span>",
352 secs * 1.0 / TM_WEEK); 344 secs * 1.0 / TM_WEEK);
353 return; 345 return;
354 } 346 }
355 if (secs < TM_YEAR * 2) { 347 if (secs < TM_YEAR * 2) {
356 htmlf("<span class='age-months'>%.0f months</span>", 348 htmlf("<span class='age-months'>%.0f months</span>",
357 secs * 1.0 / TM_MONTH); 349 secs * 1.0 / TM_MONTH);
358 return; 350 return;
359 } 351 }
360 htmlf("<span class='age-years'>%.0f years</span>", 352 htmlf("<span class='age-years'>%.0f years</span>",
361 secs * 1.0 / TM_YEAR); 353 secs * 1.0 / TM_YEAR);
362} 354}
363 355
364void cgit_print_docstart(char *title, struct cacheitem *item) 356void cgit_print_http_headers(struct cgit_context *ctx)
365{ 357{
366 html("Content-Type: text/html; charset=" PAGE_ENCODING "\n"); 358 if (ctx->page.mimetype && ctx->page.charset)
367 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); 359 htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype,
368 htmlf("Expires: %s\n", http_date(item->st.st_mtime + 360 ctx->page.charset);
369 ttl_seconds(item->ttl))); 361 else if (ctx->page.mimetype)
362 htmlf("Content-Type: %s\n", ctx->page.mimetype);
363 if (ctx->page.filename)
364 htmlf("Content-Disposition: inline; filename=\"%s\"\n",
365 ctx->page.filename);
366 htmlf("Last-Modified: %s\n", http_date(ctx->page.modified));
367 htmlf("Expires: %s\n", http_date(ctx->page.expires));
370 html("\n"); 368 html("\n");
369}
370
371void cgit_print_docstart(struct cgit_context *ctx)
372{
371 html(cgit_doctype); 373 html(cgit_doctype);
372 html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); 374 html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n");
373 html("<head>\n"); 375 html("<head>\n");
374 html("<title>"); 376 html("<title>");
375 html_txt(title); 377 html_txt(ctx->page.title);
376 html("</title>\n"); 378 html("</title>\n");
377 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); 379 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
378 if (ctx.cfg.robots && *ctx.cfg.robots) 380 if (ctx->cfg.robots && *ctx->cfg.robots)
379 htmlf("<meta name='robots' content='%s'/>\n", ctx.cfg.robots); 381 htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots);
380 html("<link rel='stylesheet' type='text/css' href='"); 382 html("<link rel='stylesheet' type='text/css' href='");
381 html_attr(ctx.cfg.css); 383 html_attr(ctx->cfg.css);
382 html("'/>\n"); 384 html("'/>\n");
383 html("</head>\n"); 385 html("</head>\n");
384 html("<body>\n"); 386 html("<body>\n");
385} 387}
386 388
387void cgit_print_docend() 389void cgit_print_docend()
388{ 390{
389 html("</td>\n</tr>\n</table>\n</body>\n</html>\n"); 391 html("</td>\n</tr>\n</table>\n</body>\n</html>\n");
390} 392}
391 393
392int print_branch_option(const char *refname, const unsigned char *sha1, 394int print_branch_option(const char *refname, const unsigned char *sha1,
393 int flags, void *cb_data) 395 int flags, void *cb_data)
394{ 396{
395 char *name = (char *)refname; 397 char *name = (char *)refname;
396 html_option(name, name, ctx.qry.head); 398 html_option(name, name, ctx.qry.head);
397 return 0; 399 return 0;
398} 400}
399 401
400int print_archive_ref(const char *refname, const unsigned char *sha1, 402int print_archive_ref(const char *refname, const unsigned char *sha1,
401 int flags, void *cb_data) 403 int flags, void *cb_data)
402{ 404{
403 struct tag *tag; 405 struct tag *tag;
404 struct taginfo *info; 406 struct taginfo *info;
405 struct object *obj; 407 struct object *obj;
406 char buf[256], *url; 408 char buf[256], *url;
407 unsigned char fileid[20]; 409 unsigned char fileid[20];
408 int *header = (int *)cb_data; 410 int *header = (int *)cb_data;
409 411
410 if (prefixcmp(refname, "refs/archives")) 412 if (prefixcmp(refname, "refs/archives"))
411 return 0; 413 return 0;
412 strncpy(buf, refname+14, sizeof(buf)); 414 strncpy(buf, refname+14, sizeof(buf));
413 obj = parse_object(sha1); 415 obj = parse_object(sha1);
414 if (!obj) 416 if (!obj)
415 return 1; 417 return 1;
416 if (obj->type == OBJ_TAG) { 418 if (obj->type == OBJ_TAG) {
417 tag = lookup_tag(sha1); 419 tag = lookup_tag(sha1);
418 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) 420 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag)))
419 return 0; 421 return 0;
420 hashcpy(fileid, tag->tagged->sha1); 422 hashcpy(fileid, tag->tagged->sha1);
421 } else if (obj->type != OBJ_BLOB) { 423 } else if (obj->type != OBJ_BLOB) {
422 return 0; 424 return 0;
423 } else { 425 } else {
424 hashcpy(fileid, sha1); 426 hashcpy(fileid, sha1);
425 } 427 }
426 if (!*header) { 428 if (!*header) {
427 html("<h1>download</h1>\n"); 429 html("<h1>download</h1>\n");
428 *header = 1; 430 *header = 1;
429 } 431 }
430 url = cgit_pageurl(ctx.qry.repo, "blob", 432 url = cgit_pageurl(ctx.qry.repo, "blob",
431 fmt("id=%s&amp;path=%s", sha1_to_hex(fileid), 433 fmt("id=%s&amp;path=%s", sha1_to_hex(fileid),
432 buf)); 434 buf));
433 html_link_open(url, NULL, "menu"); 435 html_link_open(url, NULL, "menu");
434 html_txt(strlpart(buf, 20)); 436 html_txt(strlpart(buf, 20));
435 html_link_close(); 437 html_link_close();
436 return 0; 438 return 0;
437} 439}
438 440
439void add_hidden_formfields(int incl_head, int incl_search, char *page) 441void add_hidden_formfields(int incl_head, int incl_search, char *page)
440{ 442{
441 char *url; 443 char *url;
442 444
443 if (!ctx.cfg.virtual_root) { 445 if (!ctx.cfg.virtual_root) {
444 url = fmt("%s/%s", ctx.qry.repo, page); 446 url = fmt("%s/%s", ctx.qry.repo, page);
445 if (ctx.qry.path) 447 if (ctx.qry.path)
446 url = fmt("%s/%s", url, ctx.qry.path); 448 url = fmt("%s/%s", url, ctx.qry.path);
447 html_hidden("url", url); 449 html_hidden("url", url);
448 } 450 }
449 451
450 if (incl_head && strcmp(ctx.qry.head, ctx.repo->defbranch)) 452 if (incl_head && strcmp(ctx.qry.head, ctx.repo->defbranch))
451 html_hidden("h", ctx.qry.head); 453 html_hidden("h", ctx.qry.head);
452 454
453 if (ctx.qry.sha1) 455 if (ctx.qry.sha1)
454 html_hidden("id", ctx.qry.sha1); 456 html_hidden("id", ctx.qry.sha1);
455 if (ctx.qry.sha2) 457 if (ctx.qry.sha2)
456 html_hidden("id2", ctx.qry.sha2); 458 html_hidden("id2", ctx.qry.sha2);
457 459
458 if (incl_search) { 460 if (incl_search) {
459 if (ctx.qry.grep) 461 if (ctx.qry.grep)
460 html_hidden("qt", ctx.qry.grep); 462 html_hidden("qt", ctx.qry.grep);
461 if (ctx.qry.search) 463 if (ctx.qry.search)
462 html_hidden("q", ctx.qry.search); 464 html_hidden("q", ctx.qry.search);
463 } 465 }
464} 466}
465 467
466void cgit_print_pageheader(char *title, int show_search) 468void cgit_print_pageheader(struct cgit_context *ctx)
467{ 469{
468 static const char *default_info = "This is cgit, a fast webinterface for git repositories"; 470 static const char *default_info = "This is cgit, a fast webinterface for git repositories";
469 int header = 0; 471 int header = 0;
470 char *url; 472 char *url;
471 473
472 html("<table id='layout' summary=''>\n"); 474 html("<table id='layout' summary=''>\n");
473 html("<tr><td id='sidebar'>\n"); 475 html("<tr><td id='sidebar'>\n");
474 html("<table class='sidebar' cellspacing='0' summary=''>\n"); 476 html("<table class='sidebar' cellspacing='0' summary=''>\n");
475 html("<tr><td class='sidebar'>\n<a href='"); 477 html("<tr><td class='sidebar'>\n<a href='");
476 html_attr(cgit_rooturl()); 478 html_attr(cgit_rooturl());
477 htmlf("'><img src='%s' alt='cgit'/></a>\n", 479 htmlf("'><img src='%s' alt='cgit'/></a>\n",
478 ctx.cfg.logo); 480 ctx->cfg.logo);
479 html("</td></tr>\n<tr><td class='sidebar'>\n"); 481 html("</td></tr>\n<tr><td class='sidebar'>\n");
480 if (ctx.repo) { 482 if (ctx->repo) {
481 html("<h1 class='first'>"); 483 html("<h1 class='first'>");
482 html_txt(strrpart(ctx.repo->name, 20)); 484 html_txt(strrpart(ctx->repo->name, 20));
483 html("</h1>\n"); 485 html("</h1>\n");
484 html_txt(ctx.repo->desc); 486 html_txt(ctx->repo->desc);
485 if (ctx.repo->owner) { 487 if (ctx->repo->owner) {
486 html("<h1>owner</h1>\n"); 488 html("<h1>owner</h1>\n");
487 html_txt(ctx.repo->owner); 489 html_txt(ctx->repo->owner);
488 } 490 }
489 html("<h1>navigate</h1>\n"); 491 html("<h1>navigate</h1>\n");
490 reporevlink(NULL, "summary", NULL, "menu", ctx.qry.head, 492 reporevlink(NULL, "summary", NULL, "menu", ctx->qry.head,
491 NULL, NULL); 493 NULL, NULL);
492 cgit_log_link("log", NULL, "menu", ctx.qry.head, NULL, NULL, 494 cgit_log_link("log", NULL, "menu", ctx->qry.head, NULL, NULL,
493 0, NULL, NULL); 495 0, NULL, NULL);
494 cgit_tree_link("tree", NULL, "menu", ctx.qry.head, 496 cgit_tree_link("tree", NULL, "menu", ctx->qry.head,
495 ctx.qry.sha1, NULL); 497 ctx->qry.sha1, NULL);
496 cgit_commit_link("commit", NULL, "menu", ctx.qry.head, 498 cgit_commit_link("commit", NULL, "menu", ctx->qry.head,
497 ctx.qry.sha1); 499 ctx->qry.sha1);
498 cgit_diff_link("diff", NULL, "menu", ctx.qry.head, 500 cgit_diff_link("diff", NULL, "menu", ctx->qry.head,
499 ctx.qry.sha1, ctx.qry.sha2, NULL); 501 ctx->qry.sha1, ctx->qry.sha2, NULL);
500 cgit_patch_link("patch", NULL, "menu", ctx.qry.head, 502 cgit_patch_link("patch", NULL, "menu", ctx->qry.head,
501 ctx.qry.sha1); 503 ctx->qry.sha1);
502 504
503 for_each_ref(print_archive_ref, &header); 505 for_each_ref(print_archive_ref, &header);
504 506
505 if (ctx.repo->clone_url || ctx.cfg.clone_prefix) { 507 if (ctx->repo->clone_url || ctx->cfg.clone_prefix) {
506 html("<h1>clone</h1>\n"); 508 html("<h1>clone</h1>\n");
507 if (ctx.repo->clone_url) 509 if (ctx->repo->clone_url)
508 url = ctx.repo->clone_url; 510 url = ctx->repo->clone_url;
509 else 511 else
510 url = fmt("%s%s", ctx.cfg.clone_prefix, 512 url = fmt("%s%s", ctx->cfg.clone_prefix,
511 ctx.repo->url); 513 ctx->repo->url);
512 html("<a class='menu' href='"); 514 html("<a class='menu' href='");
513 html_attr(url); 515 html_attr(url);
514 html("' title='"); 516 html("' title='");
515 html_attr(url); 517 html_attr(url);
516 html("'>\n"); 518 html("'>\n");
517 html_txt(strrpart(url, 20)); 519 html_txt(strrpart(url, 20));
518 html("</a>\n"); 520 html("</a>\n");
519 } 521 }
520 522
521 html("<h1>branch</h1>\n"); 523 html("<h1>branch</h1>\n");
522 html("<form method='get' action=''>\n"); 524 html("<form method='get' action=''>\n");
523 add_hidden_formfields(0, 1, ctx.qry.page); 525 add_hidden_formfields(0, 1, ctx->qry.page);
524 // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>"); 526 // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>");
525 html("<select name='h' onchange='this.form.submit();'>\n"); 527 html("<select name='h' onchange='this.form.submit();'>\n");
526 for_each_branch_ref(print_branch_option, ctx.qry.head); 528 for_each_branch_ref(print_branch_option, ctx->qry.head);
527 html("</select>\n"); 529 html("</select>\n");
528 // html("</td><td>"); 530 // html("</td><td>");
529 html("<noscript><input type='submit' id='switch-btn' value='switch'/></noscript>\n"); 531 html("<noscript><input type='submit' id='switch-btn' value='switch'/></noscript>\n");
530 // html("</td></tr></table>"); 532 // html("</td></tr></table>");
531 html("</form>\n"); 533 html("</form>\n");
532 534
533 html("<h1>search</h1>\n"); 535 html("<h1>search</h1>\n");
534 html("<form method='get' action='"); 536 html("<form method='get' action='");
535 if (ctx.cfg.virtual_root) 537 if (ctx->cfg.virtual_root)
536 html_attr(cgit_fileurl(ctx.qry.repo, "log", 538 html_attr(cgit_fileurl(ctx->qry.repo, "log",
537 ctx.qry.path, NULL)); 539 ctx->qry.path, NULL));
538 html("'>\n"); 540 html("'>\n");
539 add_hidden_formfields(1, 0, "log"); 541 add_hidden_formfields(1, 0, "log");
540 html("<select name='qt'>\n"); 542 html("<select name='qt'>\n");
541 html_option("grep", "log msg", ctx.qry.grep); 543 html_option("grep", "log msg", ctx->qry.grep);
542 html_option("author", "author", ctx.qry.grep); 544 html_option("author", "author", ctx->qry.grep);
543 html_option("committer", "committer", ctx.qry.grep); 545 html_option("committer", "committer", ctx->qry.grep);
544 html("</select>\n"); 546 html("</select>\n");
545 html("<input class='txt' type='text' name='q' value='"); 547 html("<input class='txt' type='text' name='q' value='");
546 html_attr(ctx.qry.search); 548 html_attr(ctx->qry.search);
547 html("'/>\n"); 549 html("'/>\n");
548 html("</form>\n"); 550 html("</form>\n");
549 } else { 551 } else {
550 if (!ctx.cfg.index_info || html_include(ctx.cfg.index_info)) 552 if (!ctx->cfg.index_info || html_include(ctx->cfg.index_info))
551 html(default_info); 553 html(default_info);
552 } 554 }
553 555
554 html("</td></tr></table></td>\n"); 556 html("</td></tr></table></td>\n");
555 557
556 html("<td id='content'>\n"); 558 html("<td id='content'>\n");
557} 559}
558 560
559
560void cgit_print_snapshot_start(const char *mimetype, const char *filename,
561 struct cacheitem *item)
562{
563 htmlf("Content-Type: %s\n", mimetype);
564 htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename);
565 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime));
566 htmlf("Expires: %s\n", http_date(item->st.st_mtime +
567 ttl_seconds(item->ttl)));
568 html("\n");
569}
570
571void cgit_print_filemode(unsigned short mode) 561void cgit_print_filemode(unsigned short mode)
572{ 562{
573 if (S_ISDIR(mode)) 563 if (S_ISDIR(mode))
574 html("d"); 564 html("d");
575 else if (S_ISLNK(mode)) 565 else if (S_ISLNK(mode))
576 html("l"); 566 html("l");
577 else if (S_ISGITLINK(mode)) 567 else if (S_ISGITLINK(mode))
578 html("m"); 568 html("m");
579 else 569 else
580 html("-"); 570 html("-");
581 html_fileperm(mode >> 6); 571 html_fileperm(mode >> 6);
582 html_fileperm(mode >> 3); 572 html_fileperm(mode >> 3);
583 html_fileperm(mode); 573 html_fileperm(mode);
584} 574}
585 575
586/* vim:set sw=8: */ 576/* vim:set sw=8: */