summaryrefslogtreecommitdiffabout
path: root/ui-repolist.c
authorLars Hjemli <hjemli@gmail.com>2006-12-11 15:48:03 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2006-12-11 15:49:18 (UTC)
commit74620f12e4f7e91cb0a0b4ca731e07272d1b65f6 (patch) (unidiff)
tree2e4db980535682c0a606d425b2937126d4b2c09b /ui-repolist.c
parent5a106eb09b9b5e189b96cc736046a92b054f6c7f (diff)
downloadcgit-74620f12e4f7e91cb0a0b4ca731e07272d1b65f6.zip
cgit-74620f12e4f7e91cb0a0b4ca731e07272d1b65f6.tar.gz
cgit-74620f12e4f7e91cb0a0b4ca731e07272d1b65f6.tar.bz2
Move functions for repolist output into ui-repolist.c
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-repolist.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-repolist.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/ui-repolist.c b/ui-repolist.c
new file mode 100644
index 0000000..1fe7059
--- a/dev/null
+++ b/ui-repolist.c
@@ -0,0 +1,60 @@
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 DIR *d;
14 struct dirent *de;
15 struct stat st;
16 char *name;
17
18 chdir(cgit_root);
19 cgit_print_docstart(cgit_root_title, item);
20 cgit_print_pageheader(cgit_root_title);
21
22 if (!(d = opendir("."))) {
23 cgit_print_error(fmt("Unable to scan repository directory: %s",
24 strerror(errno)));
25 cgit_print_docend();
26 return;
27 }
28
29 html("<h2>Repositories</h2>\n");
30 html("<table class='list'>");
31 html("<tr><th>Name</th><th>Description</th><th>Owner</th></tr>\n");
32 while ((de = readdir(d)) != NULL) {
33 if (de->d_name[0] == '.')
34 continue;
35 if (stat(de->d_name, &st) < 0)
36 continue;
37 if (!S_ISDIR(st.st_mode))
38 continue;
39
40 cgit_repo_name = cgit_repo_desc = cgit_repo_owner = NULL;
41 name = fmt("%s/info/cgit", de->d_name);
42 if (cgit_read_config(name, cgit_repo_config_cb))
43 continue;
44
45 html("<tr><td>");
46 html_link_open(cgit_repourl(de->d_name), NULL, NULL);
47 html_txt(cgit_repo_name);
48 html_link_close();
49 html("</td><td>");
50 html_txt(cgit_repo_desc);
51 html("</td><td>");
52 html_txt(cgit_repo_owner);
53 html("</td></tr>\n");
54 }
55 closedir(d);
56 html("</table>");
57 cgit_print_docend();
58}
59
60