Summary: | Add support for [% INCLUDE %] in plugin templates | ||
---|---|---|---|
Product: | Koha | Reporter: | Frédéric Demians <f.demians> |
Component: | Plugin architecture | Assignee: | Frédéric Demians <f.demians> |
Status: | CLOSED FIXED | QA Contact: | Nick Clemens (kidclamp) <nick> |
Severity: | new feature | ||
Priority: | P5 - low | CC: | dcook, fridolin.somers, jonathan.druart, lucas, martin.renvoize, maryse.simard, nick, tomascohen |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | --- |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: |
The new feature allows plugin authors to use template `[% INCLUDE %]` directives in their templates. It does so by introducing a new variable, `PLUGIN_DIR`, allowing the template engine to locate the includes.
**Usage**: `[% INCLUDE "$PLUGIN_DIR/header.tt" %]`
**Warning**: Care should be taken when installing any plugins and only plugins you trust should be used.
|
Version(s) released in: |
19.11.00,19.05.03
|
Circulation function: | |||
Bug Depends on: | |||
Bug Blocks: | 26803 | ||
Attachments: |
Bug 23237 Plugin allow [% INCLUDE %] from template
Bug 23237 Plugin allow [% INCLUDE %] from template Bug 23237: Plugin allow [% INCLUDE %] from template Bug 23237: Fix POD and typos Bug 23237: Fix PLUGIN_DIR parameter in master/19.11 |
Description
Frédéric Demians
2019-06-29 06:54:58 UTC
Created attachment 91128 [details] [review] Bug 23237 Plugin allow [% INCLUDE %] from template From a plugin template it is useful to be able to include other templates with [% INCLUDE %] directives. But TT module is used by Koha with absolute paths. Relative paths are forbidden for security reasons. A new param [% PLUGIN_DIR %] allow plugin templates to know where to find plugin home directory. How to test: 1. Install kitchen-sink plugin. 2. Find tool-step1.tt file, and add this at the begining of the file: [% INCLUDE "$PLUGIN_DIR/header.tt" %] It ask to include a template header.tt which doesn't exit. 3. Run kitchen-sink plugin tool. You must have this error message: Template process failed: file error - _path to plugin directory_/Koha/Plugin/Com/ByWaterSolutions/KitchenSink/header.tt: not found quod erat demonstrandum Created attachment 91374 [details] [review] Bug 23237 Plugin allow [% INCLUDE %] from template From a plugin template it is useful to be able to include other templates with [% INCLUDE %] directives. But TT module is used by Koha with absolute paths. Relative paths are forbidden for security reasons. A new param [% PLUGIN_DIR %] allow plugin templates to know where to find plugin home directory. How to test: 1. Install kitchen-sink plugin. 2. Find tool-step1.tt file, and add this at the begining of the file: [% INCLUDE "$PLUGIN_DIR/header.tt" %] It ask to include a template header.tt which doesn't exit. 3. Run kitchen-sink plugin tool. You must have this error message: Template process failed: file error - _path to plugin directory_/Koha/Plugin/Com/ByWaterSolutions/KitchenSink/header.tt: not found quod erat demonstrandum Signed-off-by: Maryse Simard <maryse.simard@inlibro.com> Created attachment 91875 [details] [review] Bug 23237: Plugin allow [% INCLUDE %] from template From a plugin template it is useful to be able to include other templates with [% INCLUDE %] directives. But TT module is used by Koha with absolute paths. Relative paths are forbidden for security reasons. A new param [% PLUGIN_DIR %] allow plugin templates to know where to find plugin home directory. How to test: 1. Install kitchen-sink plugin. 2. Find tool-step1.tt file, and add this at the begining of the file: [% INCLUDE "$PLUGIN_DIR/header.tt" %] It ask to include a template header.tt which doesn't exit. 3. Run kitchen-sink plugin tool. You must have this error message: Template process failed: file error - _path to plugin directory_/Koha/Plugin/Com/ByWaterSolutions/KitchenSink/header.tt: not found quod erat demonstrandum Signed-off-by: Maryse Simard <maryse.simard@inlibro.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Created attachment 91876 [details] [review] Bug 23237: Fix POD and typos Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Nice work! Pushed to master for 19.11.00 Nice work! Pushed to master for 19.11.00 Nice enhancement. I choose to backport so than Koha Plugins can already be developed/updated with this. Pushed to 19.05.x for 19.05.03 following Fridolin's lead and backporting this enhancement to 18.11.x for 18.11.10 this patchset made me unable to prove t/db_dependent/Koha/REST/Plugin/PluginRoutes.t in 18.11.x, since this is an enhancement i am choosing to revert the patch set in 18.11.x I think the get_plugin_dir method is not quite correct as there can be more than one plugins_dir entry. bundle_dir should be used instead. Any further thoughts regarding Tomas's comment Frederic? (In reply to Martin Renvoize from comment #11) > Any further thoughts regarding Tomas's comment Frederic? Thomas is right. I implemented this before Thomas added bundle_dir() method. I will submit a patch to use Thomas method instead of mine get_plugin_dir() method. bundle_dir() is available in 19.11 and after. So the new patch must not be backported to 19.05 and 18.11. As it is the usage of new template parameter PLUGIN_DIR will be OK in 18.11 and 19.05 as soon as plugins_dir parameter is unique in koha-conf.xml. Created attachment 97862 [details] [review] Bug 23237: Fix PLUGIN_DIR parameter in master/19.11 Method get_plugin_dir() is not correct when plugin_dirs parameter is repeated in koha-conf.xml. A new method bundle_path() must be used instead. bundle_dir() is available in 19.11 and after. So the new patch must not be backported to 19.05 and 18.11. As it is the usage of the new template parameter PLUGIN_DIR will be OK in 18.11 and 19.05 as soon as plugins_dir parameter is unique in koha-conf.xml. Thanks Thomas See bug 26803 |