output. The output is included in the Owner column.
render filter::
- This filter is given a single parameter: the filename of the source
- file to render. The filter can use the filename to determine (for
- example) the syntax highlighting mode. The contents of the file that
- is to be rendered is available on standard input and the rendered
- content is expected on standard output.
+ This filter is given a single required parameter: the filename of
+ the source file to render. The filter can use the filename to
+ determine (for example) the syntax highlighting mode. The
+ contents of the file that is to be rendered is available on standard
+ input and the rendered content is expected on standard output. Two
+ additional optional parameters are the base URL path and optional
+ URL parameter arguments needed to adapt relative paths in the input
+ to absolute URLs pointing to the "plain" version of the file in the
+ repo rev context, eg, "/myvirt/reponame/plain" and "?h=mybranch"
+ could be used to convert input references like "pics/myfile.png" to
+ '<img src="/myvirt/reponame/plain/pics/myfile.png?h=mybranch">'
source filter::
This filter is given a single parameter: the filename of the source
}
static void render_buffer(struct cgit_filter *render, const char *name,
- char *buf, unsigned long size)
+ char *buf, unsigned long size)
{
char *filter_arg = xstrdup(name);
+ struct strbuf sb_pre = STRBUF_INIT, sb_post = STRBUF_INIT;
+
+ cgit_repo_create_url(&sb_pre, &sb_post, "plain", ctx.qry.head, NULL);
html("<div class='blob'>");
- cgit_open_filter(render, filter_arg);
+ cgit_open_filter(render, filter_arg, sb_pre.buf, sb_post.buf);
html_raw(buf, size);
cgit_close_filter(render);
html("</div>");
+ strbuf_release(&sb_pre);
+ strbuf_release(&sb_post);
free(filter_arg);
}