List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH v2] ui-shared: split repository link into directories
@ 2016-04-28 21:24 petr.vorel
  2016-04-28 23:14 ` petr.vorel
  0 siblings, 1 reply; 3+ messages in thread
From: petr.vorel @ 2016-04-28 21:24 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.
v2: minor cleanup
---
 ui-shared.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/ui-shared.c b/ui-shared.c
index 9a38aa9..a8cf2a8 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -937,7 +937,21 @@ 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, *link, *delim = "/";
+		char dir[strlen(ctx.repo->name)];
+		strcpy(dir, "");
+		link = ctx.repo->name;
+		while ((token = strtok_r(link, delim, &link))) {
+			if (strcmp(dir, "") != 0)
+				strcat(dir, delim);
+			strcat(dir, token);
+			strcpy(ctx.repo->name, dir);
+			cgit_summary_link(token, ctx.repo->name, NULL, NULL);
+			if (strcmp(link, "") != 0)
+				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 v2] ui-shared: split repository link into directories
  2016-04-28 21:24 [PATCH v2] ui-shared: split repository link into directories petr.vorel
@ 2016-04-28 23:14 ` petr.vorel
  2016-04-29  5:05   ` petr.vorel
  0 siblings, 1 reply; 3+ messages in thread
From: petr.vorel @ 2016-04-28 23:14 UTC (permalink / raw)


Dear John,

thanks for comments and tips.

> 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...
Not a problem, I'll can add config value into v3.

<snip>

> I'm guessing you intended to allow the repository at a/b/c to link to
> the directories a/b and a,
You're right, a, b and c are clickable going to "itself".
> 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.
You're right, I just tested it with "scan-path".

I'm testing it with this config:

----
css=/cgit-css/cgit.css
logo=/cgit-css/cgit.png

scan-path=/var/lib/git-testing/tmp/for-cgit/

repo.url=MyRepo
repo.path=/var/lib/git/MyRepo
repo.desc=This is my git repository

repo.url=section/subsection/myrepo1
repo.path=/var/lib/git-testing2/section/subsection/myrepo1
repo.desc=This is my git repository

repo.url=section/subsection/myrepo2
repo.path=/var/lib/git-testing2/section/subsection/myrepo2
repo.desc=This is my git repository

repo.url=section/subsection/myrepo3
repo.name=section/subsection/myrepo3
repo.path=/var/lib/git-testing2/section/subsection/myrepo3
repo.desc=This is my git repository
----

You right, it's broken is when I set repo.url and repo.name (e.g.
section/subsection/myrepo3) - all links point to repo.url; working if I set just repo.url.

> We may just have to bail out of this feature if the two variables differ.
Is it really the best way from UI/UX POV? Inconsistency isn't nice :-(. I'd like to try
to have this feature either on or off for each repository.


Kind regards,
Petr


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

* [PATCH v2] ui-shared: split repository link into directories
  2016-04-28 23:14 ` petr.vorel
@ 2016-04-29  5:05   ` petr.vorel
  0 siblings, 0 replies; 3+ messages in thread
From: petr.vorel @ 2016-04-29  5:05 UTC (permalink / raw)


Dear John,

> > We may just have to bail out of this feature if the two variables differ.
> Is it really the best way from UI/UX POV? Inconsistency isn't nice :-(. I'd like to try
> to have this feature either on or off for each repository.
You were right, it doesn't make much sense to split links if the paths (repo.url and
repo.name) are different (even if number of levels is the same for both of them).
I'll skip it in v3.

I'll wrap the feature in option which default off.

Kind regards,
Petr


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

end of thread, other threads:[~2016-04-29  5:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-28 21:24 [PATCH v2] ui-shared: split repository link into directories petr.vorel
2016-04-28 23:14 ` petr.vorel
2016-04-29  5:05   ` 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).