ui-repolist.c (view raw)
1/* ui-repolist.c: functions for generating the repolist page
2 *
3 * Copyright (C) 2006 Lars Hjemli
4 *
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
7 */
8
9#include "cgit.h"
10
11void cgit_print_repolist(struct cacheitem *item)
12{
13 struct repoinfo *repo;
14 int i;
15 char *last_group = NULL;
16
17 cgit_print_docstart(cgit_root_title, item);
18 cgit_print_pageheader(cgit_root_title, 0);
19
20 html("<table class='list nowrap'>");
21 if (cgit_index_header) {
22 html("<tr class='nohover'><td colspan='4' class='include-block'>");
23 html_include(cgit_index_header);
24 html("</td></tr>");
25 }
26 html("<tr class='nohover'>"
27 "<th class='left'>Name</th>"
28 "<th class='left'>Description</th>"
29 "<th class='left'>Owner</th>"
30 "<th>Links</th></tr>\n");
31
32 for (i=0; i<cgit_repolist.count; i++) {
33 repo = &cgit_repolist.repos[i];
34 if ((last_group == NULL && repo->group != NULL) ||
35 (last_group != NULL && repo->group == NULL) ||
36 (last_group != NULL && repo->group!= NULL &&
37 strcmp(repo->group, last_group))) {
38 html("<tr class='nohover'><td colspan='4' class='repogroup'>");
39 html_txt(repo->group);
40 html("</td></tr>");
41 last_group = repo->group;
42 }
43 htmlf("<tr><td class='%s'>",
44 repo->group ? "sublevel-repo" : "toplevel-repo");
45 html_link_open(cgit_repourl(repo->url), repo->desc, NULL);
46 html_txt(repo->name);
47 html_link_close();
48 html("</td><td>");
49 html_ntxt(cgit_max_repodesc_len, repo->desc);
50 html("</td><td>");
51 html_txt(repo->owner);
52 html("</td><td>");
53 html_link_open(cgit_repourl(repo->url),
54 "Summary", "button");
55 html("S</a>");
56 html_link_open(cgit_pageurl(repo->name, "log", NULL),
57 "Log", "button");
58 html("L</a>");
59 html_link_open(cgit_pageurl(repo->name, "tree", NULL),
60 "Files", "button");
61 html("F</a>");
62 html("</td></tr>\n");
63 }
64 html("</table>");
65 cgit_print_docend();
66}