-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc | 4 | ||||
-rw-r--r-- | shared.c | 3 | ||||
-rw-r--r-- | ui-repolist.c | 35 |
4 files changed, 31 insertions, 12 deletions
@@ -97,48 +97,49 @@ struct taginfo { | |||
97 | int tagger_date; | 97 | int tagger_date; |
98 | char *msg; | 98 | char *msg; |
99 | }; | 99 | }; |
100 | 100 | ||
101 | extern const char cgit_version[]; | 101 | extern const char cgit_version[]; |
102 | 102 | ||
103 | extern struct repolist cgit_repolist; | 103 | extern struct repolist cgit_repolist; |
104 | extern struct repoinfo *cgit_repo; | 104 | extern struct repoinfo *cgit_repo; |
105 | extern int cgit_cmd; | 105 | extern int cgit_cmd; |
106 | 106 | ||
107 | extern char *cgit_root_title; | 107 | extern char *cgit_root_title; |
108 | extern char *cgit_css; | 108 | extern char *cgit_css; |
109 | extern char *cgit_logo; | 109 | extern char *cgit_logo; |
110 | extern char *cgit_index_header; | 110 | extern char *cgit_index_header; |
111 | extern char *cgit_logo_link; | 111 | extern char *cgit_logo_link; |
112 | extern char *cgit_module_link; | 112 | extern char *cgit_module_link; |
113 | extern char *cgit_agefile; | 113 | extern char *cgit_agefile; |
114 | extern char *cgit_virtual_root; | 114 | extern char *cgit_virtual_root; |
115 | extern char *cgit_script_name; | 115 | extern char *cgit_script_name; |
116 | extern char *cgit_cache_root; | 116 | extern char *cgit_cache_root; |
117 | extern char *cgit_repo_group; | 117 | extern char *cgit_repo_group; |
118 | 118 | ||
119 | extern int cgit_nocache; | 119 | extern int cgit_nocache; |
120 | extern int cgit_snapshots; | 120 | extern int cgit_snapshots; |
121 | extern int cgit_enable_index_links; | ||
121 | extern int cgit_enable_log_filecount; | 122 | extern int cgit_enable_log_filecount; |
122 | extern int cgit_enable_log_linecount; | 123 | extern int cgit_enable_log_linecount; |
123 | extern int cgit_max_lock_attempts; | 124 | extern int cgit_max_lock_attempts; |
124 | extern int cgit_cache_root_ttl; | 125 | extern int cgit_cache_root_ttl; |
125 | extern int cgit_cache_repo_ttl; | 126 | extern int cgit_cache_repo_ttl; |
126 | extern int cgit_cache_dynamic_ttl; | 127 | extern int cgit_cache_dynamic_ttl; |
127 | extern int cgit_cache_static_ttl; | 128 | extern int cgit_cache_static_ttl; |
128 | extern int cgit_cache_max_create_time; | 129 | extern int cgit_cache_max_create_time; |
129 | extern int cgit_summary_log; | 130 | extern int cgit_summary_log; |
130 | 131 | ||
131 | extern int cgit_max_msg_len; | 132 | extern int cgit_max_msg_len; |
132 | extern int cgit_max_repodesc_len; | 133 | extern int cgit_max_repodesc_len; |
133 | extern int cgit_max_commit_count; | 134 | extern int cgit_max_commit_count; |
134 | 135 | ||
135 | extern int cgit_query_has_symref; | 136 | extern int cgit_query_has_symref; |
136 | extern int cgit_query_has_sha1; | 137 | extern int cgit_query_has_sha1; |
137 | 138 | ||
138 | extern char *cgit_querystring; | 139 | extern char *cgit_querystring; |
139 | extern char *cgit_query_repo; | 140 | extern char *cgit_query_repo; |
140 | extern char *cgit_query_page; | 141 | extern char *cgit_query_page; |
141 | extern char *cgit_query_search; | 142 | extern char *cgit_query_search; |
142 | extern char *cgit_query_head; | 143 | extern char *cgit_query_head; |
143 | extern char *cgit_query_sha1; | 144 | extern char *cgit_query_sha1; |
144 | extern char *cgit_query_sha2; | 145 | extern char *cgit_query_sha2; |
@@ -1,38 +1,42 @@ | |||
1 | ## | 1 | ## |
2 | ## cgitrc: template for /etc/cgitrc | 2 | ## cgitrc: template for /etc/cgitrc |
3 | ## | 3 | ## |
4 | 4 | ||
5 | 5 | ||
6 | ## Uncomment and set to 1 to deactivate caching of generated pages. Mostly | 6 | ## Uncomment and set to 1 to deactivate caching of generated pages. Mostly |
7 | ## usefull for testing. | 7 | ## usefull for testing. |
8 | #nocache=0 | 8 | #nocache=0 |
9 | 9 | ||
10 | 10 | ||
11 | ## Enable/disable snapshots by default. This can be overridden per repo | 11 | ## Enable/disable snapshots by default. This can be overridden per repo |
12 | #snapshots=0 | 12 | #snapshots=0 |
13 | 13 | ||
14 | 14 | ||
15 | ## Enable/disable extra links to summary/log/tree per repo on index page | ||
16 | #enable-index-links=0 | ||
17 | |||
18 | |||
15 | ## Enable/disable display of 'number of files changed' in log view | 19 | ## Enable/disable display of 'number of files changed' in log view |
16 | #enable-log-filecount=0 | 20 | #enable-log-filecount=0 |
17 | 21 | ||
18 | 22 | ||
19 | ## Enable/disable display of 'number of lines changed' in log view | 23 | ## Enable/disable display of 'number of lines changed' in log view |
20 | #enable-log-linecount=0 | 24 | #enable-log-linecount=0 |
21 | 25 | ||
22 | 26 | ||
23 | ## Enable/disable display of HEAD shortlog in summary view. Set it to maximum | 27 | ## Enable/disable display of HEAD shortlog in summary view. Set it to maximum |
24 | ## number of commits that should be displayed | 28 | ## number of commits that should be displayed |
25 | #summary-log=0 | 29 | #summary-log=0 |
26 | 30 | ||
27 | 31 | ||
28 | ## Specify a root for virtual urls. This makes cgit generate urls like | 32 | ## Specify a root for virtual urls. This makes cgit generate urls like |
29 | ## | 33 | ## |
30 | ## http://localhost/git/repo/log/?id=master | 34 | ## http://localhost/git/repo/log/?id=master |
31 | ## | 35 | ## |
32 | ## instead of | 36 | ## instead of |
33 | ## | 37 | ## |
34 | ## http://localhost/cgit/cgit.cgi?r=repo&p=log&id=master | 38 | ## http://localhost/cgit/cgit.cgi?r=repo&p=log&id=master |
35 | ## | 39 | ## |
36 | ## For this to work with apache, rewrite rules must be added to httpd.conf, | 40 | ## For this to work with apache, rewrite rules must be added to httpd.conf, |
37 | ## possibly looking something like this: | 41 | ## possibly looking something like this: |
38 | ## | 42 | ## |
@@ -5,48 +5,49 @@ | |||
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 | 10 | ||
11 | struct repolist cgit_repolist; | 11 | struct repolist cgit_repolist; |
12 | struct repoinfo *cgit_repo; | 12 | struct repoinfo *cgit_repo; |
13 | int cgit_cmd; | 13 | int cgit_cmd; |
14 | 14 | ||
15 | char *cgit_root_title = "Git repository browser"; | 15 | char *cgit_root_title = "Git repository browser"; |
16 | char *cgit_css = "/cgit.css"; | 16 | char *cgit_css = "/cgit.css"; |
17 | char *cgit_logo = "/git-logo.png"; | 17 | char *cgit_logo = "/git-logo.png"; |
18 | char *cgit_index_header = NULL; | 18 | char *cgit_index_header = NULL; |
19 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; | 19 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
20 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; | 20 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; |
21 | char *cgit_agefile = "info/web/last-modified"; | 21 | char *cgit_agefile = "info/web/last-modified"; |
22 | char *cgit_virtual_root = NULL; | 22 | char *cgit_virtual_root = NULL; |
23 | char *cgit_script_name = CGIT_SCRIPT_NAME; | 23 | char *cgit_script_name = CGIT_SCRIPT_NAME; |
24 | char *cgit_cache_root = "/var/cache/cgit"; | 24 | char *cgit_cache_root = "/var/cache/cgit"; |
25 | char *cgit_repo_group = NULL; | 25 | char *cgit_repo_group = NULL; |
26 | 26 | ||
27 | int cgit_nocache = 0; | 27 | int cgit_nocache = 0; |
28 | int cgit_snapshots = 0; | 28 | int cgit_snapshots = 0; |
29 | int cgit_enable_index_links = 0; | ||
29 | int cgit_enable_log_filecount = 0; | 30 | int cgit_enable_log_filecount = 0; |
30 | int cgit_enable_log_linecount = 0; | 31 | int cgit_enable_log_linecount = 0; |
31 | int cgit_max_lock_attempts = 5; | 32 | int cgit_max_lock_attempts = 5; |
32 | int cgit_cache_root_ttl = 5; | 33 | int cgit_cache_root_ttl = 5; |
33 | int cgit_cache_repo_ttl = 5; | 34 | int cgit_cache_repo_ttl = 5; |
34 | int cgit_cache_dynamic_ttl = 5; | 35 | int cgit_cache_dynamic_ttl = 5; |
35 | int cgit_cache_static_ttl = -1; | 36 | int cgit_cache_static_ttl = -1; |
36 | int cgit_cache_max_create_time = 5; | 37 | int cgit_cache_max_create_time = 5; |
37 | int cgit_summary_log = 0; | 38 | int cgit_summary_log = 0; |
38 | 39 | ||
39 | int cgit_max_msg_len = 60; | 40 | int cgit_max_msg_len = 60; |
40 | int cgit_max_repodesc_len = 60; | 41 | int cgit_max_repodesc_len = 60; |
41 | int cgit_max_commit_count = 50; | 42 | int cgit_max_commit_count = 50; |
42 | 43 | ||
43 | int cgit_query_has_symref = 0; | 44 | int cgit_query_has_symref = 0; |
44 | int cgit_query_has_sha1 = 0; | 45 | int cgit_query_has_sha1 = 0; |
45 | 46 | ||
46 | char *cgit_querystring = NULL; | 47 | char *cgit_querystring = NULL; |
47 | char *cgit_query_repo = NULL; | 48 | char *cgit_query_repo = NULL; |
48 | char *cgit_query_page = NULL; | 49 | char *cgit_query_page = NULL; |
49 | char *cgit_query_head = NULL; | 50 | char *cgit_query_head = NULL; |
50 | char *cgit_query_search = NULL; | 51 | char *cgit_query_search = NULL; |
51 | char *cgit_query_sha1 = NULL; | 52 | char *cgit_query_sha1 = NULL; |
52 | char *cgit_query_sha2 = NULL; | 53 | char *cgit_query_sha2 = NULL; |
@@ -125,48 +126,50 @@ struct repoinfo *cgit_get_repoinfo(const char *url) | |||
125 | } | 126 | } |
126 | return NULL; | 127 | return NULL; |
127 | } | 128 | } |
128 | 129 | ||
129 | void cgit_global_config_cb(const char *name, const char *value) | 130 | void cgit_global_config_cb(const char *name, const char *value) |
130 | { | 131 | { |
131 | if (!strcmp(name, "root-title")) | 132 | if (!strcmp(name, "root-title")) |
132 | cgit_root_title = xstrdup(value); | 133 | cgit_root_title = xstrdup(value); |
133 | else if (!strcmp(name, "css")) | 134 | else if (!strcmp(name, "css")) |
134 | cgit_css = xstrdup(value); | 135 | cgit_css = xstrdup(value); |
135 | else if (!strcmp(name, "logo")) | 136 | else if (!strcmp(name, "logo")) |
136 | cgit_logo = xstrdup(value); | 137 | cgit_logo = xstrdup(value); |
137 | else if (!strcmp(name, "index-header")) | 138 | else if (!strcmp(name, "index-header")) |
138 | cgit_index_header = xstrdup(value); | 139 | cgit_index_header = xstrdup(value); |
139 | else if (!strcmp(name, "logo-link")) | 140 | else if (!strcmp(name, "logo-link")) |
140 | cgit_logo_link = xstrdup(value); | 141 | cgit_logo_link = xstrdup(value); |
141 | else if (!strcmp(name, "module-link")) | 142 | else if (!strcmp(name, "module-link")) |
142 | cgit_module_link = xstrdup(value); | 143 | cgit_module_link = xstrdup(value); |
143 | else if (!strcmp(name, "virtual-root")) | 144 | else if (!strcmp(name, "virtual-root")) |
144 | cgit_virtual_root = xstrdup(value); | 145 | cgit_virtual_root = xstrdup(value); |
145 | else if (!strcmp(name, "nocache")) | 146 | else if (!strcmp(name, "nocache")) |
146 | cgit_nocache = atoi(value); | 147 | cgit_nocache = atoi(value); |
147 | else if (!strcmp(name, "snapshots")) | 148 | else if (!strcmp(name, "snapshots")) |
148 | cgit_snapshots = atoi(value); | 149 | cgit_snapshots = atoi(value); |
150 | else if (!strcmp(name, "enable-index-links")) | ||
151 | cgit_enable_index_links = atoi(value); | ||
149 | else if (!strcmp(name, "enable-log-filecount")) | 152 | else if (!strcmp(name, "enable-log-filecount")) |
150 | cgit_enable_log_filecount = atoi(value); | 153 | cgit_enable_log_filecount = atoi(value); |
151 | else if (!strcmp(name, "enable-log-linecount")) | 154 | else if (!strcmp(name, "enable-log-linecount")) |
152 | cgit_enable_log_linecount = atoi(value); | 155 | cgit_enable_log_linecount = atoi(value); |
153 | else if (!strcmp(name, "cache-root")) | 156 | else if (!strcmp(name, "cache-root")) |
154 | cgit_cache_root = xstrdup(value); | 157 | cgit_cache_root = xstrdup(value); |
155 | else if (!strcmp(name, "cache-root-ttl")) | 158 | else if (!strcmp(name, "cache-root-ttl")) |
156 | cgit_cache_root_ttl = atoi(value); | 159 | cgit_cache_root_ttl = atoi(value); |
157 | else if (!strcmp(name, "cache-repo-ttl")) | 160 | else if (!strcmp(name, "cache-repo-ttl")) |
158 | cgit_cache_repo_ttl = atoi(value); | 161 | cgit_cache_repo_ttl = atoi(value); |
159 | else if (!strcmp(name, "cache-static-ttl")) | 162 | else if (!strcmp(name, "cache-static-ttl")) |
160 | cgit_cache_static_ttl = atoi(value); | 163 | cgit_cache_static_ttl = atoi(value); |
161 | else if (!strcmp(name, "cache-dynamic-ttl")) | 164 | else if (!strcmp(name, "cache-dynamic-ttl")) |
162 | cgit_cache_dynamic_ttl = atoi(value); | 165 | cgit_cache_dynamic_ttl = atoi(value); |
163 | else if (!strcmp(name, "max-message-length")) | 166 | else if (!strcmp(name, "max-message-length")) |
164 | cgit_max_msg_len = atoi(value); | 167 | cgit_max_msg_len = atoi(value); |
165 | else if (!strcmp(name, "max-repodesc-length")) | 168 | else if (!strcmp(name, "max-repodesc-length")) |
166 | cgit_max_repodesc_len = atoi(value); | 169 | cgit_max_repodesc_len = atoi(value); |
167 | else if (!strcmp(name, "max-commit-count")) | 170 | else if (!strcmp(name, "max-commit-count")) |
168 | cgit_max_commit_count = atoi(value); | 171 | cgit_max_commit_count = atoi(value); |
169 | else if (!strcmp(name, "summary-log")) | 172 | else if (!strcmp(name, "summary-log")) |
170 | cgit_summary_log = atoi(value); | 173 | cgit_summary_log = atoi(value); |
171 | else if (!strcmp(name, "agefile")) | 174 | else if (!strcmp(name, "agefile")) |
172 | cgit_agefile = xstrdup(value); | 175 | cgit_agefile = xstrdup(value); |
diff --git a/ui-repolist.c b/ui-repolist.c index 4f820a8..c735368 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -23,76 +23,87 @@ time_t read_agefile(char *path) | |||
23 | return strtoul(buf2, NULL, 10); | 23 | return strtoul(buf2, NULL, 10); |
24 | else | 24 | else |
25 | return 0; | 25 | return 0; |
26 | } | 26 | } |
27 | 27 | ||
28 | static void print_modtime(struct repoinfo *repo) | 28 | static void print_modtime(struct repoinfo *repo) |
29 | { | 29 | { |
30 | char *path; | 30 | char *path; |
31 | struct stat s; | 31 | struct stat s; |
32 | 32 | ||
33 | path = fmt("%s/%s", repo->path, cgit_agefile); | 33 | path = fmt("%s/%s", repo->path, cgit_agefile); |
34 | if (stat(path, &s) == 0) { | 34 | if (stat(path, &s) == 0) { |
35 | cgit_print_age(read_agefile(path), -1, NULL); | 35 | cgit_print_age(read_agefile(path), -1, NULL); |
36 | return; | 36 | return; |
37 | } | 37 | } |
38 | 38 | ||
39 | path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); | 39 | path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); |
40 | if (stat(path, &s) != 0) | 40 | if (stat(path, &s) != 0) |
41 | return; | 41 | return; |
42 | cgit_print_age(s.st_mtime, -1, NULL); | 42 | cgit_print_age(s.st_mtime, -1, NULL); |
43 | } | 43 | } |
44 | 44 | ||
45 | void cgit_print_repolist(struct cacheitem *item) | 45 | void cgit_print_repolist(struct cacheitem *item) |
46 | { | 46 | { |
47 | int i; | 47 | int i, columns = 4; |
48 | char *last_group = NULL; | 48 | char *last_group = NULL; |
49 | 49 | ||
50 | if (cgit_enable_index_links) | ||
51 | columns++; | ||
52 | |||
50 | cgit_print_docstart(cgit_root_title, item); | 53 | cgit_print_docstart(cgit_root_title, item); |
51 | cgit_print_pageheader(cgit_root_title, 0); | 54 | cgit_print_pageheader(cgit_root_title, 0); |
52 | 55 | ||
53 | html("<table class='list nowrap'>"); | 56 | html("<table class='list nowrap'>"); |
54 | if (cgit_index_header) { | 57 | if (cgit_index_header) { |
55 | html("<tr class='nohover'><td colspan='5' class='include-block'>"); | 58 | htmlf("<tr class='nohover'><td colspan='%d' class='include-block'>", |
59 | columns); | ||
56 | html_include(cgit_index_header); | 60 | html_include(cgit_index_header); |
57 | html("</td></tr>"); | 61 | html("</td></tr>"); |
58 | } | 62 | } |
59 | html("<tr class='nohover'>" | 63 | html("<tr class='nohover'>" |
60 | "<th class='left'>Name</th>" | 64 | "<th class='left'>Name</th>" |
61 | "<th class='left'>Description</th>" | 65 | "<th class='left'>Description</th>" |
62 | "<th class='left'>Owner</th>" | 66 | "<th class='left'>Owner</th>" |
63 | "<th class='left'>Idle</th>" | 67 | "<th class='left'>Idle</th>"); |
64 | "<th>Links</th></tr>\n"); | 68 | if (cgit_enable_index_links) |
69 | html("<th>Links</th>"); | ||
70 | html("</tr>\n"); | ||
65 | 71 | ||
66 | for (i=0; i<cgit_repolist.count; i++) { | 72 | for (i=0; i<cgit_repolist.count; i++) { |
67 | cgit_repo = &cgit_repolist.repos[i]; | 73 | cgit_repo = &cgit_repolist.repos[i]; |
68 | if ((last_group == NULL && cgit_repo->group != NULL) || | 74 | if ((last_group == NULL && cgit_repo->group != NULL) || |
69 | (last_group != NULL && cgit_repo->group == NULL) || | 75 | (last_group != NULL && cgit_repo->group == NULL) || |
70 | (last_group != NULL && cgit_repo->group != NULL && | 76 | (last_group != NULL && cgit_repo->group != NULL && |
71 | strcmp(cgit_repo->group, last_group))) { | 77 | strcmp(cgit_repo->group, last_group))) { |
72 | html("<tr class='nohover'><td colspan='4' class='repogroup'>"); | 78 | htmlf("<tr class='nohover'><td colspan='%d' class='repogroup'>", |
79 | columns); | ||
73 | html_txt(cgit_repo->group); | 80 | html_txt(cgit_repo->group); |
74 | html("</td></tr>"); | 81 | html("</td></tr>"); |
75 | last_group = cgit_repo->group; | 82 | last_group = cgit_repo->group; |
76 | } | 83 | } |
77 | htmlf("<tr><td class='%s'>", | 84 | htmlf("<tr><td class='%s'>", |
78 | cgit_repo->group ? "sublevel-repo" : "toplevel-repo"); | 85 | cgit_repo->group ? "sublevel-repo" : "toplevel-repo"); |
79 | html_link_open(cgit_repourl(cgit_repo->url), NULL, NULL); | 86 | html_link_open(cgit_repourl(cgit_repo->url), NULL, NULL); |
80 | html_txt(cgit_repo->name); | 87 | html_txt(cgit_repo->name); |
81 | html_link_close(); | 88 | html_link_close(); |
82 | html("</td><td>"); | 89 | html("</td><td>"); |
83 | html_ntxt(cgit_max_repodesc_len, cgit_repo->desc); | 90 | html_ntxt(cgit_max_repodesc_len, cgit_repo->desc); |
84 | html("</td><td>"); | 91 | html("</td><td>"); |
85 | html_txt(cgit_repo->owner); | 92 | html_txt(cgit_repo->owner); |
86 | html("</td><td>"); | 93 | html("</td><td>"); |
87 | print_modtime(cgit_repo); | 94 | print_modtime(cgit_repo); |
88 | html("</td><td>"); | 95 | html("</td>"); |
89 | html_link_open(cgit_repourl(cgit_repo->url), | 96 | if (cgit_enable_index_links) { |
90 | NULL, "button"); | 97 | html("<td>"); |
91 | html("summary</a>"); | 98 | html_link_open(cgit_repourl(cgit_repo->url), |
92 | cgit_log_link("log", NULL, "button", NULL, NULL, NULL); | 99 | NULL, "button"); |
93 | cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); | 100 | html("summary</a>"); |
94 | html("</td></tr>\n"); | 101 | cgit_log_link("log", NULL, "button", NULL, NULL, NULL); |
102 | cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); | ||
103 | html("</td>"); | ||
104 | } | ||
105 | html("</tr>\n"); | ||
95 | } | 106 | } |
96 | html("</table>"); | 107 | html("</table>"); |
97 | cgit_print_docend(); | 108 | cgit_print_docend(); |
98 | } | 109 | } |