Noah Kantrowitz wrote: > On Sep 14, 2006, at 10:11 PM, Ilias Lazaridis wrote: > > Noah Kantrowitz wrote: > >> On Sep 12, 2006, at 6:41 PM, Ilias Lazaridis wrote: > >>> Can I use the ITemplateProvider to override the original templates > >>> (e.g. wiki.cs)? > >>> > >>> Or is there any other mechanism available to do so from within a > >>> plugin? > >>> > >>> I guess I could use a simple copy instruction like this: > >>> > >>> #code > >>> global-trac-template-folder = <function to get > >>> global-trac-template-folder> > >>> copy /templates/wiki.cs to global-trac-template-folder > >>> alter permissions > >>> > >>> but I would like to avoid this. > >>> > >>> context: http://trac.edgewall.org/ticket/3704 > >> > >> Look at the TracTags plugin for how to override builtin templates. > > > > http://muness.textdriven.com/svn/edu/tags-plugin/trunk/tractags/ > > web_ui.py > > > > It provides an own template and an own implementation of the > > wiki-module. This depends additionally on changing the ini file: > > > > " > > Update your trac.ini with the following: > > > > [trac] > > default_handler = TagsWikiModule > > > > [components] > > trac.wiki.web_ui.wikimodule = disabled > > tractags.* = enabled > > " > > > > Any other simpler solution? > > > > (if possible reversible, e.g. if the plugin is deactivated, the > > original template should become active again)? > > Sorry, looks like Alec took that bit of hackery out. The way > ClearSilver looks for templates is by examining each folder in the > 'hdf.loadpaths' HDF variable. Normally the project templates folder > and the central templates folder are the first two items in this > list, with plugin folders being added below that. If you munged this > list so your folder appears first, you can mask out other templates. > As a probably much cleaner way to do it, you can just make a request > filter that does something like this: > {{{ > def post_process_request(self, req, template, content_type): > if template == 'wiki.cs': > template = 'mytemplate.cs' > return (template, content_type) > }}}
Yes, this looks much better (although it seems that this would additional overhead to _every_ request, but ok, it's a tiny one): http://trac.edgewall.org/browser/trunk/trac/web/api.py#L486 . --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Trac Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/trac-users -~----------~----~----~----~------~----~------~--~---
