[PATCH] filter: add support for owner-filter

Chris Burroughs chris.burroughs at gmail.com
Fri Aug 1 21:44:17 CEST 2014


On 08/01/2014 02:18 PM, John Keeping wrote:
> On Fri, Aug 01, 2014 at 01:54:46PM -0400, Chris Burroughs wrote:
> This isn't really acting as a filter, you're taking the argument from
> the function call and then just appending something based on that from
> the default generated by the C code.  I think the email filter has to
> take the email address as an argument because it may not be present in
> the input to the filter (depending on the value of "noplainemail")...
>


>
> Perhaps this would be better as:
>
> 	if (ctx.cfg.enable_index_owner) {
> 		if (ctx.repo->owner_filter) {
> 			cgit_open_filter(ctx.repo->owner_filter);
> 			html_txt(ctx.repo->owner);
> 			cgit_close_filter(ctx.repo->owner_filter);
> 		} else {
> 			html("<a href='");
> 			html_attr(cgit_rooturl());
> 			html("?=");
> 			html_url_arg(ctx.repo->owner);
> 			html("'>");
> 			html_txt(ctx.repo->owner);
> 			html("</a>");
> 		}
> 		html("</td><td>");
> 	}
>

Yes, much!


> so that the filter really is a filter acting on the owner.  Then the Lua
> implementation becomes:
>
> -- >8 --
> function filter_open()
>     buffer = ""
> end
>
> function filter_close()
>     html(string.format("<a href=\"%s\">%s</a>",
>             "http://wiki.example.com/about/" .. buffer, buffer))
>     return 0
> end
>
> function filter_write(str)
>      buffer = buffer .. str
> end
> -- 8< --
>
> What do you think?
>

I think using STDIN for "the thing to filter" consistently is much 
better.  I was thrown off by the way the email filter also takes the 
address as an argument.  cgit_root might be useful but if that's true I 
much prefer adding it to the environment later instead of shoe-horning 
it into the filter_open api.


More information about the CGit mailing list