List for cgit developers and users
 help / color / mirror / Atom feed
From: whydoubt at gmail.com (Jeff Smith)
Subject: [PATCHv2 5/5] ui-tree: link to blame UI if enabled
Date: Sun,  1 Oct 2017 23:39:09 -0500	[thread overview]
Message-ID: <20171002043909.27878-6-whydoubt@gmail.com> (raw)
In-Reply-To: <20171002043909.27878-1-whydoubt@gmail.com>

Create links to the blame page.

Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
 ui-shared.c | 20 +++++++++++++++++---
 ui-shared.h |  3 +++
 ui-tree.c   | 10 +++++++++-
 3 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/ui-shared.c b/ui-shared.c
index 315dedb..07c78a5 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1,6 +1,6 @@
 /* ui-shared.c: common web output functions
  *
- * Copyright (C) 2006-2014 cgit Development Team <cgit at lists.zx2c4.com>
+ * Copyright (C) 2006-2017 cgit Development Team <cgit at lists.zx2c4.com>
  *
  * Licensed under GNU General Public License v2
  *   (see COPYING for full license text)
@@ -304,6 +304,12 @@ void cgit_plain_link(const char *name, const char *title, const char *class,
 	reporevlink("plain", name, title, class, head, rev, path);
 }
 
+void cgit_blame_link(const char *name, const char *title, const char *class,
+		     const char *head, const char *rev, const char *path)
+{
+	reporevlink("blame", name, title, class, head, rev, path);
+}
+
 void cgit_log_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,
@@ -478,6 +484,10 @@ static void cgit_self_link(char *name, const char *title, const char *class)
 		cgit_plain_link(name, title, class, ctx.qry.head,
 				ctx.qry.has_sha1 ? ctx.qry.sha1 : NULL,
 				ctx.qry.path);
+	else if (!strcmp(ctx.qry.page, "blame"))
+		cgit_blame_link(name, title, class, ctx.qry.head,
+				ctx.qry.has_sha1 ? ctx.qry.sha1 : NULL,
+				ctx.qry.path);
 	else if (!strcmp(ctx.qry.page, "log"))
 		cgit_log_link(name, title, class, ctx.qry.head,
 			      ctx.qry.has_sha1 ? ctx.qry.sha1 : NULL,
@@ -983,8 +993,12 @@ 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);
-		cgit_tree_link("tree", NULL, hc("tree"), ctx.qry.head,
-			       ctx.qry.sha1, ctx.qry.vpath);
+		if (ctx.qry.page && !strcmp(ctx.qry.page, "blame"))
+			cgit_blame_link("blame", NULL, hc("blame"), ctx.qry.head,
+				        ctx.qry.sha1, ctx.qry.vpath);
+		else
+			cgit_tree_link("tree", NULL, hc("tree"), ctx.qry.head,
+				       ctx.qry.sha1, ctx.qry.vpath);
 		cgit_commit_link("commit", NULL, hc("commit"),
 				 ctx.qry.head, ctx.qry.sha1, ctx.qry.vpath);
 		cgit_diff_link("diff", NULL, hc("diff"), ctx.qry.head,
diff --git a/ui-shared.h b/ui-shared.h
index 2cd7ac9..b760a17 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -26,6 +26,9 @@ extern void cgit_tree_link(const char *name, const char *title,
 extern void cgit_plain_link(const char *name, const char *title,
 			    const char *class, const char *head,
 			    const char *rev, const char *path);
+extern void cgit_blame_link(const char *name, const char *title,
+			    const char *class, const char *head,
+			    const char *rev, const char *path);
 extern void cgit_log_link(const char *name, const char *title,
 			  const char *class, const char *head, const char *rev,
 			  const char *path, int ofs, const char *grep,
diff --git a/ui-tree.c b/ui-tree.c
index 3925809..67fd1bc 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -1,6 +1,6 @@
 /* ui-tree.c: functions for tree output
  *
- * Copyright (C) 2006-2014 cgit Development Team <cgit at lists.zx2c4.com>
+ * Copyright (C) 2006-2017 cgit Development Team <cgit at lists.zx2c4.com>
  *
  * Licensed under GNU General Public License v2
  *   (see COPYING for full license text)
@@ -110,6 +110,11 @@ static void print_object(const unsigned char *sha1, char *path, const char *base
 	htmlf("blob: %s (", sha1_to_hex(sha1));
 	cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
 		        rev, path);
+	if (ctx.cfg.enable_blame) {
+		html(") (");
+		cgit_blame_link("blame", NULL, NULL, ctx.qry.head,
+			        rev, path);
+	}
 	html(")\n");
 
 	if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) {
@@ -244,6 +249,9 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base,
 	if (!S_ISGITLINK(mode))
 		cgit_plain_link("plain", NULL, "button", ctx.qry.head,
 				walk_tree_ctx->curr_rev, fullpath.buf);
+	if (!S_ISDIR(mode) && ctx.cfg.enable_blame)
+		cgit_blame_link("blame", NULL, "button", ctx.qry.head,
+				walk_tree_ctx->curr_rev, fullpath.buf);
 	html("</td></tr>\n");
 	free(name);
 	strbuf_release(&fullpath);
-- 
2.9.4



      parent reply	other threads:[~2017-10-02  4:39 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-08  2:18 [RFC PATCH 0/4] Add ui-blame whydoubt
2017-06-08  2:18 ` [RFC PATCH 1/4] git: update to v2.14 whydoubt
2017-07-22 11:25   ` john
2017-06-08  2:18 ` [RFC PATCH 2/4] ui-blame: create placeholder and links whydoubt
2017-07-22 11:31   ` john
2017-06-08  2:18 ` [RFC PATCH 3/4] ui-blame: create needed html_ntxt_noellipsis function whydoubt
2017-07-22 11:36   ` john
2017-06-08  2:18 ` [RFC PATCH 4/4] ui-blame: fill in the contents whydoubt
2017-07-05  8:32   ` list
2017-07-22 11:47   ` john
2017-06-08  9:00 ` [RFC PATCH 0/4] Add ui-blame list
2017-07-22 12:02 ` john
2017-08-05  0:23   ` dlcampbell
2017-08-05  0:57     ` whydoubt
2017-08-24 18:14       ` list
2017-08-31 13:05         ` whydoubt
2017-09-23  3:38 ` [RFCv2 PATCH 0/7] " whydoubt
2017-09-23  3:38   ` [RFCv2 PATCH 1/7] ui-blame: create enable-blame config item whydoubt
2017-09-23 15:46     ` john
2017-09-24  3:12       ` whydoubt
2017-09-23  3:38   ` [RFCv2 PATCH 2/7] ui-blame: create framework whydoubt
2017-09-23 15:47     ` john
2017-09-24  3:24       ` whydoubt
2017-09-23  3:38   ` [RFCv2 PATCH 3/7] ui-blame: create links whydoubt
2017-09-23 15:47     ` john
2017-09-24 20:25       ` whydoubt
2017-09-23  3:38   ` [RFCv2 PATCH 4/7] ui-blame: html_ntxt with no ellipsis whydoubt
2017-09-23 15:47     ` john
2017-09-23  3:38   ` [RFCv2 PATCH 5/7] ui-blame: pull blame info from libgit whydoubt
2017-09-23 15:47     ` john
2017-09-24 19:06       ` whydoubt
2017-09-24 20:09         ` whydoubt
2017-09-24 20:52           ` john
2017-09-23  3:38   ` [RFCv2 PATCH 6/7] ui-blame: begin building whydoubt
2017-09-23  3:38   ` [RFCv2 PATCH 7/7] ui-blame: generate blame page when requested whydoubt
2017-09-23 15:53   ` [RFCv2 PATCH 0/7] Add ui-blame john
2017-09-24  3:05     ` whydoubt
2017-09-27 22:43   ` [PATCH 0/5] " whydoubt
2017-09-27 22:43     ` [PATCH 1/5] html: html_ntxt with no ellipsis whydoubt
2017-09-30 11:55       ` john
2017-09-27 22:43     ` [PATCH 2/5] ui-tree: move set_title_from_path to ui-shared whydoubt
2017-09-30 11:56       ` john
2017-09-27 22:43     ` [PATCH 3/5] ui-shared: make a char* parameter const whydoubt
2017-09-30 12:00       ` john
2017-09-27 22:43     ` [PATCH 4/5] ui-blame: add blame UI whydoubt
2017-09-30 12:07       ` john
2017-09-27 22:43     ` [PATCH 5/5] ui-tree: link to blame UI if enabled whydoubt
2017-09-30 12:08       ` john
2017-09-30 12:10     ` [PATCH 0/5] Add ui-blame john
2017-10-02  1:17       ` Jason
2017-10-02  5:34         ` list
2017-10-02 22:35           ` whydoubt
2017-10-02 23:29             ` list
2017-10-03 18:22               ` john
2017-10-03 18:23                 ` Jason
2017-10-03 18:36                   ` Jason
2017-10-03 19:06                     ` whydoubt
2017-10-02  4:39     ` [PATCHv2 " whydoubt
2017-10-02  4:39       ` [PATCHv2 1/5] html: html_ntxt with no ellipsis whydoubt
2017-10-02  4:39       ` [PATCHv2 2/5] ui-tree: move set_title_from_path to ui-shared whydoubt
2017-10-02  4:39       ` [PATCHv2 3/5] ui-shared: make a char* parameter const whydoubt
2017-10-02  4:39       ` [PATCHv2 4/5] ui-blame: add blame UI whydoubt
2017-10-02  4:39       ` whydoubt [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=20171002043909.27878-6-whydoubt@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).