List for cgit developers and users
 help / color / mirror / Atom feed
From: Kian Kasad <kian@kasad.com>
To: cgit@lists.zx2c4.com
Cc: Kian Kasad <kian@kasad.com>
Subject: [PATCH 5/6] Add graph page tab if enable-commit-graph is set to "separate"
Date: Thu,  4 Aug 2022 21:59:38 -0700	[thread overview]
Message-ID: <20220805045939.57987-6-kian@kasad.com> (raw)
In-Reply-To: <20220805045939.57987-1-kian@kasad.com>

If "enable-commit-graph" is set to "separate", a tab is added in the
navigation bar for the graph page. It sits next to the "log" link.
---
 ui-shared.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/ui-shared.c b/ui-shared.c
index acd8ab5..a0c326e 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -401,6 +401,49 @@ void cgit_log_link(const char *name, const char *title, const char *class,
 	html("</a>");
 }
 
+void cgit_graph_link(const char *name, const char *title, const char *class,
+		   const char *head, const char *rev, const char *path,
+		   int ofs, const char *grep, const char *pattern, int showmsg,
+		   int follow)
+{
+	char *delim;
+
+	delim = repolink(title, class, "graph", head, path);
+	if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) {
+		html(delim);
+		html("id=");
+		html_url_arg(rev);
+		delim = "&amp;";
+	}
+	if (grep && pattern) {
+		html(delim);
+		html("qt=");
+		html_url_arg(grep);
+		delim = "&amp;";
+		html(delim);
+		html("q=");
+		html_url_arg(pattern);
+	}
+	if (ofs > 0) {
+		html(delim);
+		html("ofs=");
+		htmlf("%d", ofs);
+		delim = "&amp;";
+	}
+	if (showmsg) {
+		html(delim);
+		html("showmsg=1");
+		delim = "&amp;";
+	}
+	if (follow) {
+		html(delim);
+		html("follow=1");
+	}
+	html("'>");
+	html_txt(name);
+	html("</a>");
+}
+
 void cgit_commit_link(const char *name, const char *title, const char *class,
 		      const char *head, const char *rev, const char *path)
 {
@@ -1043,6 +1086,10 @@ void cgit_print_pageheader(void)
 		cgit_log_link("log", NULL, hc("log"), ctx.qry.head,
 			      NULL, ctx.qry.vpath, 0, NULL, NULL,
 			      ctx.qry.showmsg, ctx.qry.follow);
+		if (ctx.repo->enable_commit_graph == 2)
+			cgit_graph_link("graph", NULL, hc("graph"), ctx.qry.head,
+					NULL, ctx.qry.vpath, 0, NULL, NULL,
+					ctx.qry.showmsg, ctx.qry.follow);
 		if (ctx.qry.page && !strcmp(ctx.qry.page, "blame"))
 			cgit_blame_link("blame", NULL, hc("blame"), ctx.qry.head,
 				        ctx.qry.oid, ctx.qry.vpath);
-- 
2.37.1


  parent reply	other threads:[~2022-08-05  5:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-18 22:31 User-configurable log graph option Kian Kasad
2021-02-19 12:22 ` John Keeping
2021-12-30 21:08   ` Kian Kasad
2022-08-05  4:59     ` [PATCH 0/6] Option for separate 'log' and 'graph' pages Kian Kasad
2022-08-05  4:59       ` [PATCH 1/6] Implement parsing of new enable-commit-graph option Kian Kasad
2022-08-05  4:59       ` [PATCH 2/6] Add graph page Kian Kasad
2022-08-05  4:59       ` [PATCH 3/6] Don't display commit age on " Kian Kasad
2022-08-05  4:59       ` [PATCH 4/6] Don't display graph page if enable-commit-graph is not set to "separate" Kian Kasad
2022-08-05  4:59       ` Kian Kasad [this message]
2022-08-05  4:59       ` [PATCH 6/6] Document new enable-commit-graph option Kian Kasad

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=20220805045939.57987-6-kian@kasad.com \
    --to=kian@kasad.com \
    --cc=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).