aboutsummaryrefslogtreecommitdiffstats
path: root/ui-repolist.c
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2016-09-12 22:54:08 -0500
committerJohn Keeping <john@keeping.me.uk>2016-10-01 11:51:07 +0100
commit1a66e7f3c15bf8d0d5d1b198c6674911a213779e (patch)
tree23f5d14af44ad63e1a9ad8c615fe622a0d4b52fe /ui-repolist.c
parent84b158abe04ca37eb6e3038d3b63a9518714b66d (diff)
downloadcgit-1a66e7f3c15bf8d0d5d1b198c6674911a213779e.tar.gz
cgit-1a66e7f3c15bf8d0d5d1b198c6674911a213779e.tar.bz2
cgit-1a66e7f3c15bf8d0d5d1b198c6674911a213779e.zip
ui-repolist: Allow sections to be collapsiblejk/collapsible-sections
The index page can be difficult to navigate for really large git servers. This change allows a configuration like: section-collapse=people section-collapse=tests And an index page would only display the "people" and "tests" section headers entries (not their repos) with a hyperlink that can be used to drill down into each section. Additionally the boolean logic around displaying sections in ui-repolist.c was simplified to eliminate an impossible condition. Signed-off-by: Andy Doan <andy.doan@linaro.org> Reviewed-by: John Keeping <john@keeping.me.uk> Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'ui-repolist.c')
-rw-r--r--ui-repolist.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/ui-repolist.c b/ui-repolist.c
index 3f967a8..e9676b8 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -188,10 +188,16 @@ static int sort_section(const void *a, const void *b)
{
const struct cgit_repo *r1 = a;
const struct cgit_repo *r2 = b;
+ const char *s1 = "";
+ const char *s2 = "";
int result;
time_t t;
- result = cmp(r1->section, r2->section);
+ if (r1->section)
+ s1 = r1->section->name;
+ if (r2->section)
+ s2 = r2->section->name;
+ result = cmp(s1, s2);
if (!result) {
if (!strcmp(ctx.cfg.repository_sort, "age")) {
// get_repo_modtime caches the value in r->mtime, so we don't
@@ -273,8 +279,8 @@ static int sort_repolist(char *field)
void cgit_print_repolist(void)
{
int i, columns = 3, hits = 0, header = 0;
- char *last_section = NULL;
- char *section;
+ struct cgit_section *last_section = NULL;
+ struct cgit_section *section;
int sorted = 0;
if (!any_repos_visible()) {
@@ -294,12 +300,10 @@ void cgit_print_repolist(void)
if (ctx.cfg.index_header)
html_include(ctx.cfg.index_header);
-
if (ctx.qry.sort)
sorted = sort_repolist(ctx.qry.sort);
else if (ctx.cfg.section_sort)
sort_repolist("section");
-
html("<table summary='repository list' class='list nowrap'>");
for (i = 0; i < cgit_repolist.count; i++) {
ctx.repo = &cgit_repolist.repos[i];
@@ -313,23 +317,22 @@ void cgit_print_repolist(void)
if (!header++)
print_header();
section = ctx.repo->section;
- if (section && !strcmp(section, ""))
+ if (section && !strcmp(section->name, ""))
section = NULL;
- if (!sorted &&
- ((last_section == NULL && section != NULL) ||
- (last_section != NULL && section == NULL) ||
- (last_section != NULL && section != NULL &&
- strcmp(section, last_section)))) {
+ if (!sorted && section && last_section != section ) {
htmlf("<tr class='nohover'><td colspan='%d' class='reposection'>",
columns);
html("<a href='");
- html_attr(section);
+ html_attr(section->name);
html("'>");
- html_txt(section);
+ html_txt(section->name);
html("</a>");
html("</td></tr>");
- last_section = section;
}
+ last_section = section;
+ if (section && section->collapse && !strstr(ctx.qry.url, section->name))
+ continue;
+
htmlf("<tr><td class='%s'>",
!sorted && section ? "sublevel-repo" : "toplevel-repo");
cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL);