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

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: gotwebd tree + readme on summary page
To:
Stefan Sperling <stsp@stsp.name>
Cc:
gameoftrees@openbsd.org
Date:
Fri, 08 Dec 2023 10:26:17 +0100

Download raw body.

Thread
On 2023/12/08 10:17:41 +0100, Stefan Sperling <stsp@stsp.name> wrote:
> Trying to show README files on the summary page, this is the best I could
> come up with. It basically copies the code used by the tree view. Displaying
> just the README is possible by stubbing out the tree item display callback
> (lazy approach, I know; a better approach would use a custom function to
> hunt for the README file). But turns out displaying the HEAD tree on the
> summary page as well looks quite nice, so let's just do that?
> 
> ok?

i have a few ideas on what we could do on top of this, but just as-is is
really nice.  Showing the README and the files is very handy especially
when browsing/discovering stuff.

ok op@ with a nit below fixed

> [...]
>  {{ define gotweb_render_summary(struct template *tp) }}
>  {!
> +	const struct got_error	*error;
>  	struct request		*c = tp->tp_arg;
>  	struct server		*srv = c->srv;
>  	struct transport	*t = c->t;
>  	struct got_reflist_head	*refs = &t->refs;
> +	struct gotweb_url	 url;
> +	char			*readme = NULL;
> +	int			 binary;
> +	const uint8_t		*buf;
> +	size_t			 len;
>  !}
> [...]
> +</div>

here we lack freeing the readme, so please add

+{{ finally }}
+{! free(readme); !}

the special "finally" block is always executed, even if the template is
interrupted in half (for e.g. due to the client disconnecting).  It's
the "goto done" equivalent in the templates.  Unfortunately I haven't
made yet this reachable by inline code, so we need to keep the
free(readme); return -1; in a few places...

>  {{ end }}
>  
>  {{ define gotweb_render_blame(struct template *tp) }}