summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/ui-shared.c b/ui-shared.c
index bb08c4a..8a804c2 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -439,138 +439,125 @@ int print_archive_ref(const char *refname, const unsigned char *sha1,
439 return 0; 439 return 0;
440} 440}
441 441
442void add_hidden_formfields(int incl_head, int incl_search, char *page) 442void add_hidden_formfields(int incl_head, int incl_search, char *page)
443{ 443{
444 char *url; 444 char *url;
445 445
446 if (!ctx.cfg.virtual_root) { 446 if (!ctx.cfg.virtual_root) {
447 url = fmt("%s/%s", ctx.qry.repo, page); 447 url = fmt("%s/%s", ctx.qry.repo, page);
448 if (ctx.qry.path) 448 if (ctx.qry.path)
449 url = fmt("%s/%s", url, ctx.qry.path); 449 url = fmt("%s/%s", url, ctx.qry.path);
450 html_hidden("url", url); 450 html_hidden("url", url);
451 } 451 }
452 452
453 if (incl_head && strcmp(ctx.qry.head, ctx.repo->defbranch)) 453 if (incl_head && strcmp(ctx.qry.head, ctx.repo->defbranch))
454 html_hidden("h", ctx.qry.head); 454 html_hidden("h", ctx.qry.head);
455 455
456 if (ctx.qry.sha1) 456 if (ctx.qry.sha1)
457 html_hidden("id", ctx.qry.sha1); 457 html_hidden("id", ctx.qry.sha1);
458 if (ctx.qry.sha2) 458 if (ctx.qry.sha2)
459 html_hidden("id2", ctx.qry.sha2); 459 html_hidden("id2", ctx.qry.sha2);
460 460
461 if (incl_search) { 461 if (incl_search) {
462 if (ctx.qry.grep) 462 if (ctx.qry.grep)
463 html_hidden("qt", ctx.qry.grep); 463 html_hidden("qt", ctx.qry.grep);
464 if (ctx.qry.search) 464 if (ctx.qry.search)
465 html_hidden("q", ctx.qry.search); 465 html_hidden("q", ctx.qry.search);
466 } 466 }
467} 467}
468 468
469char *hc(struct cgit_cmd *cmd, const char *page) 469char *hc(struct cgit_cmd *cmd, const char *page)
470{ 470{
471 return (strcmp(cmd->name, page) ? NULL : "active"); 471 return (strcmp(cmd->name, page) ? NULL : "active");
472} 472}
473 473
474void cgit_print_pageheader(struct cgit_context *ctx) 474void cgit_print_pageheader(struct cgit_context *ctx)
475{ 475{
476 struct cgit_cmd *cmd = cgit_get_cmd(ctx); 476 struct cgit_cmd *cmd = cgit_get_cmd(ctx);
477 477
478 html("<table id='header'>\n"); 478 html("<table id='header'>\n");
479 html("<tr>\n"); 479 html("<tr>\n");
480 html("<td class='logo' rowspan='2'><a href='"); 480 html("<td class='logo' rowspan='2'><a href='");
481 if (ctx->cfg.logo_link) 481 if (ctx->cfg.logo_link)
482 html_attr(ctx->cfg.logo_link); 482 html_attr(ctx->cfg.logo_link);
483 else 483 else
484 html_attr(cgit_rooturl()); 484 html_attr(cgit_rooturl());
485 html("'><img src='"); 485 html("'><img src='");
486 html_attr(ctx->cfg.logo); 486 html_attr(ctx->cfg.logo);
487 html("'/></a></td>\n"); 487 html("' alt='cgit logo'/></a></td>\n");
488 488
489 html("<td class='main'>"); 489 html("<td class='main'>");
490 if (ctx->repo) { 490 if (ctx->repo) {
491/*
492 html("<a href='");
493 html_attr(cgit_rooturl());
494 html("'>index</a> : ");
495*/
496 reporevlink(NULL, ctx->repo->name, NULL, hc(cmd, "summary"), 491 reporevlink(NULL, ctx->repo->name, NULL, hc(cmd, "summary"),
497 ctx->qry.head, NULL, NULL); 492 ctx->qry.head, NULL, NULL);
498 html(" : "); 493 html(" : ");
499 html_txt(ctx->qry.page); 494 html_txt(ctx->qry.page);
500 html("</td><td class='form'>"); 495 html("</td><td class='form'>");
501 html("<form method='get' action=''>\n"); 496 html("<form method='get' action=''>\n");
502 add_hidden_formfields(0, 1, ctx->qry.page); 497 add_hidden_formfields(0, 1, ctx->qry.page);
503 html("<select name='h' onchange='this.form.submit();'>\n"); 498 html("<select name='h' onchange='this.form.submit();'>\n");
504 for_each_branch_ref(print_branch_option, ctx->qry.head); 499 for_each_branch_ref(print_branch_option, ctx->qry.head);
505 html("</select> "); 500 html("</select> ");
506 html("<input type='submit' name='' value='switch'/>"); 501 html("<input type='submit' name='' value='switch'/>");
507 html("</form>"); 502 html("</form>");
508 } else 503 } else
509 html_txt(ctx->cfg.root_title); 504 html_txt(ctx->cfg.root_title);
510 html("</td>\n"); 505 html("</td></tr>\n");
511 506
512 html("<tr><td class='sub'"); 507 html("<tr><td class='sub'");
513 if (ctx->repo) { 508 if (ctx->repo) {
514 html(" colspan='2'>"); 509 html(" colspan='2'>");
515 html_txt(ctx->repo->desc); 510 html_txt(ctx->repo->desc);
516 } 511 } else {
517/*
518 else if (ctx->cfg.root_subtitle)
519 html_txt(ctx->cfg.root_subtitle);
520*/
521 else {
522 html(">"); 512 html(">");
523 html_txt("a fast webinterface for the git dscm"); 513 html_txt("a fast webinterface for the git dscm");
524 } 514 }
525 html("</td></tr>\n"); 515 html("</td></tr></table>\n");
526
527 html("</tr>\n");
528 html("</table>\n");
529 516
530 html("<table class='tabs'><tr><td>\n"); 517 html("<table class='tabs'><tr><td>\n");
531 if (ctx->repo) { 518 if (ctx->repo) {
532 reporevlink(NULL, "summary", NULL, hc(cmd, "summary"), 519 reporevlink(NULL, "summary", NULL, hc(cmd, "summary"),
533 ctx->qry.head, NULL, NULL); 520 ctx->qry.head, NULL, NULL);
534 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, 521 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head,
535 ctx->qry.sha1, NULL); 522 ctx->qry.sha1, NULL);
536 cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, 523 cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head,
537 NULL, NULL, 0, NULL, NULL); 524 NULL, NULL, 0, NULL, NULL);
538 cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, 525 cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
539 ctx->qry.sha1, NULL); 526 ctx->qry.sha1, NULL);
540 cgit_commit_link("commit", NULL, hc(cmd, "commit"), 527 cgit_commit_link("commit", NULL, hc(cmd, "commit"),
541 ctx->qry.head, ctx->qry.sha1); 528 ctx->qry.head, ctx->qry.sha1);
542 cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, 529 cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head,
543 ctx->qry.sha1, ctx->qry.sha2, NULL); 530 ctx->qry.sha1, ctx->qry.sha2, NULL);
544 html("</td><td class='form'>"); 531 html("</td><td class='form'>");
545 html("<form class='right' method='get' action='"); 532 html("<form class='right' method='get' action='");
546 if (ctx->cfg.virtual_root) 533 if (ctx->cfg.virtual_root)
547 html_attr(cgit_fileurl(ctx->qry.repo, "log", 534 html_attr(cgit_fileurl(ctx->qry.repo, "log",
548 ctx->qry.path, NULL)); 535 ctx->qry.path, NULL));
549 html("'>\n"); 536 html("'>\n");
550 add_hidden_formfields(1, 0, "log"); 537 add_hidden_formfields(1, 0, "log");
551 html("<select name='qt'>\n"); 538 html("<select name='qt'>\n");
552 html_option("grep", "log msg", ctx->qry.grep); 539 html_option("grep", "log msg", ctx->qry.grep);
553 html_option("author", "author", ctx->qry.grep); 540 html_option("author", "author", ctx->qry.grep);
554 html_option("committer", "committer", ctx->qry.grep); 541 html_option("committer", "committer", ctx->qry.grep);
555 html("</select>\n"); 542 html("</select>\n");
556 html("<input class='txt' type='text' size='10' name='q' value='"); 543 html("<input class='txt' type='text' size='10' name='q' value='");
557 html_attr(ctx->qry.search); 544 html_attr(ctx->qry.search);
558 html("'/>\n"); 545 html("'/>\n");
559 html("<input type='submit' value='search'/>\n"); 546 html("<input type='submit' value='search'/>\n");
560 html("</form>\n"); 547 html("</form>\n");
561 } else { 548 } else {
562 html("<a class='active' href='"); 549 html("<a class='active' href='");
563 html_attr(cgit_rooturl()); 550 html_attr(cgit_rooturl());
564 html("'>index</a>\n"); 551 html("'>index</a>\n");
565 html("</td><td class='form'>"); 552 html("</td><td class='form'>");
566 html("<form method='get' action='"); 553 html("<form method='get' action='");
567 html_attr(cgit_rooturl()); 554 html_attr(cgit_rooturl());
568 html("'>\n"); 555 html("'>\n");
569 html("<input type='text' name='q' size='10' value='"); 556 html("<input type='text' name='q' size='10' value='");
570 html_attr(ctx->qry.search); 557 html_attr(ctx->qry.search);
571 html("'/>\n"); 558 html("'/>\n");
572 html("<input type='submit' value='search'/>\n"); 559 html("<input type='submit' value='search'/>\n");
573 html("</form>"); 560 html("</form>");
574 } 561 }
575 html("</td></tr></table>\n"); 562 html("</td></tr></table>\n");
576 html("<div class='content'>"); 563 html("<div class='content'>");