List for cgit developers and users
 help / color / mirror / Atom feed
From: Jason at zx2c4.com (Jason A. Donenfeld)
Subject: [PATCH 4/4] ui-blame: put source lines through filter
Date: Sat, 14 Oct 2017 16:17:50 +0200	[thread overview]
Message-ID: <20171014141750.14013-5-Jason@zx2c4.com> (raw)
In-Reply-To: <20171014141750.14013-1-Jason@zx2c4.com>

We toggle the filter on and off so that the control table can avoid
going through the filter.

Signed-off-by: Jason A. Donenfeld <Jason at zx2c4.com>
---
 ui-blame.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/ui-blame.c b/ui-blame.c
index 62cf431..71aec65 100644
--- a/ui-blame.c
+++ b/ui-blame.c
@@ -70,7 +70,12 @@ static void emit_blame_entry(struct blame_scoreboard *sb,
 	cpend = blame_nth_line(sb, ent->lno + ent->num_lines);
 
 	html("<td class='lines'><pre><code>");
-	html_ntxt(cp, cpend - cp);
+	if (ctx.repo->source_filter) {
+		cgit_enable_filter(ctx.repo->source_filter, true);
+		html_raw(cp, cpend - cp);
+		cgit_enable_filter(ctx.repo->source_filter, false);
+	} else
+		html_ntxt(cp, cpend - cp);
 	html("</code></pre></td></tr>\n");
 }
 
@@ -90,6 +95,7 @@ static void print_object(const unsigned char *sha1, const char *path,
 	struct blame_scoreboard sb;
 	struct blame_origin *o;
 	struct blame_entry *ent = NULL;
+	char *filter_arg;
 
 	type = sha1_object_info(sha1, &size);
 	if (type == OBJ_BAD) {
@@ -131,6 +137,11 @@ static void print_object(const unsigned char *sha1, const char *path,
 		return;
 	}
 
+	if (ctx.repo->source_filter) {
+		filter_arg = xstrdup(path);
+		cgit_open_filter(ctx.repo->source_filter, filter_arg);
+		cgit_enable_filter(ctx.repo->source_filter, false);
+	}
 	html("<table class='blame blob'>");
 	for (ent = sb.ent; ent; ) {
 		struct blame_entry *e = ent->next;
@@ -139,6 +150,8 @@ static void print_object(const unsigned char *sha1, const char *path,
 		ent = e;
 	}
 	html("</table>\n");
+	if (ctx.repo->source_filter)
+		cgit_close_filter(ctx.repo->source_filter);
 	free((void *)sb.final_buf);
 
 	cgit_print_layout_end();
-- 
2.14.2



  parent reply	other threads:[~2017-10-14 14:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-14 14:17 [PATCH 0/4] adding color to ui-blame Jason
2017-10-14 14:17 ` [PATCH 1/4] filter: add generic scafolding for temporarily disabling filter Jason
2017-10-14 14:17 ` [PATCH 2/4] filter: wire up exec_filter to enable function Jason
2017-10-14 14:17 ` [PATCH 3/4] filter: wire up lua_filter " Jason
2017-10-14 14:17 ` Jason [this message]
2017-10-14 16:14 ` [PATCH 0/4] adding color to ui-blame john
2017-10-15 16:47   ` Jason
2017-10-15 17:04     ` whydoubt
2017-10-15 17:11       ` Jason

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=20171014141750.14013-5-Jason@zx2c4.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).