]>
git.cameronkatri.com Git - cgit.git/blob - ui-repolist.c
1 /* ui-repolist.c: functions for generating the repolist page
3 * Copyright (C) 2006 Lars Hjemli
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
13 time_t read_agefile(char *path
)
16 static char buf
[64], buf2
[64];
19 if (!(f
= fopen(path
, "r")))
21 fgets(buf
, sizeof(buf
), f
);
23 if (parse_date(buf
, buf2
, sizeof(buf2
)))
24 return strtoul(buf2
, NULL
, 10);
29 static void print_modtime(struct repoinfo
*repo
)
34 path
= fmt("%s/%s", repo
->path
, cgit_agefile
);
35 if (stat(path
, &s
) == 0) {
36 cgit_print_age(read_agefile(path
), -1, NULL
);
40 path
= fmt("%s/refs/heads/%s", repo
->path
, repo
->defbranch
);
41 if (stat(path
, &s
) != 0)
43 cgit_print_age(s
.st_mtime
, -1, NULL
);
46 void cgit_print_repolist(struct cacheitem
*item
)
48 struct repoinfo
*repo
;
50 char *last_group
= NULL
;
52 cgit_print_docstart(cgit_root_title
, item
);
53 cgit_print_pageheader(cgit_root_title
, 0);
55 html("<table class='list nowrap'>");
56 if (cgit_index_header
) {
57 html("<tr class='nohover'><td colspan='5' class='include-block'>");
58 html_include(cgit_index_header
);
61 html("<tr class='nohover'>"
62 "<th class='left'>Name</th>"
63 "<th class='left'>Description</th>"
64 "<th class='left'>Owner</th>"
65 "<th class='left'>Idle</th>"
66 "<th>Links</th></tr>\n");
68 for (i
=0; i
<cgit_repolist
.count
; i
++) {
69 repo
= &cgit_repolist
.repos
[i
];
70 if ((last_group
== NULL
&& repo
->group
!= NULL
) ||
71 (last_group
!= NULL
&& repo
->group
== NULL
) ||
72 (last_group
!= NULL
&& repo
->group
!= NULL
&&
73 strcmp(repo
->group
, last_group
))) {
74 html("<tr class='nohover'><td colspan='4' class='repogroup'>");
75 html_txt(repo
->group
);
77 last_group
= repo
->group
;
79 htmlf("<tr><td class='%s'>",
80 repo
->group
? "sublevel-repo" : "toplevel-repo");
81 html_link_open(cgit_repourl(repo
->url
), repo
->desc
, NULL
);
85 html_ntxt(cgit_max_repodesc_len
, repo
->desc
);
87 html_txt(repo
->owner
);
91 html_link_open(cgit_repourl(repo
->url
),
94 html_link_open(cgit_pageurl(repo
->name
, "log", NULL
),
97 html_link_open(cgit_pageurl(repo
->name
, "tree", NULL
),
100 html("</td></tr>\n");