List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH] ui-shared: split repository link into directories
@ 2016-04-28 20:37 petr.vorel
  2016-04-28 21:53 ` john
  0 siblings, 1 reply; 3+ messages in thread
From: petr.vorel @ 2016-04-28 20:37 UTC (permalink / raw)


Signed-off-by: Petr Vorel <petr.vorel at gmail.com>
---
The only missing feature from gitweb: clickable any directory in between. It's
very handy, if you have lots of repos (local AOSP repositories).
If you don't like it hardcoded, I can prepare patch with configuration option.
---
 ui-shared.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/ui-shared.c b/ui-shared.c
index 9a38aa9..cac12bf 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -937,7 +937,24 @@ 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);
+
+		char *token, *saveptr, *delim = "/";
+		char dir[strlen(ctx.repo->name)];
+		char link[strlen(ctx.repo->name)];
+		strcpy(dir, "");
+		strcpy(link, ctx.repo->name);
+		token = strtok_r(link, delim, &saveptr);
+		while (token != NULL) {
+			if (strcmp(dir, "") != 0)
+				strcat(dir, delim);
+			strcat(dir, token);
+			strcpy(ctx.repo->name, dir);
+			cgit_summary_link(token, ctx.repo->name, NULL, NULL);
+			token = strtok_r(NULL, delim, &saveptr);
+			if (token != NULL)
+				html(delim);
+		}
+
 		if (ctx.env.authenticated) {
 			html("</td><td class='form'>");
 			html("<form method='get' action=''>\n");
-- 
2.8.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] ui-shared: split repository link into directories
  2016-04-28 20:37 [PATCH] ui-shared: split repository link into directories petr.vorel
@ 2016-04-28 21:53 ` john
  2016-04-28 22:24   ` petr.vorel
  0 siblings, 1 reply; 3+ messages in thread
From: john @ 2016-04-28 21:53 UTC (permalink / raw)


On Thu, Apr 28, 2016 at 10:37:29PM +0200, Petr Vorel wrote:
> Signed-off-by: Petr Vorel <petr.vorel at gmail.com>
> ---
> The only missing feature from gitweb: clickable any directory in between. It's
> very handy, if you have lots of repos (local AOSP repositories).
> If you don't like it hardcoded, I can prepare patch with configuration option.

I think we should have a configuration option for this as it changes the
behaviour.  However, I'm not sure what the patch below does because...

> ---
>  ui-shared.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/ui-shared.c b/ui-shared.c
> index 9a38aa9..cac12bf 100644
> --- a/ui-shared.c
> +++ b/ui-shared.c
> @@ -937,7 +937,24 @@ 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);
> +
> +		char *token, *saveptr, *delim = "/";
> +		char dir[strlen(ctx.repo->name)];
> +		char link[strlen(ctx.repo->name)];
> +		strcpy(dir, "");
> +		strcpy(link, ctx.repo->name);
> +		token = strtok_r(link, delim, &saveptr);
> +		while (token != NULL) {
> +			if (strcmp(dir, "") != 0)
> +				strcat(dir, delim);
> +			strcat(dir, token);
> +			strcpy(ctx.repo->name, dir);
> +			cgit_summary_link(token, ctx.repo->name, NULL, NULL);

... we always link to the summary page for the current repo here,
although now the slashes aren't part of the link.

I'm guessing you intended to allow the repository at a/b/c to link to
the directories a/b and a, which would require changing this to use
cgit_pageurl().  But we also need to use repo->url which may be
unrelated to repo->name; that won't be the case if repositories are
discovered with "scan-path" (which I suspect is the most common
configuration), but repositories added with "repo.url" and "repo.name"
can have completely different values for these two variables.  We may
just have to bail out of this feature if the two variables differ.

> +			token = strtok_r(NULL, delim, &saveptr);
> +			if (token != NULL)
> +				html(delim);
> +		}
> +
>  		if (ctx.env.authenticated) {
>  			html("</td><td class='form'>");
>  			html("<form method='get' action=''>\n");
> -- 
> 2.8.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] ui-shared: split repository link into directories
  2016-04-28 21:53 ` john
@ 2016-04-28 22:24   ` petr.vorel
  0 siblings, 0 replies; 3+ messages in thread
From: petr.vorel @ 2016-04-28 22:24 UTC (permalink / raw)


Dear John,

Please, have a look at v2 (just minor cleanup), I'll answer there.


Kind regards,
Petr


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-28 22:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-28 20:37 [PATCH] ui-shared: split repository link into directories petr.vorel
2016-04-28 21:53 ` john
2016-04-28 22:24   ` petr.vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).