List for cgit developers and users
 help / color / mirror / Atom feed
From: petr.vorel at gmail.com (Petr Vorel)
Subject: [PATCH v9 1/1] ui-shared: allow to split the repository link
Date: Mon, 14 Aug 2017 11:34:32 +0200	[thread overview]
Message-ID: <20170814093431.dbp4txa2an7eg4ah@x230> (raw)
In-Reply-To: <20170312181131.26781-1-petr.vorel@gmail.com>

Hi Jason,

> 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 <petr.vorel at gmail.com>
> Cc: "Jason A. Donenfeld" <Jason at zx2c4.com>
> Cc: John Keeping <john at keeping.me.uk>
> Reviewed-by: John Keeping <john at keeping.me.uk>
> ---
> v8->v9: correct free() call.
> ---
>  cgitrc.5.txt |  4 +++-
>  ui-shared.c  | 29 ++++++++++++++++++++++++++++-
>  2 files changed, 31 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..a7cb15c 100644
> --- a/ui-shared.c
> +++ b/ui-shared.c
> @@ -936,7 +936,34 @@ 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';
> +
> +				char *url = cgit_repourl(name);
> +				html_link_open(url, NULL, NULL);
> +				free(url);
> +				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("</td><td class='form'>");
>  			html("<form method='get'>\n");

Anything preventing to merge this patch?
Thanks for info.

Kind regards,
Petr


      reply	other threads:[~2017-08-14  9:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-12 18:11 petr.vorel
2017-08-14  9:34 ` petr.vorel [this message]

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=20170814093431.dbp4txa2an7eg4ah@x230 \
    --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).