blob: f5e087f36564d68dbd78587137d0ace5e33c4902 [file] [log] [blame]
Lars Hjemli74620f12006-12-11 16:48:03 +01001/* 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{
Lars Hjemlice1c7332007-02-03 15:02:55 +010013 struct repoinfo *repo;
14 int i;
Lars Hjemli5877c492007-05-18 22:48:22 +020015 char *last_group = NULL;
Lars Hjemli74620f12006-12-11 16:48:03 +010016
Lars Hjemli74620f12006-12-11 16:48:03 +010017 cgit_print_docstart(cgit_root_title, item);
Lars Hjemlie39d7382006-12-28 02:01:49 +010018 cgit_print_pageheader(cgit_root_title, 0);
Lars Hjemli74620f12006-12-11 16:48:03 +010019
Lars Hjemlic43f1242006-12-22 01:44:32 +010020 html("<table class='list nowrap'>");
Lars Hjemlide69ce02007-05-19 00:00:25 +020021 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 }
Lars Hjemli777faf72007-01-28 00:39:26 +010026 html("<tr class='nohover'>"
Lars Hjemlic43f1242006-12-22 01:44:32 +010027 "<th class='left'>Name</th>"
28 "<th class='left'>Description</th>"
Lars Hjemli8f6f8c32007-05-16 02:12:06 +020029 "<th class='left'>Owner</th>"
Lars Hjemli0b8b6a32007-05-21 00:14:28 +020030 "<th>Links</th></tr>\n");
Lars Hjemli74620f12006-12-11 16:48:03 +010031
Lars Hjemlice1c7332007-02-03 15:02:55 +010032 for (i=0; i<cgit_repolist.count; i++) {
33 repo = &cgit_repolist.repos[i];
Lars Hjemli5877c492007-05-18 22:48:22 +020034 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))) {
Lars Hjemli2aef89e2007-05-18 23:17:09 +020038 html("<tr class='nohover'><td colspan='4' class='repogroup'>");
Lars Hjemli5877c492007-05-18 22:48:22 +020039 html_txt(repo->group);
40 html("</td></tr>");
41 last_group = repo->group;
42 }
Lars Hjemli0b8b6a32007-05-21 00:14:28 +020043 htmlf("<tr><td class='%s'>",
44 repo->group ? "sublevel-repo" : "toplevel-repo");
45 html_link_open(cgit_repourl(repo->url), repo->desc, NULL);
Lars Hjemlice1c7332007-02-03 15:02:55 +010046 html_txt(repo->name);
Lars Hjemli74620f12006-12-11 16:48:03 +010047 html_link_close();
48 html("</td><td>");
Lars Hjemlic1ad6cb2007-05-16 10:45:45 +020049 html_ntxt(cgit_max_repodesc_len, repo->desc);
Lars Hjemli74620f12006-12-11 16:48:03 +010050 html("</td><td>");
Lars Hjemlice1c7332007-02-03 15:02:55 +010051 html_txt(repo->owner);
Lars Hjemli8f6f8c32007-05-16 02:12:06 +020052 html("</td><td>");
Lars Hjemli0b8b6a32007-05-21 00:14:28 +020053 html_link_open(cgit_repourl(repo->url),
54 "Summary", "button");
55 html("S</a>");
Lars Hjemli8f6f8c32007-05-16 02:12:06 +020056 html_link_open(cgit_pageurl(repo->name, "log", NULL),
Lars Hjemli0b8b6a32007-05-21 00:14:28 +020057 "Log", "button");
58 html("L</a>");
Lars Hjemli8f6f8c32007-05-16 02:12:06 +020059 html_link_open(cgit_pageurl(repo->name, "tree", NULL),
Lars Hjemli0b8b6a32007-05-21 00:14:28 +020060 "Files", "button");
61 html("F</a>");
Lars Hjemli74620f12006-12-11 16:48:03 +010062 html("</td></tr>\n");
63 }
Lars Hjemli74620f12006-12-11 16:48:03 +010064 html("</table>");
65 cgit_print_docend();
66}