Permit arbitrary absolute wiki page names in wiki edit template= argument
|Reported by:||Owned by:||Ryan J Ollos|
Absolute path to wiki page can be passed in the
Attached is a small enhancement to trac core wiki/web_ui.py. Please consider including this patch in a future version of trac.
When editing a new wiki page, it is possible to select from template pages placed under PageTemplates/, and it is possible to pass a template= argument directly along with an edit link to select the specific template to use.
I came across this feature recently when reviewing the trachacks:wiki/WikiCalendarMacro which has a base=template parameter to select the template to use when creating a new calendar subpage. For this use case, it is not really useful to be forced to place the template under PageTemplates/ where it will _also_ be visible in the new wiki page template dropdown box; these kinds of templates are only useful for the specific calendar.
To this end, I came up with this enhancement patch. If the template argument starts with a slash, e.g. template=/some/template, that absolute path is directly used as the source page, omitting the PageTemplate/ prefix that is otherwise hardcoded.
NOTE: patch is against trac 0.11.7 as that's what I'm still using. I had a look at the code in current trunk - it's unchanged, so the patch should apply with some offset.