"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
gotwebd: linkables lines in blame page
To:
gameoftrees@openbsd.org
Cc:
Tracey Emery <tracey@traceyemery.net>
Date:
Tue, 09 Aug 2022 16:48:04 +0200

Download raw body.

Thread
This makes it possible to link lines in the blame page.  For example:

https://git.omarpolo.com/?index_page=0&path=vc-got.git&action=blame&commit=bc158324418fd8bef96a7f62856679de2569030f&folder=&file=vc-got.el#676

I'm adding it to the blame page since we're serving blobs as-is, the
only page with the file content that's browsable in an HTML page is
the blame page.

P.S.: what do you think if we introduce something a printf-like
fcgi_gen_responsef?

diff /home/op/w/got
commit - 3ff00eade6c3b17a852658c28502edbfc83ef25b
path + /home/op/w/got
blob - aa31a4194e9ded7a28469e87db5cb864a4035bbe
file + gotwebd/files/htdocs/gotwebd/gotweb.css
--- gotwebd/files/htdocs/gotwebd/gotweb.css
+++ gotwebd/files/htdocs/gotwebd/gotweb.css
@@ -578,6 +578,9 @@ body {
 	float: left;
 	width: 100%;
 }
+.blame_wrapper:target {
+        background-color: Khaki;
+}
 .blame_number {
 	float: left;
 	width: 6em;
blob - 35b380e1800015f0b0fc66fd8de05660532b58d9
file + gotwebd/got_operations.c
--- gotwebd/got_operations.c
+++ gotwebd/got_operations.c
@@ -1400,15 +1400,27 @@ got_gotweb_blame_cb(void *arg, int nlines, int lineno,
 		if (nl)
 			*nl = '\0';
 
-		if (fcgi_gen_response(c, "<div class='blame_wrapper'>") == -1)
-			goto done;
-		if (fcgi_gen_response(c, "<div class='blame_number'>") == -1)
-			goto done;
 		if (snprintf(out_buff, strlen(out_buff), "%.*d", a->nlines_prec,
 		    a->lineno_cur) < 0)
 			goto done;
+		if (fcgi_gen_response(c, "<div id='") == -1)
+			goto done;
 		if (fcgi_gen_response(c, out_buff) == -1)
 			goto done;
+		if (fcgi_gen_response(c, "' class='blame_wrapper'>") == -1)
+			goto done;
+		if (fcgi_gen_response(c, "<div class='blame_number'>") == -1)
+			goto done;
+		if (fcgi_gen_response(c, "<a href='#") == -1)
+			goto done;
+		if (fcgi_gen_response(c, out_buff) == -1)
+			goto done;
+		if (fcgi_gen_response(c, "'>") == -1)
+			goto done;
+		if (fcgi_gen_response(c, out_buff) == -1)
+			goto done;
+		if (fcgi_gen_response(c, "</a>") == -1)
+			goto done;
 		if (fcgi_gen_response(c, "</div>") == -1)
 			goto done;