On Sun, Aug 07, 2016 at 02:33:41PM -0500, Andy Doan wrote:
> This is a rough work-in-progress, but I wanted to get our take on whether
> or not you'd be interested in this type of functionality:
> 
> 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 "test" section
> headers entries (not their repos) with a hyperlink that can be used to
> drill down into each section.

My initial thought is that the name is wrong, when I saw the summary I
assumed it would be about adding script to allow sections to be
dynamically expanded/collapsed.  I can't immediately think of a better
name, though.

I also wonder why this takes a list of sections rather than a global
boolean that applies to all sections.  That may be because I tend to use
section-from-path though.

Overall, the implementation seems remarkably simple (and the change to
make section titles into links should probably be a separate patch) and
I think it would be reasonable to do something like this.  But I do
wonder if a global boolean would make more sense given the range of ways
it is possible to configure sections.  Do you have a use case that
requires only some sections to have their contents hidden in the main
index?

> Signed-off-by: Andy Doan <[email protected]>
> ---
>  cgit.c        | 2 ++
>  cgit.h        | 1 +
>  cgitrc.5.txt  | 5 +++++
>  ui-repolist.c | 4 +++-
>  4 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/cgit.c b/cgit.c
> index 9427c4a..abecc64 100644
> --- a/cgit.c
> +++ b/cgit.c
> @@ -238,6 +238,8 @@ static void config_cb(const char *name, const char *value)
>                       scan_tree(expand_macros(value), repo_config);
>       else if (!strcmp(name, "scan-hidden-path"))
>               ctx.cfg.scan_hidden_path = atoi(value);
> +     else if (!strcmp(name, "section-collapse"))
> +             string_list_insert(&ctx.cfg.section_collapse, xstrdup(value));
>       else if (!strcmp(name, "section-from-path"))
>               ctx.cfg.section_from_path = atoi(value);
>       else if (!strcmp(name, "repository-sort"))
> diff --git a/cgit.h b/cgit.h
> index 325432b..5c654be 100644
> --- a/cgit.h
> +++ b/cgit.h
> @@ -251,6 +251,7 @@ struct cgit_config {
>       int renamelimit;
>       int remove_suffix;
>       int scan_hidden_path;
> +     struct string_list section_collapse;
>       int section_from_path;
>       int snapshots;
>       int section_sort;
> diff --git a/cgitrc.5.txt b/cgitrc.5.txt
> index 9fcf445..2762657 100644
> --- a/cgitrc.5.txt
> +++ b/cgitrc.5.txt
> @@ -404,6 +404,11 @@ section::
>       after this option will inherit the current section name. Default value:
>       none.
> 
> +section-collapse::
> +     Name of a section to "collapse" and not display on the index page.
> +     Multiple config entries can be specified and each one will be
> +     collapsed.
> +
>  section-sort::
>       Flag which, when set to "1", will sort the sections on the repository
>       listing by name. Set this flag to "0" if the order in the cgitrc file 
> should
> diff --git a/ui-repolist.c b/ui-repolist.c
> index 30915df..330f749 100644
> --- a/ui-repolist.c
> +++ b/ui-repolist.c
> @@ -322,10 +322,12 @@ void cgit_print_repolist(void)
>                    strcmp(section, last_section)))) {
>                       htmlf("<tr class='nohover'><td colspan='%d' 
> class='reposection'>",
>                             columns);
> -                     html_txt(section);
> +                     htmlf("<a href='%s'>%s</a>", section, section);
>                       html("</td></tr>");
>                       last_section = section;
>               }
> +             if (section && 
> string_list_has_string(&ctx.cfg.section_collapse, section))
> +                     continue;
>               htmlf("<tr><td class='%s'>",
>                     !sorted && section ? "sublevel-repo" : "toplevel-repo");
>               cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL);
> --
> 2.7.4
> 
> _______________________________________________
> CGit mailing list
> [email protected]
> http://lists.zx2c4.com/mailman/listinfo/cgit
_______________________________________________
CGit mailing list
[email protected]
http://lists.zx2c4.com/mailman/listinfo/cgit

Reply via email to