X-Git-Url: https://git.cameronkatri.com/cgit.git/blobdiff_plain/777faf7e509e1de2b795b2a326ff00c9bd799104..42a7eb9c73457319a3fd5441ff26046fc9b31dad:/ui-repolist.c?ds=sidebyside diff --git a/ui-repolist.c b/ui-repolist.c index bd4af59..2018dab 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -7,57 +7,92 @@ */ #include "cgit.h" +#include -void cgit_print_repolist(struct cacheitem *item) + +time_t read_agefile(char *path) { - DIR *d; - struct dirent *de; - struct stat st; - char *name; + FILE *f; + static char buf[64], buf2[64]; - chdir(cgit_root); - cgit_print_docstart(cgit_root_title, item); - cgit_print_pageheader(cgit_root_title, 0); + if (!(f = fopen(path, "r"))) + return -1; + fgets(buf, sizeof(buf), f); + fclose(f); + if (parse_date(buf, buf2, sizeof(buf2))) + return strtoul(buf2, NULL, 10); + else + return 0; +} - if (!(d = opendir("."))) { - cgit_print_error(fmt("Unable to scan repository directory: %s", - strerror(errno))); - cgit_print_docend(); +static void print_modtime(struct repoinfo *repo) +{ + char *path; + struct stat s; + + path = fmt("%s/%s", repo->path, cgit_agefile); + if (stat(path, &s) == 0) { + cgit_print_age(read_agefile(path), -1, NULL); return; } - html("

Repositories

\n"); + path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); + if (stat(path, &s) != 0) + return; + cgit_print_age(s.st_mtime, -1, NULL); +} + +void cgit_print_repolist(struct cacheitem *item) +{ + int i; + char *last_group = NULL; + + cgit_print_docstart(cgit_root_title, item); + cgit_print_pageheader(cgit_root_title, 0); + html(""); + if (cgit_index_header) { + html(""); + } html("" "" "" - "\n"); - while ((de = readdir(d)) != NULL) { - if (de->d_name[0] == '.') - continue; - if (stat(de->d_name, &st) < 0) - continue; - if (!S_ISDIR(st.st_mode)) - continue; - - cgit_repo_name = cgit_repo_desc = cgit_repo_owner = NULL; - name = fmt("%s/info/cgit", de->d_name); - if (cgit_read_config(name, cgit_repo_config_cb)) - continue; - - html("" + "" + "\n"); + + for (i=0; igroup != NULL) || + (last_group != NULL && cgit_repo->group == NULL) || + (last_group != NULL && cgit_repo->group != NULL && + strcmp(cgit_repo->group, last_group))) { + html(""); + last_group = cgit_repo->group; + } + htmlf("\n"); } - closedir(d); html("
"); + html_include(cgit_index_header); + html("
NameDescriptionOwner
"); - html_link_open(cgit_repourl(de->d_name), NULL, NULL); - html_txt(cgit_repo_name); + "OwnerIdleLinks
"); + html_txt(cgit_repo->group); + html("
", + cgit_repo->group ? "sublevel-repo" : "toplevel-repo"); + html_link_open(cgit_repourl(cgit_repo->url), NULL, NULL); + html_txt(cgit_repo->name); html_link_close(); html(""); - html_txt(cgit_repo_desc); + html_ntxt(cgit_max_repodesc_len, cgit_repo->desc); + html(""); + html_txt(cgit_repo->owner); + html(""); + print_modtime(cgit_repo); html(""); - html_txt(cgit_repo_owner); + html_link_open(cgit_repourl(cgit_repo->url), + "Summary", "button"); + html("S"); + cgit_log_link("L", "Log", "button", NULL, NULL, NULL); + cgit_tree_link("F", "Files", "button", NULL, NULL, NULL); html("
"); cgit_print_docend(); } - -