author | Lars Hjemli <hjemli@gmail.com> | 2008-10-05 17:09:58 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-10-05 17:09:58 (UTC) |
commit | b9aabf0b8fbf3a3ab69010ee2c9ed5426c751912 (patch) (unidiff) | |
tree | 7a75f470154e12f365189600ac08d9df2d15547d /ui-shared.c | |
parent | 23ffba78b4572f35f0ee52410dde9a16e6d02ce5 (diff) | |
download | cgit-b9aabf0b8fbf3a3ab69010ee2c9ed5426c751912.zip cgit-b9aabf0b8fbf3a3ab69010ee2c9ed5426c751912.tar.gz cgit-b9aabf0b8fbf3a3ab69010ee2c9ed5426c751912.tar.bz2 |
ui-shared: reword the standard page footer
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-shared.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ui-shared.c b/ui-shared.c index d909f55..f858ab6 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -403,195 +403,195 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
403 | { | 403 | { |
404 | time_t now, secs; | 404 | time_t now, secs; |
405 | 405 | ||
406 | if (!t) | 406 | if (!t) |
407 | return; | 407 | return; |
408 | time(&now); | 408 | time(&now); |
409 | secs = now - t; | 409 | secs = now - t; |
410 | 410 | ||
411 | if (secs > max_relative && max_relative >= 0) { | 411 | if (secs > max_relative && max_relative >= 0) { |
412 | cgit_print_date(t, format, ctx.cfg.local_time); | 412 | cgit_print_date(t, format, ctx.cfg.local_time); |
413 | return; | 413 | return; |
414 | } | 414 | } |
415 | 415 | ||
416 | if (secs < TM_HOUR * 2) { | 416 | if (secs < TM_HOUR * 2) { |
417 | htmlf("<span class='age-mins'>%.0f min.</span>", | 417 | htmlf("<span class='age-mins'>%.0f min.</span>", |
418 | secs * 1.0 / TM_MIN); | 418 | secs * 1.0 / TM_MIN); |
419 | return; | 419 | return; |
420 | } | 420 | } |
421 | if (secs < TM_DAY * 2) { | 421 | if (secs < TM_DAY * 2) { |
422 | htmlf("<span class='age-hours'>%.0f hours</span>", | 422 | htmlf("<span class='age-hours'>%.0f hours</span>", |
423 | secs * 1.0 / TM_HOUR); | 423 | secs * 1.0 / TM_HOUR); |
424 | return; | 424 | return; |
425 | } | 425 | } |
426 | if (secs < TM_WEEK * 2) { | 426 | if (secs < TM_WEEK * 2) { |
427 | htmlf("<span class='age-days'>%.0f days</span>", | 427 | htmlf("<span class='age-days'>%.0f days</span>", |
428 | secs * 1.0 / TM_DAY); | 428 | secs * 1.0 / TM_DAY); |
429 | return; | 429 | return; |
430 | } | 430 | } |
431 | if (secs < TM_MONTH * 2) { | 431 | if (secs < TM_MONTH * 2) { |
432 | htmlf("<span class='age-weeks'>%.0f weeks</span>", | 432 | htmlf("<span class='age-weeks'>%.0f weeks</span>", |
433 | secs * 1.0 / TM_WEEK); | 433 | secs * 1.0 / TM_WEEK); |
434 | return; | 434 | return; |
435 | } | 435 | } |
436 | if (secs < TM_YEAR * 2) { | 436 | if (secs < TM_YEAR * 2) { |
437 | htmlf("<span class='age-months'>%.0f months</span>", | 437 | htmlf("<span class='age-months'>%.0f months</span>", |
438 | secs * 1.0 / TM_MONTH); | 438 | secs * 1.0 / TM_MONTH); |
439 | return; | 439 | return; |
440 | } | 440 | } |
441 | htmlf("<span class='age-years'>%.0f years</span>", | 441 | htmlf("<span class='age-years'>%.0f years</span>", |
442 | secs * 1.0 / TM_YEAR); | 442 | secs * 1.0 / TM_YEAR); |
443 | } | 443 | } |
444 | 444 | ||
445 | void cgit_print_http_headers(struct cgit_context *ctx) | 445 | void cgit_print_http_headers(struct cgit_context *ctx) |
446 | { | 446 | { |
447 | if (ctx->page.mimetype && ctx->page.charset) | 447 | if (ctx->page.mimetype && ctx->page.charset) |
448 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, | 448 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, |
449 | ctx->page.charset); | 449 | ctx->page.charset); |
450 | else if (ctx->page.mimetype) | 450 | else if (ctx->page.mimetype) |
451 | htmlf("Content-Type: %s\n", ctx->page.mimetype); | 451 | htmlf("Content-Type: %s\n", ctx->page.mimetype); |
452 | if (ctx->page.size) | 452 | if (ctx->page.size) |
453 | htmlf("Content-Length: %ld\n", ctx->page.size); | 453 | htmlf("Content-Length: %ld\n", ctx->page.size); |
454 | if (ctx->page.filename) | 454 | if (ctx->page.filename) |
455 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", | 455 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", |
456 | ctx->page.filename); | 456 | ctx->page.filename); |
457 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); | 457 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); |
458 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); | 458 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); |
459 | html("\n"); | 459 | html("\n"); |
460 | } | 460 | } |
461 | 461 | ||
462 | void cgit_print_docstart(struct cgit_context *ctx) | 462 | void cgit_print_docstart(struct cgit_context *ctx) |
463 | { | 463 | { |
464 | char *host = cgit_hosturl(); | 464 | char *host = cgit_hosturl(); |
465 | html(cgit_doctype); | 465 | html(cgit_doctype); |
466 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); | 466 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); |
467 | html("<head>\n"); | 467 | html("<head>\n"); |
468 | html("<title>"); | 468 | html("<title>"); |
469 | html_txt(ctx->page.title); | 469 | html_txt(ctx->page.title); |
470 | html("</title>\n"); | 470 | html("</title>\n"); |
471 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 471 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
472 | if (ctx->cfg.robots && *ctx->cfg.robots) | 472 | if (ctx->cfg.robots && *ctx->cfg.robots) |
473 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); | 473 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); |
474 | html("<link rel='stylesheet' type='text/css' href='"); | 474 | html("<link rel='stylesheet' type='text/css' href='"); |
475 | html_attr(ctx->cfg.css); | 475 | html_attr(ctx->cfg.css); |
476 | html("'/>\n"); | 476 | html("'/>\n"); |
477 | if (ctx->cfg.favicon) { | 477 | if (ctx->cfg.favicon) { |
478 | html("<link rel='shortcut icon' href='"); | 478 | html("<link rel='shortcut icon' href='"); |
479 | html_attr(ctx->cfg.favicon); | 479 | html_attr(ctx->cfg.favicon); |
480 | html("'/>\n"); | 480 | html("'/>\n"); |
481 | } | 481 | } |
482 | if (host && ctx->repo) { | 482 | if (host && ctx->repo) { |
483 | html("<link rel='alternate' title='Atom feed' href='http://"); | 483 | html("<link rel='alternate' title='Atom feed' href='http://"); |
484 | html_attr(cgit_hosturl()); | 484 | html_attr(cgit_hosturl()); |
485 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, | 485 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, |
486 | fmt("h=%s", ctx->qry.head))); | 486 | fmt("h=%s", ctx->qry.head))); |
487 | html("' type='application/atom+xml'/>"); | 487 | html("' type='application/atom+xml'/>"); |
488 | } | 488 | } |
489 | html("</head>\n"); | 489 | html("</head>\n"); |
490 | html("<body>\n"); | 490 | html("<body>\n"); |
491 | } | 491 | } |
492 | 492 | ||
493 | void cgit_print_docend() | 493 | void cgit_print_docend() |
494 | { | 494 | { |
495 | html("</div>"); | 495 | html("</div>"); |
496 | if (ctx.cfg.footer) | 496 | if (ctx.cfg.footer) |
497 | html_include(ctx.cfg.footer); | 497 | html_include(ctx.cfg.footer); |
498 | else { | 498 | else { |
499 | html("<div class='footer'>generated "); | 499 | htmlf("<div class='footer'>generated by cgit %s at ", |
500 | cgit_version); | ||
500 | cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time); | 501 | cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time); |
501 | htmlf(" by cgit %s", cgit_version); | ||
502 | html("</div>\n"); | 502 | html("</div>\n"); |
503 | } | 503 | } |
504 | html("</body>\n</html>\n"); | 504 | html("</body>\n</html>\n"); |
505 | } | 505 | } |
506 | 506 | ||
507 | int print_branch_option(const char *refname, const unsigned char *sha1, | 507 | int print_branch_option(const char *refname, const unsigned char *sha1, |
508 | int flags, void *cb_data) | 508 | int flags, void *cb_data) |
509 | { | 509 | { |
510 | char *name = (char *)refname; | 510 | char *name = (char *)refname; |
511 | html_option(name, name, ctx.qry.head); | 511 | html_option(name, name, ctx.qry.head); |
512 | return 0; | 512 | return 0; |
513 | } | 513 | } |
514 | 514 | ||
515 | int print_archive_ref(const char *refname, const unsigned char *sha1, | 515 | int print_archive_ref(const char *refname, const unsigned char *sha1, |
516 | int flags, void *cb_data) | 516 | int flags, void *cb_data) |
517 | { | 517 | { |
518 | struct tag *tag; | 518 | struct tag *tag; |
519 | struct taginfo *info; | 519 | struct taginfo *info; |
520 | struct object *obj; | 520 | struct object *obj; |
521 | char buf[256], *url; | 521 | char buf[256], *url; |
522 | unsigned char fileid[20]; | 522 | unsigned char fileid[20]; |
523 | int *header = (int *)cb_data; | 523 | int *header = (int *)cb_data; |
524 | 524 | ||
525 | if (prefixcmp(refname, "refs/archives")) | 525 | if (prefixcmp(refname, "refs/archives")) |
526 | return 0; | 526 | return 0; |
527 | strncpy(buf, refname+14, sizeof(buf)); | 527 | strncpy(buf, refname+14, sizeof(buf)); |
528 | obj = parse_object(sha1); | 528 | obj = parse_object(sha1); |
529 | if (!obj) | 529 | if (!obj) |
530 | return 1; | 530 | return 1; |
531 | if (obj->type == OBJ_TAG) { | 531 | if (obj->type == OBJ_TAG) { |
532 | tag = lookup_tag(sha1); | 532 | tag = lookup_tag(sha1); |
533 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 533 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
534 | return 0; | 534 | return 0; |
535 | hashcpy(fileid, tag->tagged->sha1); | 535 | hashcpy(fileid, tag->tagged->sha1); |
536 | } else if (obj->type != OBJ_BLOB) { | 536 | } else if (obj->type != OBJ_BLOB) { |
537 | return 0; | 537 | return 0; |
538 | } else { | 538 | } else { |
539 | hashcpy(fileid, sha1); | 539 | hashcpy(fileid, sha1); |
540 | } | 540 | } |
541 | if (!*header) { | 541 | if (!*header) { |
542 | html("<h1>download</h1>\n"); | 542 | html("<h1>download</h1>\n"); |
543 | *header = 1; | 543 | *header = 1; |
544 | } | 544 | } |
545 | url = cgit_pageurl(ctx.qry.repo, "blob", | 545 | url = cgit_pageurl(ctx.qry.repo, "blob", |
546 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | 546 | fmt("id=%s&path=%s", sha1_to_hex(fileid), |
547 | buf)); | 547 | buf)); |
548 | html_link_open(url, NULL, "menu"); | 548 | html_link_open(url, NULL, "menu"); |
549 | html_txt(strlpart(buf, 20)); | 549 | html_txt(strlpart(buf, 20)); |
550 | html_link_close(); | 550 | html_link_close(); |
551 | return 0; | 551 | return 0; |
552 | } | 552 | } |
553 | 553 | ||
554 | void add_hidden_formfields(int incl_head, int incl_search, char *page) | 554 | void add_hidden_formfields(int incl_head, int incl_search, char *page) |
555 | { | 555 | { |
556 | char *url; | 556 | char *url; |
557 | 557 | ||
558 | if (!ctx.cfg.virtual_root) { | 558 | if (!ctx.cfg.virtual_root) { |
559 | url = fmt("%s/%s", ctx.qry.repo, page); | 559 | url = fmt("%s/%s", ctx.qry.repo, page); |
560 | if (ctx.qry.path) | 560 | if (ctx.qry.path) |
561 | url = fmt("%s/%s", url, ctx.qry.path); | 561 | url = fmt("%s/%s", url, ctx.qry.path); |
562 | html_hidden("url", url); | 562 | html_hidden("url", url); |
563 | } | 563 | } |
564 | 564 | ||
565 | if (incl_head && ctx.qry.head && ctx.repo->defbranch && | 565 | if (incl_head && ctx.qry.head && ctx.repo->defbranch && |
566 | strcmp(ctx.qry.head, ctx.repo->defbranch)) | 566 | strcmp(ctx.qry.head, ctx.repo->defbranch)) |
567 | html_hidden("h", ctx.qry.head); | 567 | html_hidden("h", ctx.qry.head); |
568 | 568 | ||
569 | if (ctx.qry.sha1) | 569 | if (ctx.qry.sha1) |
570 | html_hidden("id", ctx.qry.sha1); | 570 | html_hidden("id", ctx.qry.sha1); |
571 | if (ctx.qry.sha2) | 571 | if (ctx.qry.sha2) |
572 | html_hidden("id2", ctx.qry.sha2); | 572 | html_hidden("id2", ctx.qry.sha2); |
573 | 573 | ||
574 | if (incl_search) { | 574 | if (incl_search) { |
575 | if (ctx.qry.grep) | 575 | if (ctx.qry.grep) |
576 | html_hidden("qt", ctx.qry.grep); | 576 | html_hidden("qt", ctx.qry.grep); |
577 | if (ctx.qry.search) | 577 | if (ctx.qry.search) |
578 | html_hidden("q", ctx.qry.search); | 578 | html_hidden("q", ctx.qry.search); |
579 | } | 579 | } |
580 | } | 580 | } |
581 | 581 | ||
582 | char *hc(struct cgit_cmd *cmd, const char *page) | 582 | char *hc(struct cgit_cmd *cmd, const char *page) |
583 | { | 583 | { |
584 | return (strcmp(cmd->name, page) ? NULL : "active"); | 584 | return (strcmp(cmd->name, page) ? NULL : "active"); |
585 | } | 585 | } |
586 | 586 | ||
587 | void cgit_print_pageheader(struct cgit_context *ctx) | 587 | void cgit_print_pageheader(struct cgit_context *ctx) |
588 | { | 588 | { |
589 | struct cgit_cmd *cmd = cgit_get_cmd(ctx); | 589 | struct cgit_cmd *cmd = cgit_get_cmd(ctx); |
590 | 590 | ||
591 | html("<table id='header'>\n"); | 591 | html("<table id='header'>\n"); |
592 | html("<tr>\n"); | 592 | html("<tr>\n"); |
593 | html("<td class='logo' rowspan='2'><a href='"); | 593 | html("<td class='logo' rowspan='2'><a href='"); |
594 | if (ctx->cfg.logo_link) | 594 | if (ctx->cfg.logo_link) |
595 | html_attr(ctx->cfg.logo_link); | 595 | html_attr(ctx->cfg.logo_link); |
596 | else | 596 | else |
597 | html_attr(cgit_rooturl()); | 597 | html_attr(cgit_rooturl()); |