diff options
author | Jed Barber <jjbarber@y7mail.com> | 2021-02-14 00:11:29 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2021-02-14 00:11:29 +1100 |
commit | c2de6335092a4f5ad7a6a962eb7f91c0245e5e25 (patch) | |
tree | bd4ed0e6233c8a5a6ad55b05ec1adcdf892185cd | |
parent | bd6f5683f6cde4212364354b3139c1d521f40f39 (diff) |
-rw-r--r-- | cgit.c | 14 | ||||
-rw-r--r-- | cgit.h | 4 | ||||
-rw-r--r-- | ui-repolist.c | 40 |
3 files changed, 58 insertions, 0 deletions
@@ -52,6 +52,10 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va repo->desc = xstrdup(value); else if (!strcmp(name, "owner")) repo->owner = xstrdup(value); + else if (!strcmp(name, "language")) + repo->language = xstrdup(value); + else if (!strcmp(name, "license")) + repo->license = xstrdup(value); else if (!strcmp(name, "homepage")) repo->homepage = xstrdup(value); else if (!strcmp(name, "defbranch")) @@ -177,6 +181,10 @@ static void config_cb(const char *name, const char *value) ctx.cfg.enable_index_links = atoi(value); else if (!strcmp(name, "enable-index-owner")) ctx.cfg.enable_index_owner = atoi(value); + else if (!strcmp(name, "enable-index-license")) + ctx.cfg.enable_index_license = atoi(value); + else if (!strcmp(name, "enable-index-language")) + ctx.cfg.enable_index_language = atoi(value); else if (!strcmp(name, "enable-blame")) ctx.cfg.enable_blame = atoi(value); else if (!strcmp(name, "enable-commit-graph")) @@ -382,6 +390,8 @@ static void prepare_context(void) ctx.cfg.local_time = 0; ctx.cfg.enable_http_clone = 1; ctx.cfg.enable_index_owner = 1; + ctx.cfg.enable_index_language = 0; + ctx.cfg.enable_index_license = 0; ctx.cfg.enable_tree_linenumbers = 1; ctx.cfg.enable_git_config = 0; ctx.cfg.max_repo_count = 50; @@ -791,6 +801,10 @@ static void print_repo(FILE *f, struct cgit_repo *repo) fprintf(f, "repo.url=%s\n", repo->url); fprintf(f, "repo.name=%s\n", repo->name); fprintf(f, "repo.path=%s\n", repo->path); + if (repo->language) + fprintf(f, "repo.language=%s\n", repo->language); + if (repo->license) + fprintf(f, "repo.license=%s\n", repo->license); if (repo->owner) fprintf(f, "repo.owner=%s\n", repo->owner); if (repo->desc) { @@ -83,6 +83,8 @@ struct cgit_repo { char *path; char *desc; char *extra_head_content; + char *language; + char *license; char *owner; char *homepage; char *defbranch; @@ -231,6 +233,8 @@ struct cgit_config { int enable_http_clone; int enable_index_links; int enable_index_owner; + int enable_index_license; + int enable_index_language; int enable_blame; int enable_commit_graph; int enable_log_filecount; diff --git a/ui-repolist.c b/ui-repolist.c index 529a203..c12cb19 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -92,6 +92,10 @@ static int is_match(struct cgit_repo *repo) return 1; if (repo->desc && strcasestr(repo->desc, ctx.qry.search)) return 1; + if (repo->language && strcasestr(repo->language, ctx.qry.search)) + return 1; + if (repo->license && strcasestr(repo->license, ctx.qry.search)) + return 1; if (repo->owner && strcasestr(repo->owner, ctx.qry.search)) return 1; return 0; @@ -145,6 +149,10 @@ static void print_header(void) html("<tr class='nohover'>"); print_sort_header("Name", "name"); print_sort_header("Description", "desc"); + if (ctx.cfg.enable_index_language) + print_sort_header("Language", "language"); + if (ctx.cfg.enable_index_license) + print_sort_header("License", "license"); if (ctx.cfg.enable_index_owner) print_sort_header("Owner", "owner"); print_sort_header("Idle", "idle"); @@ -200,6 +208,22 @@ static int sort_desc(const void *a, const void *b) return cmp(r1->desc, r2->desc); } +static int sort_language(const void *a, const void *b) +{ + const struct cgit_repo *r1 = a; + const struct cgit_repo *r2 = b; + + return cmp(r1->language, r2->language); +} + +static int sort_license(const void *a, const void *b) +{ + const struct cgit_repo *r1 = a; + const struct cgit_repo *r2 = b; + + return cmp(r1->license, r2->license); +} + static int sort_owner(const void *a, const void *b) { const struct cgit_repo *r1 = a; @@ -244,6 +268,8 @@ struct sortcolumn { static const struct sortcolumn sortcolumn[] = { {"section", sort_section}, {"name", sort_name}, + {"language", sort_language}, + {"license", sort_license}, {"desc", sort_desc}, {"owner", sort_owner}, {"idle", sort_idle}, @@ -282,6 +308,10 @@ void cgit_print_repolist(void) ++columns; if (ctx.cfg.enable_index_owner) ++columns; + if (ctx.cfg.enable_index_license) + ++columns; + if (ctx.cfg.enable_index_language) + ++columns; ctx.page.title = ctx.cfg.root_title; cgit_print_http_headers(); @@ -330,6 +360,16 @@ void cgit_print_repolist(void) html("..."); html_link_close(); html("</td><td>"); + if (ctx.cfg.enable_index_language) { + if (ctx.repo->language) + html(ctx.repo->language); + html("</td><td>"); + } + if (ctx.cfg.enable_index_license) { + if (ctx.repo->license) + html(ctx.repo->license); + html("</td><td>"); + } if (ctx.cfg.enable_index_owner) { if (ctx.repo->owner_filter) { cgit_open_filter(ctx.repo->owner_filter); |