blob: ce7c8cdb6086a61cee0667ec22d6041087bbf57a [file] [log] [blame]
Lars Hjemli74620f12006-12-11 16:48:03 +01001/* ui-repolist.c: functions for generating the repolist page
2 *
Lukas Fleischerf7f26f82014-01-08 15:10:49 +01003 * Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com>
Lars Hjemli74620f12006-12-11 16:48:03 +01004 *
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
7 */
8
Lars Hjemlib1f9b9c2008-02-23 22:45:33 +01009#include "cgit.h"
John Keeping8f208792013-04-06 11:37:59 +010010#include "ui-repolist.h"
Lars Hjemlib1f9b9c2008-02-23 22:45:33 +010011#include "html.h"
Lars Hjemlia4d1ca12008-03-24 16:50:57 +010012#include "ui-shared.h"
Andy Doan47f39582016-09-29 16:59:54 -050013#include "run-command.h"
14
15
16struct allowed_repos {
17 const char *name;
18 struct allowed_repos *next;
19};
20
Lars Hjemli57f6a8b2007-05-22 23:25:25 +020021
Christian Hesseccba7eb2019-01-02 17:25:01 +010022static time_t read_agefile(const char *path)
Lars Hjemli57f6a8b2007-05-22 23:25:25 +020023{
Lars Hjemlie16f1782009-08-18 17:17:41 +020024 time_t result;
25 size_t size;
Christian Hesse6edc84b2016-01-13 00:45:03 +010026 char *buf = NULL;
Christian Hesse17838ec2014-12-19 00:28:34 -070027 struct strbuf date_buf = STRBUF_INIT;
Lars Hjemli57f6a8b2007-05-22 23:25:25 +020028
Christian Hesse7ef1a472015-10-09 14:55:47 +020029 if (readfile(path, &buf, &size)) {
30 free(buf);
Christian Hesse583aa5d2019-11-22 11:09:50 +010031 return 0;
Christian Hesse7ef1a472015-10-09 14:55:47 +020032 }
Lars Hjemlie16f1782009-08-18 17:17:41 +020033
Christian Hesse17838ec2014-12-19 00:28:34 -070034 if (parse_date(buf, &date_buf) == 0)
35 result = strtoul(date_buf.buf, NULL, 10);
Lars Hjemli57f6a8b2007-05-22 23:25:25 +020036 else
Lars Hjemlie16f1782009-08-18 17:17:41 +020037 result = 0;
38 free(buf);
Christian Hesse17838ec2014-12-19 00:28:34 -070039 strbuf_release(&date_buf);
Lars Hjemlie16f1782009-08-18 17:17:41 +020040 return result;
Lars Hjemli57f6a8b2007-05-22 23:25:25 +020041}
42
Lars Hjemlicbac02c2008-11-29 13:33:02 +010043static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime)
Lars Hjemli57f6a8b2007-05-22 23:25:25 +020044{
John Keepingfb3655d2013-04-06 10:28:57 +010045 struct strbuf path = STRBUF_INIT;
Lars Hjemli57f6a8b2007-05-22 23:25:25 +020046 struct stat s;
Lars Hjemli88131702008-11-29 16:46:37 +010047 struct cgit_repo *r = (struct cgit_repo *)repo;
Lars Hjemli57f6a8b2007-05-22 23:25:25 +020048
Lars Hjemli88131702008-11-29 16:46:37 +010049 if (repo->mtime != -1) {
50 *mtime = repo->mtime;
51 return 1;
52 }
John Keepingfb3655d2013-04-06 10:28:57 +010053 strbuf_addf(&path, "%s/%s", repo->path, ctx.cfg.agefile);
54 if (stat(path.buf, &s) == 0) {
55 *mtime = read_agefile(path.buf);
Ferry Hubertse52a5222012-10-09 13:09:58 +020056 if (*mtime) {
57 r->mtime = *mtime;
John Keepingfb3655d2013-04-06 10:28:57 +010058 goto end;
Ferry Hubertse52a5222012-10-09 13:09:58 +020059 }
Lars Hjemli57f6a8b2007-05-22 23:25:25 +020060 }
61
John Keepingfb3655d2013-04-06 10:28:57 +010062 strbuf_reset(&path);
63 strbuf_addf(&path, "%s/refs/heads/%s", repo->path,
64 repo->defbranch ? repo->defbranch : "master");
65 if (stat(path.buf, &s) == 0) {
Lars Hjemlicbac02c2008-11-29 13:33:02 +010066 *mtime = s.st_mtime;
Ferry Huberts21e0e0b2011-05-13 23:09:34 +020067 r->mtime = *mtime;
John Keepingfb3655d2013-04-06 10:28:57 +010068 goto end;
Ferry Huberts21e0e0b2011-05-13 23:09:34 +020069 }
Lars Hjemli88131702008-11-29 16:46:37 +010070
John Keepingfb3655d2013-04-06 10:28:57 +010071 strbuf_reset(&path);
72 strbuf_addf(&path, "%s/%s", repo->path, "packed-refs");
73 if (stat(path.buf, &s) == 0) {
Ferry Huberts21e0e0b2011-05-13 23:09:34 +020074 *mtime = s.st_mtime;
75 r->mtime = *mtime;
John Keepingfb3655d2013-04-06 10:28:57 +010076 goto end;
Ferry Huberts21e0e0b2011-05-13 23:09:34 +020077 }
78
79 *mtime = 0;
Lars Hjemli88131702008-11-29 16:46:37 +010080 r->mtime = *mtime;
John Keepingfb3655d2013-04-06 10:28:57 +010081end:
82 strbuf_release(&path);
Lars Hjemli88131702008-11-29 16:46:37 +010083 return (r->mtime != 0);
Lars Hjemlicbac02c2008-11-29 13:33:02 +010084}
85
86static void print_modtime(struct cgit_repo *repo)
87{
88 time_t t;
89 if (get_repo_modtime(repo, &t))
John Keepingf2a901d2016-01-19 19:33:05 +000090 cgit_print_age(t, 0, -1);
Lars Hjemli57f6a8b2007-05-22 23:25:25 +020091}
Lars Hjemli74620f12006-12-11 16:48:03 +010092
Lukas Fleischerbafab422013-03-04 08:52:33 +010093static int is_match(struct cgit_repo *repo)
Lars Hjemli74620f12006-12-11 16:48:03 +010094{
Lars Hjemli536b0542008-04-13 11:57:10 +020095 if (!ctx.qry.search)
96 return 1;
Lars Hjemli28d781f2008-04-13 12:42:27 +020097 if (repo->url && strcasestr(repo->url, ctx.qry.search))
Lars Hjemli536b0542008-04-13 11:57:10 +020098 return 1;
Lars Hjemli28d781f2008-04-13 12:42:27 +020099 if (repo->name && strcasestr(repo->name, ctx.qry.search))
Lars Hjemli536b0542008-04-13 11:57:10 +0200100 return 1;
Lars Hjemli28d781f2008-04-13 12:42:27 +0200101 if (repo->desc && strcasestr(repo->desc, ctx.qry.search))
Lars Hjemli536b0542008-04-13 11:57:10 +0200102 return 1;
Lars Hjemli28d781f2008-04-13 12:42:27 +0200103 if (repo->owner && strcasestr(repo->owner, ctx.qry.search))
Lars Hjemli536b0542008-04-13 11:57:10 +0200104 return 1;
105 return 0;
106}
Lars Hjemli74620f12006-12-11 16:48:03 +0100107
Andy Doan47f39582016-09-29 16:59:54 -0500108static struct allowed_repos* find_allowed_repos(void)
109{
110 struct strbuf buf = STRBUF_INIT;
111 struct child_process cp = CHILD_PROCESS_INIT;
112 const char *argv[] = {ctx.cfg.allowed_repos_cmd, NULL};
113 char *result, *token;
114 struct allowed_repos *allowed = NULL, *prev=NULL;
115
116 cp.argv = argv;
117 cp.no_stdin = 1;
118
119 if (!capture_command(&cp, &buf, 1024)) {
120 strbuf_trim(&buf);
121 result = strbuf_detach(&buf, NULL);
122
123 token = strtok(result, "\n");
124 while( token != NULL ) {
125 if (!prev) {
126 allowed = xmalloc(sizeof(*allowed));
127 prev = allowed;
128 } else {
129 prev->next = xmalloc(sizeof(*allowed));
130 prev = prev->next;
131 }
132 prev->name = token;
133 prev->next = NULL;
134 token = strtok(NULL, "\n");
135 }
136 }
137 return allowed;
138}
139
Lukas Fleischerbafab422013-03-04 08:52:33 +0100140static int is_in_url(struct cgit_repo *repo)
Lars Hjemlidd80ef52008-09-14 20:18:10 +0200141{
142 if (!ctx.qry.url)
143 return 1;
Christian Hesse79c985e2014-05-29 17:35:46 +0200144 if (repo->url && starts_with(repo->url, ctx.qry.url))
Lars Hjemlidd80ef52008-09-14 20:18:10 +0200145 return 1;
146 return 0;
147}
148
Andy Doan47f39582016-09-29 16:59:54 -0500149static int is_visible(struct allowed_repos *allowed, struct cgit_repo *repo)
Peter Colberga4014d02015-12-08 12:53:08 -0500150{
151 if (repo->hide || repo->ignore)
152 return 0;
153 if (!(is_match(repo) && is_in_url(repo)))
154 return 0;
Andy Doan47f39582016-09-29 16:59:54 -0500155 if (ctx.cfg.allowed_repos_cmd) {
156 while(allowed) {
157 if (!strcmp(repo->url, allowed->name))
158 return 1;
159 allowed = allowed->next;
160 }
161 return 0;
162 }
Peter Colberga4014d02015-12-08 12:53:08 -0500163 return 1;
164}
165
Andy Doan47f39582016-09-29 16:59:54 -0500166static int any_repos_visible(struct allowed_repos *allowed)
Peter Colberg9abe4a22015-12-08 12:53:09 -0500167{
168 int i;
Peter Colberg9abe4a22015-12-08 12:53:09 -0500169 for (i = 0; i < cgit_repolist.count; i++) {
Andy Doan47f39582016-09-29 16:59:54 -0500170 if (is_visible(allowed, &cgit_repolist.repos[i]))
Peter Colberg9abe4a22015-12-08 12:53:09 -0500171 return 1;
172 }
173 return 0;
174}
175
Lukas Fleischerbafab422013-03-04 08:52:33 +0100176static void print_sort_header(const char *title, const char *sort)
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100177{
Christian Hesse51338f72015-10-09 14:55:48 +0200178 char *currenturl = cgit_currenturl();
John Keeping1de65912014-01-12 19:45:17 +0000179 html("<th class='left'><a href='");
Christian Hesse51338f72015-10-09 14:55:48 +0200180 html_attr(currenturl);
John Keeping1de65912014-01-12 19:45:17 +0000181 htmlf("?s=%s", sort);
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100182 if (ctx.qry.search) {
William Bellc366bd62012-10-09 20:45:58 +0200183 html("&amp;q=");
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100184 html_url_arg(ctx.qry.search);
185 }
186 htmlf("'>%s</a></th>", title);
Christian Hesse51338f72015-10-09 14:55:48 +0200187 free(currenturl);
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100188}
189
John Keepinge3d3fff2015-03-08 16:32:16 +0000190static void print_header(void)
Lars Hjemli536b0542008-04-13 11:57:10 +0200191{
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100192 html("<tr class='nohover'>");
193 print_sort_header("Name", "name");
194 print_sort_header("Description", "desc");
Florian Pritzb1e172a2013-02-01 10:59:13 +0100195 if (ctx.cfg.enable_index_owner)
196 print_sort_header("Owner", "owner");
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100197 print_sort_header("Idle", "idle");
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100198 if (ctx.cfg.enable_index_links)
Lars Hjemli931fc6d2008-04-13 10:57:11 +0200199 html("<th class='left'>Links</th>");
Lars Hjemli0d05bca2007-06-19 00:56:40 +0200200 html("</tr>\n");
Lars Hjemli536b0542008-04-13 11:57:10 +0200201}
Lars Hjemli74620f12006-12-11 16:48:03 +0100202
Lars Hjemlic6078b82008-05-03 10:54:39 +0200203
Lukas Fleischerbafab422013-03-04 08:52:33 +0100204static void print_pager(int items, int pagelen, char *search, char *sort)
Lars Hjemlic6078b82008-05-03 10:54:39 +0200205{
Jamie Couture4675b912012-10-08 12:49:34 -0400206 int i, ofs;
207 char *class = NULL;
Lukas Fleischerb60e6bf2013-03-07 08:56:22 +0100208 html("<ul class='pager'>");
Jason A. Donenfeldbdae1d82013-03-03 23:21:33 -0500209 for (i = 0, ofs = 0; ofs < items; i++, ofs = i * pagelen) {
Jamie Couture4675b912012-10-08 12:49:34 -0400210 class = (ctx.qry.ofs == ofs) ? "current" : NULL;
Lukas Fleischerb60e6bf2013-03-07 08:56:22 +0100211 html("<li>");
Lukas Fleischer53bc7472013-03-03 16:04:29 +0100212 cgit_index_link(fmt("[%d]", i + 1), fmt("Page %d", i + 1),
Jason A. Donenfeld2e4a41e2015-03-03 17:23:40 +0100213 class, search, sort, ofs, 0);
Lukas Fleischerb60e6bf2013-03-07 08:56:22 +0100214 html("</li>");
Jamie Couture4675b912012-10-08 12:49:34 -0400215 }
Lukas Fleischerb60e6bf2013-03-07 08:56:22 +0100216 html("</ul>");
Lars Hjemlic6078b82008-05-03 10:54:39 +0200217}
218
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100219static int cmp(const char *s1, const char *s2)
220{
Jason A. Donenfeld184c5652012-07-12 19:13:39 +0200221 if (s1 && s2) {
222 if (ctx.cfg.case_sensitive_sort)
223 return strcmp(s1, s2);
224 else
225 return strcasecmp(s1, s2);
226 }
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100227 if (s1 && !s2)
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100228 return -1;
Lars Hjemli54272e62008-11-29 14:27:35 +0100229 if (s2 && !s1)
230 return 1;
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100231 return 0;
232}
233
234static int sort_name(const void *a, const void *b)
235{
236 const struct cgit_repo *r1 = a;
237 const struct cgit_repo *r2 = b;
238
239 return cmp(r1->name, r2->name);
240}
241
242static int sort_desc(const void *a, const void *b)
243{
244 const struct cgit_repo *r1 = a;
245 const struct cgit_repo *r2 = b;
246
247 return cmp(r1->desc, r2->desc);
248}
249
250static int sort_owner(const void *a, const void *b)
251{
252 const struct cgit_repo *r1 = a;
253 const struct cgit_repo *r2 = b;
254
255 return cmp(r1->owner, r2->owner);
256}
257
258static int sort_idle(const void *a, const void *b)
Benjamin Closed71c0c72008-11-25 06:25:35 -0800259{
260 const struct cgit_repo *r1 = a;
261 const struct cgit_repo *r2 = b;
Benjamin Closed71c0c72008-11-25 06:25:35 -0800262 time_t t1, t2;
Benjamin Closed71c0c72008-11-25 06:25:35 -0800263
Lars Hjemlicbac02c2008-11-29 13:33:02 +0100264 t1 = t2 = 0;
265 get_repo_modtime(r1, &t1);
266 get_repo_modtime(r2, &t2);
267 return t2 - t1;
Benjamin Closed71c0c72008-11-25 06:25:35 -0800268}
269
Jason A. Donenfeld87c47482017-03-30 13:19:50 +0200270static int sort_section(const void *a, const void *b)
271{
272 const struct cgit_repo *r1 = a;
273 const struct cgit_repo *r2 = b;
274 int result;
Jason A. Donenfeld87c47482017-03-30 13:19:50 +0200275
276 result = cmp(r1->section, r2->section);
277 if (!result) {
278 if (!strcmp(ctx.cfg.repository_sort, "age"))
279 result = sort_idle(r1, r2);
280 if (!result)
281 result = cmp(r1->name, r2->name);
282 }
283 return result;
284}
285
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100286struct sortcolumn {
287 const char *name;
288 int (*fn)(const void *a, const void *b);
289};
290
John Keepingad746692015-03-08 16:32:21 +0000291static const struct sortcolumn sortcolumn[] = {
Lars Hjemli63816ec2009-08-23 23:09:31 +0200292 {"section", sort_section},
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100293 {"name", sort_name},
294 {"desc", sort_desc},
295 {"owner", sort_owner},
296 {"idle", sort_idle},
297 {NULL, NULL}
298};
299
Lukas Fleischerbafab422013-03-04 08:52:33 +0100300static int sort_repolist(char *field)
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100301{
John Keepingad746692015-03-08 16:32:21 +0000302 const struct sortcolumn *column;
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100303
304 for (column = &sortcolumn[0]; column->name; column++) {
305 if (strcmp(field, column->name))
306 continue;
307 qsort(cgit_repolist.repos, cgit_repolist.count,
308 sizeof(struct cgit_repo), column->fn);
309 return 1;
310 }
311 return 0;
312}
313
314
John Keepinge3d3fff2015-03-08 16:32:16 +0000315void cgit_print_repolist(void)
Lars Hjemli536b0542008-04-13 11:57:10 +0200316{
Florian Pritzb1e172a2013-02-01 10:59:13 +0100317 int i, columns = 3, hits = 0, header = 0;
Lars Hjemlie7af0022009-08-23 22:58:39 +0200318 char *last_section = NULL;
Lars Hjemlie01229c2009-08-24 07:42:03 +0200319 char *section;
Christian Hessec1773792016-10-07 15:08:53 +0200320 char *repourl;
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100321 int sorted = 0;
Andy Doan47f39582016-09-29 16:59:54 -0500322 struct allowed_repos * allowed = NULL;
Lars Hjemli536b0542008-04-13 11:57:10 +0200323
Andy Doan47f39582016-09-29 16:59:54 -0500324 if (ctx.cfg.allowed_repos_cmd)
325 allowed = find_allowed_repos();
326
327 if (!any_repos_visible(allowed)) {
Peter Colberg9abe4a22015-12-08 12:53:09 -0500328 cgit_print_error_page(404, "Not found", "No repositories found");
329 return;
330 }
331
Lars Hjemli536b0542008-04-13 11:57:10 +0200332 if (ctx.cfg.enable_index_links)
Florian Pritzb1e172a2013-02-01 10:59:13 +0100333 ++columns;
334 if (ctx.cfg.enable_index_owner)
335 ++columns;
Lars Hjemli536b0542008-04-13 11:57:10 +0200336
337 ctx.page.title = ctx.cfg.root_title;
Lukas Fleischerf60ffa12014-01-15 21:53:15 +0100338 cgit_print_http_headers();
339 cgit_print_docstart();
340 cgit_print_pageheader();
Lars Hjemli536b0542008-04-13 11:57:10 +0200341
Jason A. Donenfeldbdae1d82013-03-03 23:21:33 -0500342 if (ctx.qry.sort)
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100343 sorted = sort_repolist(ctx.qry.sort);
Tobias Bieniek7a4e7c82012-10-09 20:53:29 +0200344 else if (ctx.cfg.section_sort)
Lars Hjemli63816ec2009-08-23 23:09:31 +0200345 sort_repolist("section");
Benjamin Closed71c0c72008-11-25 06:25:35 -0800346
Lars Hjemli536b0542008-04-13 11:57:10 +0200347 html("<table summary='repository list' class='list nowrap'>");
Lukas Fleischer53bc7472013-03-03 16:04:29 +0100348 for (i = 0; i < cgit_repolist.count; i++) {
Lars Hjemlid1f3bbe2008-02-16 13:56:09 +0100349 ctx.repo = &cgit_repolist.repos[i];
Andy Doan47f39582016-09-29 16:59:54 -0500350 if (!is_visible(allowed, ctx.repo))
Lars Hjemli536b0542008-04-13 11:57:10 +0200351 continue;
Lars Hjemlic6078b82008-05-03 10:54:39 +0200352 hits++;
353 if (hits <= ctx.qry.ofs)
354 continue;
355 if (hits > ctx.qry.ofs + ctx.cfg.max_repo_count)
356 continue;
Lars Hjemli536b0542008-04-13 11:57:10 +0200357 if (!header++)
Florian Pritzb1e172a2013-02-01 10:59:13 +0100358 print_header();
Lars Hjemlie01229c2009-08-24 07:42:03 +0200359 section = ctx.repo->section;
360 if (section && !strcmp(section, ""))
361 section = NULL;
Lars Hjemlif250c1c2008-11-29 14:08:51 +0100362 if (!sorted &&
Lars Hjemlie01229c2009-08-24 07:42:03 +0200363 ((last_section == NULL && section != NULL) ||
364 (last_section != NULL && section == NULL) ||
365 (last_section != NULL && section != NULL &&
366 strcmp(section, last_section)))) {
Andy Doan4f12b702016-10-13 15:01:09 -0500367 htmlf("<tr id='%s' class='nohover reposection'><td colspan='%d' class='reposection'>",
368 section, columns);
Lars Hjemlie01229c2009-08-24 07:42:03 +0200369 html_txt(section);
Lars Hjemli5877c492007-05-18 22:48:22 +0200370 html("</td></tr>");
Lars Hjemlie01229c2009-08-24 07:42:03 +0200371 last_section = section;
Lars Hjemli5877c492007-05-18 22:48:22 +0200372 }
Lars Hjemli0b8b6a32007-05-21 00:14:28 +0200373 htmlf("<tr><td class='%s'>",
Lars Hjemlie01229c2009-08-24 07:42:03 +0200374 !sorted && section ? "sublevel-repo" : "toplevel-repo");
Lars Hjemli49ecbbd2008-10-05 17:16:36 +0200375 cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL);
Lars Hjemli74620f12006-12-11 16:48:03 +0100376 html("</td><td>");
Christian Hessec1773792016-10-07 15:08:53 +0200377 repourl = cgit_repourl(ctx.repo->url);
378 html_link_open(repourl, NULL, NULL);
379 free(repourl);
Jeff Smith70787252017-10-01 23:39:05 -0500380 if (html_ntxt(ctx.repo->desc, ctx.cfg.max_repodesc_len) < 0)
381 html("...");
Lars Hjemlie9a70422008-04-14 22:23:48 +0200382 html_link_close();
Lars Hjemli74620f12006-12-11 16:48:03 +0100383 html("</td><td>");
Florian Pritzb1e172a2013-02-01 10:59:13 +0100384 if (ctx.cfg.enable_index_owner) {
Chris Burroughs96ceb9a2014-08-04 09:23:08 -0400385 if (ctx.repo->owner_filter) {
386 cgit_open_filter(ctx.repo->owner_filter);
387 html_txt(ctx.repo->owner);
388 cgit_close_filter(ctx.repo->owner_filter);
389 } else {
Christian Hesse7fea5852016-10-10 20:17:51 +0200390 char *currenturl = cgit_currenturl();
Chris Burroughs96ceb9a2014-08-04 09:23:08 -0400391 html("<a href='");
Christian Hesse7fea5852016-10-10 20:17:51 +0200392 html_attr(currenturl);
Jason A. Donenfelde14eee92015-03-03 16:53:11 +0100393 html("?q=");
Chris Burroughs96ceb9a2014-08-04 09:23:08 -0400394 html_url_arg(ctx.repo->owner);
395 html("'>");
396 html_txt(ctx.repo->owner);
397 html("</a>");
Christian Hesse7fea5852016-10-10 20:17:51 +0200398 free(currenturl);
Chris Burroughs96ceb9a2014-08-04 09:23:08 -0400399 }
Florian Pritzb1e172a2013-02-01 10:59:13 +0100400 html("</td><td>");
401 }
Lars Hjemlid1f3bbe2008-02-16 13:56:09 +0100402 print_modtime(ctx.repo);
Lars Hjemli0d05bca2007-06-19 00:56:40 +0200403 html("</td>");
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100404 if (ctx.cfg.enable_index_links) {
Lars Hjemli0d05bca2007-06-19 00:56:40 +0200405 html("<td>");
Lars Hjemli49ecbbd2008-10-05 17:16:36 +0200406 cgit_summary_link("summary", NULL, "button", NULL);
Lars Hjemli51140312007-11-03 10:42:37 +0100407 cgit_log_link("log", NULL, "button", NULL, NULL, NULL,
John Keeping30304d82015-08-12 15:55:28 +0100408 0, NULL, NULL, ctx.qry.showmsg, 0);
Lars Hjemli0d05bca2007-06-19 00:56:40 +0200409 cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL);
410 html("</td>");
411 }
412 html("</tr>\n");
Lars Hjemli74620f12006-12-11 16:48:03 +0100413 }
Lars Hjemli74620f12006-12-11 16:48:03 +0100414 html("</table>");
Peter Colberg9abe4a22015-12-08 12:53:09 -0500415 if (hits > ctx.cfg.max_repo_count)
Tobias Grimm7530d942011-07-31 02:44:05 +0200416 print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search, ctx.qry.sort);
Lars Hjemli74620f12006-12-11 16:48:03 +0100417 cgit_print_docend();
418}
Lars Hjemlic6431a72008-04-29 01:06:30 +0200419
John Keepinge3d3fff2015-03-08 16:32:16 +0000420void cgit_print_site_readme(void)
Lars Hjemlic6431a72008-04-29 01:06:30 +0200421{
John Keeping51d91762015-08-14 12:47:12 +0100422 cgit_print_layout_start();
Lars Hjemli537c05f2009-08-09 13:27:21 +0200423 if (!ctx.cfg.root_readme)
John Keeping51d91762015-08-14 12:47:12 +0100424 goto done;
Jason A. Donenfeld800380d2014-01-13 03:56:50 +0100425 cgit_open_filter(ctx.cfg.about_filter, ctx.cfg.root_readme);
Lars Hjemli537c05f2009-08-09 13:27:21 +0200426 html_include(ctx.cfg.root_readme);
Jason A. Donenfeld800380d2014-01-13 03:56:50 +0100427 cgit_close_filter(ctx.cfg.about_filter);
John Keeping51d91762015-08-14 12:47:12 +0100428done:
429 cgit_print_layout_end();
Lars Hjemlic6431a72008-04-29 01:06:30 +0200430}