summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show 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
@@ -101,24 +101,25 @@ struct taginfo {
101extern const char cgit_version[]; 101extern const char cgit_version[];
102 102
103extern struct repolist cgit_repolist; 103extern struct repolist cgit_repolist;
104extern struct repoinfo *cgit_repo; 104extern struct repoinfo *cgit_repo;
105extern int cgit_cmd; 105extern int cgit_cmd;
106 106
107extern char *cgit_root_title; 107extern char *cgit_root_title;
108extern char *cgit_css; 108extern char *cgit_css;
109extern char *cgit_logo; 109extern char *cgit_logo;
110extern char *cgit_index_header; 110extern char *cgit_index_header;
111extern char *cgit_logo_link; 111extern 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;
114extern char *cgit_script_name; 115extern char *cgit_script_name;
115extern char *cgit_cache_root; 116extern char *cgit_cache_root;
116extern char *cgit_repo_group; 117extern char *cgit_repo_group;
117 118
118extern int cgit_nocache; 119extern int cgit_nocache;
119extern int cgit_snapshots; 120extern int cgit_snapshots;
120extern int cgit_enable_log_filecount; 121extern int cgit_enable_log_filecount;
121extern int cgit_enable_log_linecount; 122extern int cgit_enable_log_linecount;
122extern int cgit_max_lock_attempts; 123extern int cgit_max_lock_attempts;
123extern int cgit_cache_root_ttl; 124extern int cgit_cache_root_ttl;
124extern int cgit_cache_repo_ttl; 125extern int cgit_cache_repo_ttl;
diff --git a/shared.c b/shared.c
index 65af11a..ce3ca4f 100644
--- a/shared.c
+++ b/shared.c
@@ -9,24 +9,25 @@
9#include "cgit.h" 9#include "cgit.h"
10 10
11struct repolist cgit_repolist; 11struct repolist cgit_repolist;
12struct repoinfo *cgit_repo; 12struct repoinfo *cgit_repo;
13int cgit_cmd; 13int cgit_cmd;
14 14
15char *cgit_root_title = "Git repository browser"; 15char *cgit_root_title = "Git repository browser";
16char *cgit_css = "/cgit.css"; 16char *cgit_css = "/cgit.css";
17char *cgit_logo = "/git-logo.png"; 17char *cgit_logo = "/git-logo.png";
18char *cgit_index_header = NULL; 18char *cgit_index_header = NULL;
19char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; 19char *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;
22char *cgit_script_name = CGIT_SCRIPT_NAME; 23char *cgit_script_name = CGIT_SCRIPT_NAME;
23char *cgit_cache_root = "/var/cache/cgit"; 24char *cgit_cache_root = "/var/cache/cgit";
24char *cgit_repo_group = NULL; 25char *cgit_repo_group = NULL;
25 26
26int cgit_nocache = 0; 27int cgit_nocache = 0;
27int cgit_snapshots = 0; 28int cgit_snapshots = 0;
28int cgit_enable_log_filecount = 0; 29int cgit_enable_log_filecount = 0;
29int cgit_enable_log_linecount = 0; 30int cgit_enable_log_linecount = 0;
30int cgit_max_lock_attempts = 5; 31int cgit_max_lock_attempts = 5;
31int cgit_cache_root_ttl = 5; 32int cgit_cache_root_ttl = 5;
32int cgit_cache_repo_ttl = 5; 33int cgit_cache_repo_ttl = 5;
@@ -153,24 +154,26 @@ void cgit_global_config_cb(const char *name, const char *value)
153 else if (!strcmp(name, "cache-repo-ttl")) 154 else if (!strcmp(name, "cache-repo-ttl"))
154 cgit_cache_repo_ttl = atoi(value); 155 cgit_cache_repo_ttl = atoi(value);
155 else if (!strcmp(name, "cache-static-ttl")) 156 else if (!strcmp(name, "cache-static-ttl"))
156 cgit_cache_static_ttl = atoi(value); 157 cgit_cache_static_ttl = atoi(value);
157 else if (!strcmp(name, "cache-dynamic-ttl")) 158 else if (!strcmp(name, "cache-dynamic-ttl"))
158 cgit_cache_dynamic_ttl = atoi(value); 159 cgit_cache_dynamic_ttl = atoi(value);
159 else if (!strcmp(name, "max-message-length")) 160 else if (!strcmp(name, "max-message-length"))
160 cgit_max_msg_len = atoi(value); 161 cgit_max_msg_len = atoi(value);
161 else if (!strcmp(name, "max-repodesc-length")) 162 else if (!strcmp(name, "max-repodesc-length"))
162 cgit_max_repodesc_len = atoi(value); 163 cgit_max_repodesc_len = atoi(value);
163 else if (!strcmp(name, "max-commit-count")) 164 else if (!strcmp(name, "max-commit-count"))
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"))
166 cgit_repo_group = xstrdup(value); 169 cgit_repo_group = xstrdup(value);
167 else if (!strcmp(name, "repo.url")) 170 else if (!strcmp(name, "repo.url"))
168 cgit_repo = add_repo(value); 171 cgit_repo = add_repo(value);
169 else if (!strcmp(name, "repo.name")) 172 else if (!strcmp(name, "repo.name"))
170 cgit_repo->name = xstrdup(value); 173 cgit_repo->name = xstrdup(value);
171 else if (cgit_repo && !strcmp(name, "repo.path")) 174 else if (cgit_repo && !strcmp(name, "repo.path"))
172 cgit_repo->path = xstrdup(value); 175 cgit_repo->path = xstrdup(value);
173 else if (cgit_repo && !strcmp(name, "repo.desc")) 176 else if (cgit_repo && !strcmp(name, "repo.desc"))
174 cgit_repo->desc = xstrdup(value); 177 cgit_repo->desc = xstrdup(value);
175 else if (cgit_repo && !strcmp(name, "repo.owner")) 178 else if (cgit_repo && !strcmp(name, "repo.owner"))
176 cgit_repo->owner = xstrdup(value); 179 cgit_repo->owner = xstrdup(value);
diff --git a/ui-repolist.c b/ui-repolist.c
index f5e087f..573c730 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -1,64 +1,102 @@
1/* ui-repolist.c: functions for generating the repolist page 1/* ui-repolist.c: functions for generating the repolist page
2 * 2 *
3 * Copyright (C) 2006 Lars Hjemli 3 * Copyright (C) 2006 Lars Hjemli
4 * 4 *
5 * Licensed under GNU General Public License v2 5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text) 6 * (see COPYING for full license text)
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{
13 struct repoinfo *repo; 48 struct repoinfo *repo;
14 int i; 49 int i;
15 char *last_group = NULL; 50 char *last_group = NULL;
16 51
17 cgit_print_docstart(cgit_root_title, item); 52 cgit_print_docstart(cgit_root_title, item);
18 cgit_print_pageheader(cgit_root_title, 0); 53 cgit_print_pageheader(cgit_root_title, 0);
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 }
26 html("<tr class='nohover'>" 61 html("<tr class='nohover'>"
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++) {
33 repo = &cgit_repolist.repos[i]; 69 repo = &cgit_repolist.repos[i];
34 if ((last_group == NULL && repo->group != NULL) || 70 if ((last_group == NULL && repo->group != NULL) ||
35 (last_group != NULL && repo->group == NULL) || 71 (last_group != NULL && repo->group == NULL) ||
36 (last_group != NULL && repo->group!= NULL && 72 (last_group != NULL && repo->group!= NULL &&
37 strcmp(repo->group, last_group))) { 73 strcmp(repo->group, last_group))) {
38 html("<tr class='nohover'><td colspan='4' class='repogroup'>"); 74 html("<tr class='nohover'><td colspan='4' class='repogroup'>");
39 html_txt(repo->group); 75 html_txt(repo->group);
40 html("</td></tr>"); 76 html("</td></tr>");
41 last_group = repo->group; 77 last_group = repo->group;
42 } 78 }
43 htmlf("<tr><td class='%s'>", 79 htmlf("<tr><td class='%s'>",
44 repo->group ? "sublevel-repo" : "toplevel-repo"); 80 repo->group ? "sublevel-repo" : "toplevel-repo");
45 html_link_open(cgit_repourl(repo->url), repo->desc, NULL); 81 html_link_open(cgit_repourl(repo->url), repo->desc, NULL);
46 html_txt(repo->name); 82 html_txt(repo->name);
47 html_link_close(); 83 html_link_close();
48 html("</td><td>"); 84 html("</td><td>");
49 html_ntxt(cgit_max_repodesc_len, repo->desc); 85 html_ntxt(cgit_max_repodesc_len, repo->desc);
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>");
56 html_link_open(cgit_pageurl(repo->name, "log", NULL), 94 html_link_open(cgit_pageurl(repo->name, "log", NULL),
57 "Log", "button"); 95 "Log", "button");
58 html("L</a>"); 96 html("L</a>");
59 html_link_open(cgit_pageurl(repo->name, "tree", NULL), 97 html_link_open(cgit_pageurl(repo->name, "tree", NULL),
60 "Files", "button"); 98 "Files", "button");
61 html("F</a>"); 99 html("F</a>");
62 html("</td></tr>\n"); 100 html("</td></tr>\n");
63 } 101 }
64 html("</table>"); 102 html("</table>");