]> gitweb.ps.run Git - ps-cgit/blob - ui-repolist.c
Don't show new and old filemode for added/removed files
[ps-cgit] / ui-repolist.c
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
11 void 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