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

From:
Tracey Emery <tracey@traceyemery.net>
Subject:
Re: gotwebd: linkables lines in blame page
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Tue, 9 Aug 2022 09:11:56 -0600

Download raw body.

Thread
On Tue, Aug 09, 2022 at 04:48:04PM +0200, Omar Polo wrote:
> 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.

I'm concerned about adding this to blame. Some blame operations can take
a long time. What if we change our blob to be more like gitweb's and add
a third type of "raw," which would replace our blob? Then our blob would
have HTML output and the line linking, which is really cool.

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

Can you expound a bit here? What would it be used for? If it is used for
something like this, I think it would be a good idea and reduce lines:

fcgi_gen_responsef(c, "<a href='#%s'>%s</a>", out_buff, out_buff);

Is that what you mean?

> 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;
>  

-- 

Tracey Emery