summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
Unidiff
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/ui-shared.c b/ui-shared.c
index cf06511..07d5dd4 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -585,104 +585,107 @@ int print_archive_ref(const char *refname, const unsigned char *sha1,
585 buf)); 585 buf));
586 html_link_open(url, NULL, "menu"); 586 html_link_open(url, NULL, "menu");
587 html_txt(strlpart(buf, 20)); 587 html_txt(strlpart(buf, 20));
588 html_link_close(); 588 html_link_close();
589 return 0; 589 return 0;
590} 590}
591 591
592void cgit_add_hidden_formfields(int incl_head, int incl_search, char *page) 592void cgit_add_hidden_formfields(int incl_head, int incl_search, char *page)
593{ 593{
594 char *url; 594 char *url;
595 595
596 if (!ctx.cfg.virtual_root) { 596 if (!ctx.cfg.virtual_root) {
597 url = fmt("%s/%s", ctx.qry.repo, page); 597 url = fmt("%s/%s", ctx.qry.repo, page);
598 if (ctx.qry.path) 598 if (ctx.qry.path)
599 url = fmt("%s/%s", url, ctx.qry.path); 599 url = fmt("%s/%s", url, ctx.qry.path);
600 html_hidden("url", url); 600 html_hidden("url", url);
601 } 601 }
602 602
603 if (incl_head && ctx.qry.head && ctx.repo->defbranch && 603 if (incl_head && ctx.qry.head && ctx.repo->defbranch &&
604 strcmp(ctx.qry.head, ctx.repo->defbranch)) 604 strcmp(ctx.qry.head, ctx.repo->defbranch))
605 html_hidden("h", ctx.qry.head); 605 html_hidden("h", ctx.qry.head);
606 606
607 if (ctx.qry.sha1) 607 if (ctx.qry.sha1)
608 html_hidden("id", ctx.qry.sha1); 608 html_hidden("id", ctx.qry.sha1);
609 if (ctx.qry.sha2) 609 if (ctx.qry.sha2)
610 html_hidden("id2", ctx.qry.sha2); 610 html_hidden("id2", ctx.qry.sha2);
611 if (ctx.qry.showmsg) 611 if (ctx.qry.showmsg)
612 html_hidden("showmsg", "1"); 612 html_hidden("showmsg", "1");
613 613
614 if (incl_search) { 614 if (incl_search) {
615 if (ctx.qry.grep) 615 if (ctx.qry.grep)
616 html_hidden("qt", ctx.qry.grep); 616 html_hidden("qt", ctx.qry.grep);
617 if (ctx.qry.search) 617 if (ctx.qry.search)
618 html_hidden("q", ctx.qry.search); 618 html_hidden("q", ctx.qry.search);
619 } 619 }
620} 620}
621 621
622const char *fallback_cmd = "repolist"; 622const char *fallback_cmd = "repolist";
623 623
624char *hc(struct cgit_cmd *cmd, const char *page) 624char *hc(struct cgit_cmd *cmd, const char *page)
625{ 625{
626 return (strcmp(cmd ? cmd->name : fallback_cmd, page) ? NULL : "active"); 626 return (strcmp(cmd ? cmd->name : fallback_cmd, page) ? NULL : "active");
627} 627}
628 628
629static void print_header(struct cgit_context *ctx) 629static void print_header(struct cgit_context *ctx)
630{ 630{
631 html("<table id='header'>\n"); 631 html("<table id='header'>\n");
632 html("<tr>\n"); 632 html("<tr>\n");
633 html("<td class='logo' rowspan='2'><a href='"); 633
634 if (ctx->cfg.logo_link) 634 if (ctx->cfg.logo && ctx->cfg.logo[0] != 0) {
635 html_attr(ctx->cfg.logo_link); 635 html("<td class='logo' rowspan='2'><a href='");
636 else 636 if (ctx->cfg.logo_link)
637 html_attr(cgit_rooturl()); 637 html_attr(ctx->cfg.logo_link);
638 html("'><img src='"); 638 else
639 html_attr(ctx->cfg.logo); 639 html_attr(cgit_rooturl());
640 html("' alt='cgit logo'/></a></td>\n"); 640 html("'><img src='");
641 html_attr(ctx->cfg.logo);
642 html("' alt='cgit logo'/></a></td>\n");
643 }
641 644
642 html("<td class='main'>"); 645 html("<td class='main'>");
643 if (ctx->repo) { 646 if (ctx->repo) {
644 cgit_index_link("index", NULL, NULL, NULL, 0); 647 cgit_index_link("index", NULL, NULL, NULL, 0);
645 html(" : "); 648 html(" : ");
646 cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); 649 cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL);
647 html("</td><td class='form'>"); 650 html("</td><td class='form'>");
648 html("<form method='get' action=''>\n"); 651 html("<form method='get' action=''>\n");
649 cgit_add_hidden_formfields(0, 1, ctx->qry.page); 652 cgit_add_hidden_formfields(0, 1, ctx->qry.page);
650 html("<select name='h' onchange='this.form.submit();'>\n"); 653 html("<select name='h' onchange='this.form.submit();'>\n");
651 for_each_branch_ref(print_branch_option, ctx->qry.head); 654 for_each_branch_ref(print_branch_option, ctx->qry.head);
652 html("</select> "); 655 html("</select> ");
653 html("<input type='submit' name='' value='switch'/>"); 656 html("<input type='submit' name='' value='switch'/>");
654 html("</form>"); 657 html("</form>");
655 } else 658 } else
656 html_txt(ctx->cfg.root_title); 659 html_txt(ctx->cfg.root_title);
657 html("</td></tr>\n"); 660 html("</td></tr>\n");
658 661
659 html("<tr><td class='sub'>"); 662 html("<tr><td class='sub'>");
660 if (ctx->repo) { 663 if (ctx->repo) {
661 html_txt(ctx->repo->desc); 664 html_txt(ctx->repo->desc);
662 html("</td><td class='sub right'>"); 665 html("</td><td class='sub right'>");
663 html_txt(ctx->repo->owner); 666 html_txt(ctx->repo->owner);
664 } else { 667 } else {
665 if (ctx->cfg.root_desc) 668 if (ctx->cfg.root_desc)
666 html_txt(ctx->cfg.root_desc); 669 html_txt(ctx->cfg.root_desc);
667 else if (ctx->cfg.index_info) 670 else if (ctx->cfg.index_info)
668 html_include(ctx->cfg.index_info); 671 html_include(ctx->cfg.index_info);
669 } 672 }
670 html("</td></tr></table>\n"); 673 html("</td></tr></table>\n");
671} 674}
672 675
673void cgit_print_pageheader(struct cgit_context *ctx) 676void cgit_print_pageheader(struct cgit_context *ctx)
674{ 677{
675 struct cgit_cmd *cmd = cgit_get_cmd(ctx); 678 struct cgit_cmd *cmd = cgit_get_cmd(ctx);
676 679
677 if (!cmd && ctx->repo) 680 if (!cmd && ctx->repo)
678 fallback_cmd = "summary"; 681 fallback_cmd = "summary";
679 682
680 html("<div id='cgit'>"); 683 html("<div id='cgit'>");
681 if (!ctx->cfg.noheader) 684 if (!ctx->cfg.noheader)
682 print_header(ctx); 685 print_header(ctx);
683 686
684 html("<table class='tabs'><tr><td>\n"); 687 html("<table class='tabs'><tr><td>\n");
685 if (ctx->repo) { 688 if (ctx->repo) {
686 cgit_summary_link("summary", NULL, hc(cmd, "summary"), 689 cgit_summary_link("summary", NULL, hc(cmd, "summary"),
687 ctx->qry.head); 690 ctx->qry.head);
688 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, 691 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head,