List for cgit developers and users
 help / color / mirror / Atom feed
From: petr.vorel at gmail.com (Petr Vorel)
Subject: [PATCH v2] ui-shared: split repository link into directories
Date: Thu, 28 Apr 2016 23:24:52 +0200	[thread overview]
Message-ID: <1461878692-15061-1-git-send-email-petr.vorel@gmail.com> (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



             reply	other threads:[~2016-04-28 21:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-28 21:24 petr.vorel [this message]
2016-04-28 23:14 ` petr.vorel
2016-04-29  5:05   ` petr.vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461878692-15061-1-git-send-email-petr.vorel@gmail.com \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).