author | Lars Hjemli <hjemli@gmail.com> | 2011-03-05 13:01:59 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2011-03-05 13:01:59 (UTC) |
commit | 1b09cbd303d889ec2636127584d57b7f1b70c25e (patch) (unidiff) | |
tree | 2b1188f946451d06af4d9120cbc3ba34de716f21 /ui-shared.c | |
parent | 979c460e7f71d153ae79da67b8b21c3412f0fe02 (diff) | |
parent | 9e849950dc7c1f2fb6ffa62ab65bd30f35717d13 (diff) | |
download | cgit-1b09cbd303d889ec2636127584d57b7f1b70c25e.zip cgit-1b09cbd303d889ec2636127584d57b7f1b70c25e.tar.gz cgit-1b09cbd303d889ec2636127584d57b7f1b70c25e.tar.bz2 |
Merge branch 'stable'
-rw-r--r-- | ui-shared.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ui-shared.c b/ui-shared.c index 7efae7a..5aa9119 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -513,129 +513,129 @@ void cgit_print_date(time_t secs, const char *format, int local_time) | |||
513 | if(local_time) | 513 | if(local_time) |
514 | time = localtime(&secs); | 514 | time = localtime(&secs); |
515 | else | 515 | else |
516 | time = gmtime(&secs); | 516 | time = gmtime(&secs); |
517 | strftime(buf, sizeof(buf)-1, format, time); | 517 | strftime(buf, sizeof(buf)-1, format, time); |
518 | html_txt(buf); | 518 | html_txt(buf); |
519 | } | 519 | } |
520 | 520 | ||
521 | void cgit_print_age(time_t t, time_t max_relative, const char *format) | 521 | void cgit_print_age(time_t t, time_t max_relative, const char *format) |
522 | { | 522 | { |
523 | time_t now, secs; | 523 | time_t now, secs; |
524 | 524 | ||
525 | if (!t) | 525 | if (!t) |
526 | return; | 526 | return; |
527 | time(&now); | 527 | time(&now); |
528 | secs = now - t; | 528 | secs = now - t; |
529 | 529 | ||
530 | if (secs > max_relative && max_relative >= 0) { | 530 | if (secs > max_relative && max_relative >= 0) { |
531 | cgit_print_date(t, format, ctx.cfg.local_time); | 531 | cgit_print_date(t, format, ctx.cfg.local_time); |
532 | return; | 532 | return; |
533 | } | 533 | } |
534 | 534 | ||
535 | if (secs < TM_HOUR * 2) { | 535 | if (secs < TM_HOUR * 2) { |
536 | htmlf("<span class='age-mins'>%.0f min.</span>", | 536 | htmlf("<span class='age-mins'>%.0f min.</span>", |
537 | secs * 1.0 / TM_MIN); | 537 | secs * 1.0 / TM_MIN); |
538 | return; | 538 | return; |
539 | } | 539 | } |
540 | if (secs < TM_DAY * 2) { | 540 | if (secs < TM_DAY * 2) { |
541 | htmlf("<span class='age-hours'>%.0f hours</span>", | 541 | htmlf("<span class='age-hours'>%.0f hours</span>", |
542 | secs * 1.0 / TM_HOUR); | 542 | secs * 1.0 / TM_HOUR); |
543 | return; | 543 | return; |
544 | } | 544 | } |
545 | if (secs < TM_WEEK * 2) { | 545 | if (secs < TM_WEEK * 2) { |
546 | htmlf("<span class='age-days'>%.0f days</span>", | 546 | htmlf("<span class='age-days'>%.0f days</span>", |
547 | secs * 1.0 / TM_DAY); | 547 | secs * 1.0 / TM_DAY); |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | if (secs < TM_MONTH * 2) { | 550 | if (secs < TM_MONTH * 2) { |
551 | htmlf("<span class='age-weeks'>%.0f weeks</span>", | 551 | htmlf("<span class='age-weeks'>%.0f weeks</span>", |
552 | secs * 1.0 / TM_WEEK); | 552 | secs * 1.0 / TM_WEEK); |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | if (secs < TM_YEAR * 2) { | 555 | if (secs < TM_YEAR * 2) { |
556 | htmlf("<span class='age-months'>%.0f months</span>", | 556 | htmlf("<span class='age-months'>%.0f months</span>", |
557 | secs * 1.0 / TM_MONTH); | 557 | secs * 1.0 / TM_MONTH); |
558 | return; | 558 | return; |
559 | } | 559 | } |
560 | htmlf("<span class='age-years'>%.0f years</span>", | 560 | htmlf("<span class='age-years'>%.0f years</span>", |
561 | secs * 1.0 / TM_YEAR); | 561 | secs * 1.0 / TM_YEAR); |
562 | } | 562 | } |
563 | 563 | ||
564 | void cgit_print_http_headers(struct cgit_context *ctx) | 564 | void cgit_print_http_headers(struct cgit_context *ctx) |
565 | { | 565 | { |
566 | if (ctx->env.no_http && !strcmp(ctx->env.no_http, "1")) | 566 | if (ctx->env.no_http && !strcmp(ctx->env.no_http, "1")) |
567 | return; | 567 | return; |
568 | 568 | ||
569 | if (ctx->page.status) | 569 | if (ctx->page.status) |
570 | htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg); | 570 | htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg); |
571 | if (ctx->page.mimetype && ctx->page.charset) | 571 | if (ctx->page.mimetype && ctx->page.charset) |
572 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, | 572 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, |
573 | ctx->page.charset); | 573 | ctx->page.charset); |
574 | else if (ctx->page.mimetype) | 574 | else if (ctx->page.mimetype) |
575 | htmlf("Content-Type: %s\n", ctx->page.mimetype); | 575 | htmlf("Content-Type: %s\n", ctx->page.mimetype); |
576 | if (ctx->page.size) | 576 | if (ctx->page.size) |
577 | htmlf("Content-Length: %ld\n", ctx->page.size); | 577 | htmlf("Content-Length: %zd\n", ctx->page.size); |
578 | if (ctx->page.filename) | 578 | if (ctx->page.filename) |
579 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", | 579 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", |
580 | ctx->page.filename); | 580 | ctx->page.filename); |
581 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); | 581 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); |
582 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); | 582 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); |
583 | if (ctx->page.etag) | 583 | if (ctx->page.etag) |
584 | htmlf("ETag: \"%s\"\n", ctx->page.etag); | 584 | htmlf("ETag: \"%s\"\n", ctx->page.etag); |
585 | html("\n"); | 585 | html("\n"); |
586 | if (ctx->env.request_method && !strcmp(ctx->env.request_method, "HEAD")) | 586 | if (ctx->env.request_method && !strcmp(ctx->env.request_method, "HEAD")) |
587 | exit(0); | 587 | exit(0); |
588 | } | 588 | } |
589 | 589 | ||
590 | void cgit_print_docstart(struct cgit_context *ctx) | 590 | void cgit_print_docstart(struct cgit_context *ctx) |
591 | { | 591 | { |
592 | if (ctx->cfg.embedded) { | 592 | if (ctx->cfg.embedded) { |
593 | if (ctx->cfg.header) | 593 | if (ctx->cfg.header) |
594 | html_include(ctx->cfg.header); | 594 | html_include(ctx->cfg.header); |
595 | return; | 595 | return; |
596 | } | 596 | } |
597 | 597 | ||
598 | char *host = cgit_hosturl(); | 598 | char *host = cgit_hosturl(); |
599 | html(cgit_doctype); | 599 | html(cgit_doctype); |
600 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); | 600 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); |
601 | html("<head>\n"); | 601 | html("<head>\n"); |
602 | html("<title>"); | 602 | html("<title>"); |
603 | html_txt(ctx->page.title); | 603 | html_txt(ctx->page.title); |
604 | html("</title>\n"); | 604 | html("</title>\n"); |
605 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 605 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
606 | if (ctx->cfg.robots && *ctx->cfg.robots) | 606 | if (ctx->cfg.robots && *ctx->cfg.robots) |
607 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); | 607 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); |
608 | html("<link rel='stylesheet' type='text/css' href='"); | 608 | html("<link rel='stylesheet' type='text/css' href='"); |
609 | html_attr(ctx->cfg.css); | 609 | html_attr(ctx->cfg.css); |
610 | html("'/>\n"); | 610 | html("'/>\n"); |
611 | if (ctx->cfg.favicon) { | 611 | if (ctx->cfg.favicon) { |
612 | html("<link rel='shortcut icon' href='"); | 612 | html("<link rel='shortcut icon' href='"); |
613 | html_attr(ctx->cfg.favicon); | 613 | html_attr(ctx->cfg.favicon); |
614 | html("'/>\n"); | 614 | html("'/>\n"); |
615 | } | 615 | } |
616 | if (host && ctx->repo) { | 616 | if (host && ctx->repo) { |
617 | html("<link rel='alternate' title='Atom feed' href='"); | 617 | html("<link rel='alternate' title='Atom feed' href='"); |
618 | html(cgit_httpscheme()); | 618 | html(cgit_httpscheme()); |
619 | html_attr(cgit_hosturl()); | 619 | html_attr(cgit_hosturl()); |
620 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.vpath, | 620 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.vpath, |
621 | fmt("h=%s", ctx->qry.head))); | 621 | fmt("h=%s", ctx->qry.head))); |
622 | html("' type='application/atom+xml'/>\n"); | 622 | html("' type='application/atom+xml'/>\n"); |
623 | } | 623 | } |
624 | if (ctx->cfg.head_include) | 624 | if (ctx->cfg.head_include) |
625 | html_include(ctx->cfg.head_include); | 625 | html_include(ctx->cfg.head_include); |
626 | html("</head>\n"); | 626 | html("</head>\n"); |
627 | html("<body>\n"); | 627 | html("<body>\n"); |
628 | if (ctx->cfg.header) | 628 | if (ctx->cfg.header) |
629 | html_include(ctx->cfg.header); | 629 | html_include(ctx->cfg.header); |
630 | } | 630 | } |
631 | 631 | ||
632 | void cgit_print_docend() | 632 | void cgit_print_docend() |
633 | { | 633 | { |
634 | html("</div> <!-- class=content -->\n"); | 634 | html("</div> <!-- class=content -->\n"); |
635 | if (ctx.cfg.embedded) { | 635 | if (ctx.cfg.embedded) { |
636 | html("</div> <!-- id=cgit -->\n"); | 636 | html("</div> <!-- id=cgit -->\n"); |
637 | if (ctx.cfg.footer) | 637 | if (ctx.cfg.footer) |
638 | html_include(ctx.cfg.footer); | 638 | html_include(ctx.cfg.footer); |
639 | return; | 639 | return; |
640 | } | 640 | } |
641 | if (ctx.cfg.footer) | 641 | if (ctx.cfg.footer) |