summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
Unidiff
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 749ea35..5ce2bc5 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -458,97 +458,98 @@ void cgit_print_age(time_t t, time_t max_relative, char *format)
458 } 458 }
459 if (secs < TM_YEAR * 2) { 459 if (secs < TM_YEAR * 2) {
460 htmlf("<span class='age-months'>%.0f months</span>", 460 htmlf("<span class='age-months'>%.0f months</span>",
461 secs * 1.0 / TM_MONTH); 461 secs * 1.0 / TM_MONTH);
462 return; 462 return;
463 } 463 }
464 htmlf("<span class='age-years'>%.0f years</span>", 464 htmlf("<span class='age-years'>%.0f years</span>",
465 secs * 1.0 / TM_YEAR); 465 secs * 1.0 / TM_YEAR);
466} 466}
467 467
468void cgit_print_http_headers(struct cgit_context *ctx) 468void cgit_print_http_headers(struct cgit_context *ctx)
469{ 469{
470 if (ctx->page.mimetype && ctx->page.charset) 470 if (ctx->page.mimetype && ctx->page.charset)
471 htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, 471 htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype,
472 ctx->page.charset); 472 ctx->page.charset);
473 else if (ctx->page.mimetype) 473 else if (ctx->page.mimetype)
474 htmlf("Content-Type: %s\n", ctx->page.mimetype); 474 htmlf("Content-Type: %s\n", ctx->page.mimetype);
475 if (ctx->page.size) 475 if (ctx->page.size)
476 htmlf("Content-Length: %ld\n", ctx->page.size); 476 htmlf("Content-Length: %ld\n", ctx->page.size);
477 if (ctx->page.filename) 477 if (ctx->page.filename)
478 htmlf("Content-Disposition: inline; filename=\"%s\"\n", 478 htmlf("Content-Disposition: inline; filename=\"%s\"\n",
479 ctx->page.filename); 479 ctx->page.filename);
480 htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); 480 htmlf("Last-Modified: %s\n", http_date(ctx->page.modified));
481 htmlf("Expires: %s\n", http_date(ctx->page.expires)); 481 htmlf("Expires: %s\n", http_date(ctx->page.expires));
482 html("\n"); 482 html("\n");
483} 483}
484 484
485void cgit_print_docstart(struct cgit_context *ctx) 485void cgit_print_docstart(struct cgit_context *ctx)
486{ 486{
487 char *host = cgit_hosturl(); 487 char *host = cgit_hosturl();
488 html(cgit_doctype); 488 html(cgit_doctype);
489 html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); 489 html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n");
490 html("<head>\n"); 490 html("<head>\n");
491 html("<title>"); 491 html("<title>");
492 html_txt(ctx->page.title); 492 html_txt(ctx->page.title);
493 html("</title>\n"); 493 html("</title>\n");
494 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); 494 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
495 if (ctx->cfg.robots && *ctx->cfg.robots) 495 if (ctx->cfg.robots && *ctx->cfg.robots)
496 htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); 496 htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots);
497 html("<link rel='stylesheet' type='text/css' href='"); 497 html("<link rel='stylesheet' type='text/css' href='");
498 html_attr(ctx->cfg.css); 498 html_attr(ctx->cfg.css);
499 html("'/>\n"); 499 html("'/>\n");
500 if (ctx->cfg.favicon) { 500 if (ctx->cfg.favicon) {
501 html("<link rel='shortcut icon' href='"); 501 html("<link rel='shortcut icon' href='");
502 html_attr(ctx->cfg.favicon); 502 html_attr(ctx->cfg.favicon);
503 html("'/>\n"); 503 html("'/>\n");
504 } 504 }
505 if (host && ctx->repo) { 505 if (host && ctx->repo) {
506 html("<link rel='alternate' title='Atom feed' href='http://"); 506 html("<link rel='alternate' title='Atom feed' href='");
507 html(cgit_httpscheme());
507 html_attr(cgit_hosturl()); 508 html_attr(cgit_hosturl());
508 html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, 509 html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path,
509 fmt("h=%s", ctx->qry.head))); 510 fmt("h=%s", ctx->qry.head)));
510 html("' type='application/atom+xml'/>"); 511 html("' type='application/atom+xml'/>");
511 } 512 }
512 html("</head>\n"); 513 html("</head>\n");
513 html("<body>\n"); 514 html("<body>\n");
514 if (ctx->cfg.header) 515 if (ctx->cfg.header)
515 html_include(ctx->cfg.header); 516 html_include(ctx->cfg.header);
516} 517}
517 518
518void cgit_print_docend() 519void cgit_print_docend()
519{ 520{
520 html("</div>"); 521 html("</div>");
521 if (ctx.cfg.footer) 522 if (ctx.cfg.footer)
522 html_include(ctx.cfg.footer); 523 html_include(ctx.cfg.footer);
523 else { 524 else {
524 htmlf("<div class='footer'>generated by cgit %s at ", 525 htmlf("<div class='footer'>generated by cgit %s at ",
525 cgit_version); 526 cgit_version);
526 cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time); 527 cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time);
527 html("</div>\n"); 528 html("</div>\n");
528 } 529 }
529 html("</body>\n</html>\n"); 530 html("</body>\n</html>\n");
530} 531}
531 532
532int print_branch_option(const char *refname, const unsigned char *sha1, 533int print_branch_option(const char *refname, const unsigned char *sha1,
533 int flags, void *cb_data) 534 int flags, void *cb_data)
534{ 535{
535 char *name = (char *)refname; 536 char *name = (char *)refname;
536 html_option(name, name, ctx.qry.head); 537 html_option(name, name, ctx.qry.head);
537 return 0; 538 return 0;
538} 539}
539 540
540int print_archive_ref(const char *refname, const unsigned char *sha1, 541int print_archive_ref(const char *refname, const unsigned char *sha1,
541 int flags, void *cb_data) 542 int flags, void *cb_data)
542{ 543{
543 struct tag *tag; 544 struct tag *tag;
544 struct taginfo *info; 545 struct taginfo *info;
545 struct object *obj; 546 struct object *obj;
546 char buf[256], *url; 547 char buf[256], *url;
547 unsigned char fileid[20]; 548 unsigned char fileid[20];
548 int *header = (int *)cb_data; 549 int *header = (int *)cb_data;
549 550
550 if (prefixcmp(refname, "refs/archives")) 551 if (prefixcmp(refname, "refs/archives"))
551 return 0; 552 return 0;
552 strncpy(buf, refname+14, sizeof(buf)); 553 strncpy(buf, refname+14, sizeof(buf));
553 obj = parse_object(sha1); 554 obj = parse_object(sha1);
554 if (!obj) 555 if (!obj)