summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.h1
-rw-r--r--shared.c3
-rw-r--r--ui-repolist.c40
3 files changed, 43 insertions, 1 deletions
diff --git a/cgit.h b/cgit.h
index 4da2d3d..3938633 100644
--- a/cgit.h
+++ b/cgit.h
@@ -112,2 +112,3 @@ extern char *cgit_logo_link;
112extern char *cgit_module_link; 112extern char *cgit_module_link;
113extern char *cgit_agefile;
113extern char *cgit_virtual_root; 114extern char *cgit_virtual_root;
diff --git a/shared.c b/shared.c
index 65af11a..ce3ca4f 100644
--- a/shared.c
+++ b/shared.c
@@ -20,2 +20,3 @@ char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/";
20char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; 20char *cgit_module_link = "./?repo=%s&page=commit&id=%s";
21char *cgit_agefile = "info/web/last-modified";
21char *cgit_virtual_root = NULL; 22char *cgit_virtual_root = NULL;
@@ -164,2 +165,4 @@ void cgit_global_config_cb(const char *name, const char *value)
164 cgit_max_commit_count = atoi(value); 165 cgit_max_commit_count = atoi(value);
166 else if (!strcmp(name, "agefile"))
167 cgit_agefile = xstrdup(value);
165 else if (!strcmp(name, "repo.group")) 168 else if (!strcmp(name, "repo.group"))
diff --git a/ui-repolist.c b/ui-repolist.c
index f5e087f..573c730 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -9,2 +9,37 @@
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
@@ -21,3 +56,3 @@ void cgit_print_repolist(struct cacheitem *item)
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);
@@ -29,2 +64,3 @@ void cgit_print_repolist(struct cacheitem *item)
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");
@@ -52,2 +88,4 @@ void cgit_print_repolist(struct cacheitem *item)
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),