From mboxrd@z Thu Jan 1 00:00:00 1970 From: petr.vorel at gmail.com (Petr Vorel) Date: Tue, 21 Feb 2017 00:36:04 +0100 Subject: [PATCH v7 1/1] ui-shared: allow to split the repository link Message-ID: <20170220233604.19578-1-petr.vorel@gmail.com> Teach cgit split the repository link in the top of repository "summary" view. This emulates the same behaviour as it's in gitweb. This behaviour is not implemented for repositories which have "repo.name" set different than "repo.url". Signed-off-by: Petr Vorel Cc: "Jason A. Donenfeld" Cc: John Keeping Reviewed-by: John Keeping --- Thanks for your review John. Are we there yet? :-) Changes v6->v7: * Remove redundant '*' * Add Reviewed-by --- cgitrc.5.txt | 4 +++- ui-shared.c | 27 ++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 9fcf445..500b7ee 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -604,7 +604,9 @@ repo.source-filter:: repo.url:: The relative url used to access the repository. This must be the first - setting specified for each repo. Default value: none. + setting specified for each repo. Unless repo.url is different from + repo.name, cgit splits the repository link in the top of repository + "summary" view. Default value: none. REPOSITORY-SPECIFIC CGITRC FILE diff --git a/ui-shared.c b/ui-shared.c index 2e4fcd9..e4f956d 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -936,7 +936,32 @@ static void print_header(void) if (ctx.repo) { cgit_index_link("index", NULL, NULL, NULL, NULL, 0, 1); html(" : "); - cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL); + + /* + * NOTE: If repo.name and repo.url are different, we don't split link as + * it wouldn't make sense to split the path. + */ + if (!strcmp(ctx.repo->name, ctx.repo->url)) { + char *name = ctx.repo->name; + char *start = name; + for (;;) { + char *delim = strchr(start, '/'); + if (delim) + *delim = '\0'; + + html_link_open(cgit_repourl(name), NULL, NULL); + html_ntxt(strlen(start), start); + html_link_close(); + + if (!delim) + break; + *delim = '/'; + html("/"); + start = delim + 1; + } + } else + cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL); + if (ctx.env.authenticated) { html(""); html("
\n"); -- 2.11.0