summaryrefslogtreecommitdiffabout
path: root/ui-repolist.c
Side-by-side diff
Diffstat (limited to 'ui-repolist.c') (more/less context) (show whitespace changes)
-rw-r--r--ui-repolist.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/ui-repolist.c b/ui-repolist.c
index 7c7aa9b..3ef2e99 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -138,2 +138,14 @@ static int cmp(const char *s1, const char *s2)
+static int sort_section(const void *a, const void *b)
+{
+ const struct cgit_repo *r1 = a;
+ const struct cgit_repo *r2 = b;
+ int result;
+
+ result = cmp(r1->section, r2->section);
+ if (!result)
+ result = cmp(r1->name, r2->name);
+ return result;
+}
+
static int sort_name(const void *a, const void *b)
@@ -180,2 +192,3 @@ struct sortcolumn {
struct sortcolumn sortcolumn[] = {
+ {"section", sort_section},
{"name", sort_name},
@@ -205,3 +218,4 @@ void cgit_print_repolist()
int i, columns = 4, hits = 0, header = 0;
- char *last_group = NULL;
+ char *last_section = NULL;
+ char *section;
int sorted = 0;
@@ -221,2 +235,4 @@ void cgit_print_repolist()
sorted = sort_repolist(ctx.qry.sort);
+ else
+ sort_repolist("section");
@@ -234,15 +250,18 @@ void cgit_print_repolist()
print_header(columns);
+ section = ctx.repo->section;
+ if (section && !strcmp(section, ""))
+ section = NULL;
if (!sorted &&
- ((last_group == NULL && ctx.repo->group != NULL) ||
- (last_group != NULL && ctx.repo->group == NULL) ||
- (last_group != NULL && ctx.repo->group != NULL &&
- strcmp(ctx.repo->group, last_group)))) {
- htmlf("<tr class='nohover'><td colspan='%d' class='repogroup'>",
+ ((last_section == NULL && section != NULL) ||
+ (last_section != NULL && section == NULL) ||
+ (last_section != NULL && section != NULL &&
+ strcmp(section, last_section)))) {
+ htmlf("<tr class='nohover'><td colspan='%d' class='reposection'>",
columns);
- html_txt(ctx.repo->group);
+ html_txt(section);
html("</td></tr>");
- last_group = ctx.repo->group;
+ last_section = section;
}
htmlf("<tr><td class='%s'>",
- !sorted && ctx.repo->group ? "sublevel-repo" : "toplevel-repo");
+ !sorted && section ? "sublevel-repo" : "toplevel-repo");
cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL);