On Tue, Sep 17, 2013 at 9:51 AM, Anoop Nayak <[email protected]> wrote:
> Hi Gary, > > Is the post_process_request acting like a signal. And I just read through > the trac plugin documentation. So basically we are making a trac plugin. I > assumed it to be integrated into trac. Sorry for the misunderstanding. Let > me try making a plugin. I just made a branch as you suggested and will soon > update the more neater code into it :) > > Thanks & Regards, > > Anoop Nayak > `post_process_request` will get called after each request is handled: http://trac.edgewall.org/browser/tags/trac-1.0.1/trac/web/main.py?marks=214,223-224#L212 You'll need to determine inside of `post_process_request` whether your code should be executed for this request. For example, you don't need or want your code to be executed if the request is a GET on the timeline. Generally, you use the `template`, `data` and `req.path_info` parameters to determine if this is a request for which you want to execute your code. Probably the `req.path_info` parameter will be most useful to you to get started, but it seems like you want to add your syntax highlighting on any page that wiki markup is allowed, and this would include the milestone edit page and any plugins, so we'll probably need to come up with a better way to determine for which requests your code should be added. I think what Gary was suggesting is to put your JavaScript code in a file, and add it to the template using `trac.web.chrome:add_script` after matching for the appropriate requests. Similarly for your CSS with `trac.web.chrome:add_stylesheet`. The modifications you are making to the Genshi templates can either be done in JavaScript, or in an ITemplateStreamFilter implementation. The latter is a bit challenging, so I wouldn't worry about that for now. Any changes you make to the templates now can be moved into JavaScript or an ITemplateStreamFilter implementation after you get the plugin working correctly.
