-rw-r--r-- | ui-repolist.c | 8 | ||||
-rw-r--r-- | ui-shared.c | 7 |
2 files changed, 5 insertions, 10 deletions
diff --git a/ui-repolist.c b/ui-repolist.c index 725338b..ab050c7 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -70,101 +70,97 @@ int is_in_url(struct cgit_repo *repo) | |||
70 | 70 | ||
71 | void print_header(int columns) | 71 | void print_header(int columns) |
72 | { | 72 | { |
73 | html("<tr class='nohover'>" | 73 | html("<tr class='nohover'>" |
74 | "<th class='left'>Name</th>" | 74 | "<th class='left'>Name</th>" |
75 | "<th class='left'>Description</th>" | 75 | "<th class='left'>Description</th>" |
76 | "<th class='left'>Owner</th>" | 76 | "<th class='left'>Owner</th>" |
77 | "<th class='left'>Idle</th>"); | 77 | "<th class='left'>Idle</th>"); |
78 | if (ctx.cfg.enable_index_links) | 78 | if (ctx.cfg.enable_index_links) |
79 | html("<th class='left'>Links</th>"); | 79 | html("<th class='left'>Links</th>"); |
80 | html("</tr>\n"); | 80 | html("</tr>\n"); |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | void print_pager(int items, int pagelen, char *search) | 84 | void print_pager(int items, int pagelen, char *search) |
85 | { | 85 | { |
86 | int i; | 86 | int i; |
87 | html("<div class='pager'>"); | 87 | html("<div class='pager'>"); |
88 | for(i = 0; i * pagelen < items; i++) | 88 | for(i = 0; i * pagelen < items; i++) |
89 | cgit_index_link(fmt("[%d]", i+1), fmt("Page %d", i+1), NULL, | 89 | cgit_index_link(fmt("[%d]", i+1), fmt("Page %d", i+1), NULL, |
90 | search, i * pagelen); | 90 | search, i * pagelen); |
91 | html("</div>"); | 91 | html("</div>"); |
92 | } | 92 | } |
93 | 93 | ||
94 | void cgit_print_repolist() | 94 | void cgit_print_repolist() |
95 | { | 95 | { |
96 | int i, columns = 4, hits = 0, header = 0; | 96 | int i, columns = 4, hits = 0, header = 0; |
97 | char *last_group = NULL; | 97 | char *last_group = NULL; |
98 | 98 | ||
99 | if (ctx.cfg.enable_index_links) | 99 | if (ctx.cfg.enable_index_links) |
100 | columns++; | 100 | columns++; |
101 | 101 | ||
102 | ctx.page.title = ctx.cfg.root_title; | 102 | ctx.page.title = ctx.cfg.root_title; |
103 | cgit_print_http_headers(&ctx); | 103 | cgit_print_http_headers(&ctx); |
104 | cgit_print_docstart(&ctx); | 104 | cgit_print_docstart(&ctx); |
105 | cgit_print_pageheader(&ctx); | 105 | cgit_print_pageheader(&ctx); |
106 | 106 | ||
107 | if (ctx.cfg.index_header) | 107 | if (ctx.cfg.index_header) |
108 | html_include(ctx.cfg.index_header); | 108 | html_include(ctx.cfg.index_header); |
109 | 109 | ||
110 | html("<table summary='repository list' class='list nowrap'>"); | 110 | html("<table summary='repository list' class='list nowrap'>"); |
111 | for (i=0; i<cgit_repolist.count; i++) { | 111 | for (i=0; i<cgit_repolist.count; i++) { |
112 | ctx.repo = &cgit_repolist.repos[i]; | 112 | ctx.repo = &cgit_repolist.repos[i]; |
113 | if (!(is_match(ctx.repo) && is_in_url(ctx.repo))) | 113 | if (!(is_match(ctx.repo) && is_in_url(ctx.repo))) |
114 | continue; | 114 | continue; |
115 | hits++; | 115 | hits++; |
116 | if (hits <= ctx.qry.ofs) | 116 | if (hits <= ctx.qry.ofs) |
117 | continue; | 117 | continue; |
118 | if (hits > ctx.qry.ofs + ctx.cfg.max_repo_count) | 118 | if (hits > ctx.qry.ofs + ctx.cfg.max_repo_count) |
119 | continue; | 119 | continue; |
120 | if (!header++) | 120 | if (!header++) |
121 | print_header(columns); | 121 | print_header(columns); |
122 | if ((last_group == NULL && ctx.repo->group != NULL) || | 122 | if ((last_group == NULL && ctx.repo->group != NULL) || |
123 | (last_group != NULL && ctx.repo->group == NULL) || | 123 | (last_group != NULL && ctx.repo->group == NULL) || |
124 | (last_group != NULL && ctx.repo->group != NULL && | 124 | (last_group != NULL && ctx.repo->group != NULL && |
125 | strcmp(ctx.repo->group, last_group))) { | 125 | strcmp(ctx.repo->group, last_group))) { |
126 | htmlf("<tr class='nohover'><td colspan='%d' class='repogroup'>", | 126 | htmlf("<tr class='nohover'><td colspan='%d' class='repogroup'>", |
127 | columns); | 127 | columns); |
128 | html_txt(ctx.repo->group); | 128 | html_txt(ctx.repo->group); |
129 | html("</td></tr>"); | 129 | html("</td></tr>"); |
130 | last_group = ctx.repo->group; | 130 | last_group = ctx.repo->group; |
131 | } | 131 | } |
132 | htmlf("<tr><td class='%s'>", | 132 | htmlf("<tr><td class='%s'>", |
133 | ctx.repo->group ? "sublevel-repo" : "toplevel-repo"); | 133 | ctx.repo->group ? "sublevel-repo" : "toplevel-repo"); |
134 | html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL); | 134 | cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL); |
135 | html_txt(ctx.repo->name); | ||
136 | html_link_close(); | ||
137 | html("</td><td>"); | 135 | html("</td><td>"); |
138 | html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL); | 136 | html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL); |
139 | html_ntxt(ctx.cfg.max_repodesc_len, ctx.repo->desc); | 137 | html_ntxt(ctx.cfg.max_repodesc_len, ctx.repo->desc); |
140 | html_link_close(); | 138 | html_link_close(); |
141 | html("</td><td>"); | 139 | html("</td><td>"); |
142 | html_txt(ctx.repo->owner); | 140 | html_txt(ctx.repo->owner); |
143 | html("</td><td>"); | 141 | html("</td><td>"); |
144 | print_modtime(ctx.repo); | 142 | print_modtime(ctx.repo); |
145 | html("</td>"); | 143 | html("</td>"); |
146 | if (ctx.cfg.enable_index_links) { | 144 | if (ctx.cfg.enable_index_links) { |
147 | html("<td>"); | 145 | html("<td>"); |
148 | html_link_open(cgit_repourl(ctx.repo->url), | 146 | cgit_summary_link("summary", NULL, "button", NULL); |
149 | NULL, "button"); | ||
150 | html("summary</a>"); | ||
151 | cgit_log_link("log", NULL, "button", NULL, NULL, NULL, | 147 | cgit_log_link("log", NULL, "button", NULL, NULL, NULL, |
152 | 0, NULL, NULL); | 148 | 0, NULL, NULL); |
153 | cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); | 149 | cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); |
154 | html("</td>"); | 150 | html("</td>"); |
155 | } | 151 | } |
156 | html("</tr>\n"); | 152 | html("</tr>\n"); |
157 | } | 153 | } |
158 | html("</table>"); | 154 | html("</table>"); |
159 | if (!hits) | 155 | if (!hits) |
160 | cgit_print_error("No repositories found"); | 156 | cgit_print_error("No repositories found"); |
161 | else if (hits > ctx.cfg.max_repo_count) | 157 | else if (hits > ctx.cfg.max_repo_count) |
162 | print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search); | 158 | print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search); |
163 | cgit_print_docend(); | 159 | cgit_print_docend(); |
164 | } | 160 | } |
165 | 161 | ||
166 | void cgit_print_site_readme() | 162 | void cgit_print_site_readme() |
167 | { | 163 | { |
168 | if (ctx.cfg.root_readme) | 164 | if (ctx.cfg.root_readme) |
169 | html_include(ctx.cfg.root_readme); | 165 | html_include(ctx.cfg.root_readme); |
170 | } | 166 | } |
diff --git a/ui-shared.c b/ui-shared.c index ee3f6fe..1fc5c09 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -542,159 +542,158 @@ int print_archive_ref(const char *refname, const unsigned char *sha1, | |||
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()); |
598 | html("'><img src='"); | 598 | html("'><img src='"); |
599 | html_attr(ctx->cfg.logo); | 599 | html_attr(ctx->cfg.logo); |
600 | html("' alt='cgit logo'/></a></td>\n"); | 600 | html("' alt='cgit logo'/></a></td>\n"); |
601 | 601 | ||
602 | html("<td class='main'>"); | 602 | html("<td class='main'>"); |
603 | if (ctx->repo) { | 603 | if (ctx->repo) { |
604 | cgit_index_link("index", NULL, NULL, NULL, 0); | 604 | cgit_index_link("index", NULL, NULL, NULL, 0); |
605 | html(" : "); | 605 | html(" : "); |
606 | reporevlink(NULL, ctx->repo->name, NULL, hc(cmd, "summary"), | 606 | cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); |
607 | ctx->qry.head, NULL, NULL); | ||
608 | html("</td><td class='form'>"); | 607 | html("</td><td class='form'>"); |
609 | html("<form method='get' action=''>\n"); | 608 | html("<form method='get' action=''>\n"); |
610 | add_hidden_formfields(0, 1, ctx->qry.page); | 609 | add_hidden_formfields(0, 1, ctx->qry.page); |
611 | html("<select name='h' onchange='this.form.submit();'>\n"); | 610 | html("<select name='h' onchange='this.form.submit();'>\n"); |
612 | for_each_branch_ref(print_branch_option, ctx->qry.head); | 611 | for_each_branch_ref(print_branch_option, ctx->qry.head); |
613 | html("</select> "); | 612 | html("</select> "); |
614 | html("<input type='submit' name='' value='switch'/>"); | 613 | html("<input type='submit' name='' value='switch'/>"); |
615 | html("</form>"); | 614 | html("</form>"); |
616 | } else | 615 | } else |
617 | html_txt(ctx->cfg.root_title); | 616 | html_txt(ctx->cfg.root_title); |
618 | html("</td></tr>\n"); | 617 | html("</td></tr>\n"); |
619 | 618 | ||
620 | html("<tr><td class='sub'>"); | 619 | html("<tr><td class='sub'>"); |
621 | if (ctx->repo) { | 620 | if (ctx->repo) { |
622 | html_txt(ctx->repo->desc); | 621 | html_txt(ctx->repo->desc); |
623 | html("</td><td class='sub right'>"); | 622 | html("</td><td class='sub right'>"); |
624 | html_txt(ctx->repo->owner); | 623 | html_txt(ctx->repo->owner); |
625 | } else { | 624 | } else { |
626 | if (ctx->cfg.root_desc) | 625 | if (ctx->cfg.root_desc) |
627 | html_txt(ctx->cfg.root_desc); | 626 | html_txt(ctx->cfg.root_desc); |
628 | else if (ctx->cfg.index_info) | 627 | else if (ctx->cfg.index_info) |
629 | html_include(ctx->cfg.index_info); | 628 | html_include(ctx->cfg.index_info); |
630 | } | 629 | } |
631 | html("</td></tr></table>\n"); | 630 | html("</td></tr></table>\n"); |
632 | 631 | ||
633 | html("<table class='tabs'><tr><td>\n"); | 632 | html("<table class='tabs'><tr><td>\n"); |
634 | if (ctx->repo) { | 633 | if (ctx->repo) { |
635 | reporevlink(NULL, "summary", NULL, hc(cmd, "summary"), | 634 | cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, |
636 | ctx->qry.head, NULL, NULL); | 635 | ctx->qry.head); |
637 | cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, | 636 | cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, |
638 | ctx->qry.sha1, NULL); | 637 | ctx->qry.sha1, NULL); |
639 | cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, | 638 | cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, |
640 | NULL, NULL, 0, NULL, NULL); | 639 | NULL, NULL, 0, NULL, NULL); |
641 | cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, | 640 | cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, |
642 | ctx->qry.sha1, NULL); | 641 | ctx->qry.sha1, NULL); |
643 | cgit_commit_link("commit", NULL, hc(cmd, "commit"), | 642 | cgit_commit_link("commit", NULL, hc(cmd, "commit"), |
644 | ctx->qry.head, ctx->qry.sha1); | 643 | ctx->qry.head, ctx->qry.sha1); |
645 | cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, | 644 | cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, |
646 | ctx->qry.sha1, ctx->qry.sha2, NULL); | 645 | ctx->qry.sha1, ctx->qry.sha2, NULL); |
647 | if (ctx->repo->readme) | 646 | if (ctx->repo->readme) |
648 | reporevlink("about", "about", NULL, | 647 | reporevlink("about", "about", NULL, |
649 | hc(cmd, "about"), ctx->qry.head, NULL, | 648 | hc(cmd, "about"), ctx->qry.head, NULL, |
650 | NULL); | 649 | NULL); |
651 | html("</td><td class='form'>"); | 650 | html("</td><td class='form'>"); |
652 | html("<form class='right' method='get' action='"); | 651 | html("<form class='right' method='get' action='"); |
653 | if (ctx->cfg.virtual_root) | 652 | if (ctx->cfg.virtual_root) |
654 | html_attr(cgit_fileurl(ctx->qry.repo, "log", | 653 | html_attr(cgit_fileurl(ctx->qry.repo, "log", |
655 | ctx->qry.path, NULL)); | 654 | ctx->qry.path, NULL)); |
656 | html("'>\n"); | 655 | html("'>\n"); |
657 | add_hidden_formfields(1, 0, "log"); | 656 | add_hidden_formfields(1, 0, "log"); |
658 | html("<select name='qt'>\n"); | 657 | html("<select name='qt'>\n"); |
659 | html_option("grep", "log msg", ctx->qry.grep); | 658 | html_option("grep", "log msg", ctx->qry.grep); |
660 | html_option("author", "author", ctx->qry.grep); | 659 | html_option("author", "author", ctx->qry.grep); |
661 | html_option("committer", "committer", ctx->qry.grep); | 660 | html_option("committer", "committer", ctx->qry.grep); |
662 | html("</select>\n"); | 661 | html("</select>\n"); |
663 | html("<input class='txt' type='text' size='10' name='q' value='"); | 662 | html("<input class='txt' type='text' size='10' name='q' value='"); |
664 | html_attr(ctx->qry.search); | 663 | html_attr(ctx->qry.search); |
665 | html("'/>\n"); | 664 | html("'/>\n"); |
666 | html("<input type='submit' value='search'/>\n"); | 665 | html("<input type='submit' value='search'/>\n"); |
667 | html("</form>\n"); | 666 | html("</form>\n"); |
668 | } else { | 667 | } else { |
669 | site_link(NULL, "index", NULL, hc(cmd, "repolist"), NULL, 0); | 668 | site_link(NULL, "index", NULL, hc(cmd, "repolist"), NULL, 0); |
670 | if (ctx->cfg.root_readme) | 669 | if (ctx->cfg.root_readme) |
671 | site_link("about", "about", NULL, hc(cmd, "about"), | 670 | site_link("about", "about", NULL, hc(cmd, "about"), |
672 | NULL, 0); | 671 | NULL, 0); |
673 | html("</td><td class='form'>"); | 672 | html("</td><td class='form'>"); |
674 | html("<form method='get' action='"); | 673 | html("<form method='get' action='"); |
675 | html_attr(cgit_rooturl()); | 674 | html_attr(cgit_rooturl()); |
676 | html("'>\n"); | 675 | html("'>\n"); |
677 | html("<input type='text' name='q' size='10' value='"); | 676 | html("<input type='text' name='q' size='10' value='"); |
678 | html_attr(ctx->qry.search); | 677 | html_attr(ctx->qry.search); |
679 | html("'/>\n"); | 678 | html("'/>\n"); |
680 | html("<input type='submit' value='search'/>\n"); | 679 | html("<input type='submit' value='search'/>\n"); |
681 | html("</form>"); | 680 | html("</form>"); |
682 | } | 681 | } |
683 | html("</td></tr></table>\n"); | 682 | html("</td></tr></table>\n"); |
684 | html("<div class='content'>"); | 683 | html("<div class='content'>"); |
685 | } | 684 | } |
686 | 685 | ||
687 | void cgit_print_filemode(unsigned short mode) | 686 | void cgit_print_filemode(unsigned short mode) |
688 | { | 687 | { |
689 | if (S_ISDIR(mode)) | 688 | if (S_ISDIR(mode)) |
690 | html("d"); | 689 | html("d"); |
691 | else if (S_ISLNK(mode)) | 690 | else if (S_ISLNK(mode)) |
692 | html("l"); | 691 | html("l"); |
693 | else if (S_ISGITLINK(mode)) | 692 | else if (S_ISGITLINK(mode)) |
694 | html("m"); | 693 | html("m"); |
695 | else | 694 | else |
696 | html("-"); | 695 | html("-"); |
697 | html_fileperm(mode >> 6); | 696 | html_fileperm(mode >> 6); |
698 | html_fileperm(mode >> 3); | 697 | html_fileperm(mode >> 3); |
699 | html_fileperm(mode); | 698 | html_fileperm(mode); |
700 | } | 699 | } |