blob: 33e3e7fdcc45690aad81d66ebee33d31cdd84dcf [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>"
30 "<th class='left'>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 Hjemli74620f12006-12-11 16:48:03 +010043 html("<tr><td>");
Lars Hjemlice1c7332007-02-03 15:02:55 +010044 html_link_open(cgit_repourl(repo->url), NULL, NULL);
45 html_txt(repo->name);
Lars Hjemli74620f12006-12-11 16:48:03 +010046 html_link_close();
47 html("</td><td>");
Lars Hjemlic1ad6cb2007-05-16 10:45:45 +020048 html_ntxt(cgit_max_repodesc_len, repo->desc);
Lars Hjemli74620f12006-12-11 16:48:03 +010049 html("</td><td>");
Lars Hjemlice1c7332007-02-03 15:02:55 +010050 html_txt(repo->owner);
Lars Hjemli8f6f8c32007-05-16 02:12:06 +020051 html("</td><td>");
52 html_link_open(cgit_pageurl(repo->name, "commit", NULL),
53 "Commit: display last commit", NULL);
54 html("C</a> ");
55 html_link_open(cgit_pageurl(repo->name, "diff", NULL),
56 "Diff: see changes introduced by last commit", NULL);
57 html("D</a> ");
58 html_link_open(cgit_pageurl(repo->name, "log", NULL),
59 "Log: show history of the main branch", NULL);
60 html("L</a> ");
61 html_link_open(cgit_pageurl(repo->name, "tree", NULL),
62 "Tree: browse the files in the main branch", NULL);
63 html("T</a>");
Lars Hjemli74620f12006-12-11 16:48:03 +010064 html("</td></tr>\n");
65 }
Lars Hjemli74620f12006-12-11 16:48:03 +010066 html("</table>");
67 cgit_print_docend();
68}