From mboxrd@z Thu Jan 1 00:00:00 1970 From: chris.burroughs at gmail.com (Chris Burroughs) Date: Fri, 01 Aug 2014 15:44:17 -0400 Subject: [PATCH] filter: add support for owner-filter In-Reply-To: <20140801181850.GS26927@serenity.lan> References: <53DBD466.9000509@gmail.com> <20140801181850.GS26927@serenity.lan> Message-ID: <53DBEE11.8030509@gmail.com> 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(""); > html_txt(ctx.repo->owner); > html(""); > } > html(""); > } > 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("%s", > "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.