aboutsummaryrefslogtreecommitdiffstats
path: root/ui-repolist.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-repolist.c')
-rw-r--r--ui-repolist.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/ui-repolist.c b/ui-repolist.c
index f5e087f..573c730 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -7,6 +7,41 @@
7 */ 7 */
8 8
9#include "cgit.h" 9#include "cgit.h"
10#include <time.h>
11
12
13time_t read_agefile(char *path)
14{
15 FILE *f;
16 static char buf[64], buf2[64];
17 struct tm tm;
18
19 if (!(f = fopen(path, "r")))
20 return -1;
21 fgets(buf, sizeof(buf), f);
22 fclose(f);
23 if (parse_date(buf, buf2, sizeof(buf2)))
24 return strtoul(buf2, NULL, 10);
25 else
26 return 0;
27}
28
29static void print_modtime(struct repoinfo *repo)
30{
31 char *path;
32 struct stat s;
33
34 path = fmt("%s/%s", repo->path, cgit_agefile);
35 if (stat(path, &s) == 0) {
36 cgit_print_age(read_agefile(path), -1, NULL);
37 return;
38 }
39
40 path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch);
41 if (stat(path, &s) != 0)
42 return;
43 cgit_print_age(s.st_mtime, -1, NULL);
44}
10 45
11void cgit_print_repolist(struct cacheitem *item) 46void cgit_print_repolist(struct cacheitem *item)
12{ 47{
@@ -19,7 +54,7 @@ void cgit_print_repolist(struct cacheitem *item)
19 54
20 html("<table class='list nowrap'>"); 55 html("<table class='list nowrap'>");
21 if (cgit_index_header) { 56 if (cgit_index_header) {
22 html("<tr class='nohover'><td colspan='4' class='include-block'>"); 57 html("<tr class='nohover'><td colspan='5' class='include-block'>");
23 html_include(cgit_index_header); 58 html_include(cgit_index_header);
24 html("</td></tr>"); 59 html("</td></tr>");
25 } 60 }
@@ -27,6 +62,7 @@ void cgit_print_repolist(struct cacheitem *item)
27 "<th class='left'>Name</th>" 62 "<th class='left'>Name</th>"
28 "<th class='left'>Description</th>" 63 "<th class='left'>Description</th>"
29 "<th class='left'>Owner</th>" 64 "<th class='left'>Owner</th>"
65 "<th class='left'>Idle</th>"
30 "<th>Links</th></tr>\n"); 66 "<th>Links</th></tr>\n");
31 67
32 for (i=0; i<cgit_repolist.count; i++) { 68 for (i=0; i<cgit_repolist.count; i++) {
@@ -50,6 +86,8 @@ void cgit_print_repolist(struct cacheitem *item)
50 html("</td><td>"); 86 html("</td><td>");
51 html_txt(repo->owner); 87 html_txt(repo->owner);
52 html("</td><td>"); 88 html("</td><td>");
89 print_modtime(repo);
90 html("</td><td>");
53 html_link_open(cgit_repourl(repo->url), 91 html_link_open(cgit_repourl(repo->url),
54 "Summary", "button"); 92 "Summary", "button");
55 html("S</a>"); 93 html("S</a>");