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 html("<tr class='nohover'>"
22 "<th class='left'>Name</th>"
23 "<th class='left'>Description</th>"
24 "<th class='left'>Owner</th>"
25 "<th class='left'>Links</th></tr>\n");
26
27 for (i=0; i<cgit_repolist.count; i++) {
28 repo = &cgit_repolist.repos[i];
29 if ((last_group == NULL && repo->group != NULL) ||
30 (last_group != NULL && repo->group == NULL) ||
31 (last_group != NULL && repo->group!= NULL &&
32 strcmp(repo->group, last_group))) {
33 html("<tr class='nohover'><td colspan='4' class='repogroup'>");
34 html_txt(repo->group);
35 html("</td></tr>");
36 last_group = repo->group;
37 }
38 html("<tr><td>");
39 html_link_open(cgit_repourl(repo->url), NULL, NULL);
40 html_txt(repo->name);
41 html_link_close();
42 html("</td><td>");
43 html_ntxt(cgit_max_repodesc_len, repo->desc);
44 html("</td><td>");
45 html_txt(repo->owner);
46 html("</td><td>");
47 html_link_open(cgit_pageurl(repo->name, "commit", NULL),
48 "Commit: display last commit", NULL);
49 html("C</a> ");
50 html_link_open(cgit_pageurl(repo->name, "diff", NULL),
51 "Diff: see changes introduced by last commit", NULL);
52 html("D</a> ");
53 html_link_open(cgit_pageurl(repo->name, "log", NULL),
54 "Log: show history of the main branch", NULL);
55 html("L</a> ");
56 html_link_open(cgit_pageurl(repo->name, "tree", NULL),
57 "Tree: browse the files in the main branch", NULL);
58 html("T</a>");
59 html("</td></tr>\n");
60 }
61 html("</table>");
62 cgit_print_docend();
63}