Bug 22834

Summary: Add a method for plugins to return the absolute path for bundled files
Product: Koha Reporter: Tomás Cohen Arazi <tomascohen>
Component: Plugin architectureAssignee: Tomás Cohen Arazi <tomascohen>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: new feature    
Priority: P5 - low CC: agustinmoyano, arthur.suzuki, hayleypelham, kyle, lucas, martin.renvoize, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
This new feature allows plugin authors to construct absolute paths to resources contained within their plugins using the new `bundle_path` method. This can be used to aid in serving static content. **Warning**: Care should be taken when installing any plugins and only plugins you trust should be used.
Version(s) released in:
19.11.00
Bug Depends on: 21073    
Bug Blocks: 22835, 26803    
Attachments: Bug 22834: Add tests for Koha::Plugins::Base->bundle_path
Bug 22834: Add Koha::Plugins::Base->bundle_path
Bug 22834: Add tests for Koha::Plugins::Base->bundle_path
Bug 22834: Add Koha::Plugins::Base->bundle_path
Bug 22834: Add tests for Koha::Plugins::Base->bundle_path
Bug 22834: Add Koha::Plugins::Base->bundle_path
Bug 21073: (follow-up) QA fixes after rebase
Bug 22834: Add tests for Koha::Plugins::Base->bundle_path
Bug 22834: Add Koha::Plugins::Base->bundle_path
Bug 22834: Add tests for Koha::Plugins::Base->bundle_path
Bug 22834: Add Koha::Plugins::Base->bundle_path

Description Tomás Cohen Arazi 2019-05-02 18:29:03 UTC
Koha::Plugins::Base inherits from Module::Bundled::Files, which is handy to pack assets together and have a simple way to calculate the asset's path. It would help developing new features to have a way to retrieve the absolute path.
Comment 1 Tomás Cohen Arazi 2019-05-02 18:54:28 UTC Comment hidden (obsolete)
Comment 2 Tomás Cohen Arazi 2019-05-02 18:54:32 UTC Comment hidden (obsolete)
Comment 3 Tomás Cohen Arazi 2019-05-02 19:16:02 UTC
Created attachment 89260 [details] [review]
Bug 22834: Add tests for Koha::Plugins::Base->bundle_path
Comment 4 Tomás Cohen Arazi 2019-05-02 19:16:06 UTC
Created attachment 89261 [details] [review]
Bug 22834: Add Koha::Plugins::Base->bundle_path

This patch adds a 'bundle_path' method that return the base path for
assets included in the plugin. The idea is that it will be used for
calculation of the absolute path in the filesystem for static content.

To test:
- Apply the unit tests patch
- Run:
  $ kshell
 k$ prove t/db_dependent/Plugins.t
=> FAIL: The method is not implemented
- Apply this patch
- Run:
 k$ prove t/db_dependent/Plugins.t
=> SUCCESS: Tests pass!
- Sign off :-D
Comment 5 Arthur Suzuki 2019-05-13 13:40:22 UTC
Created attachment 89660 [details] [review]
Bug 22834: Add tests for Koha::Plugins::Base->bundle_path

Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
Comment 6 Arthur Suzuki 2019-05-13 13:40:48 UTC
Created attachment 89661 [details] [review]
Bug 22834: Add Koha::Plugins::Base->bundle_path

This patch adds a 'bundle_path' method that return the base path for
assets included in the plugin. The idea is that it will be used for
calculation of the absolute path in the filesystem for static content.

To test:
- Apply the unit tests patch
- Run:
  $ kshell
 k$ prove t/db_dependent/Plugins.t
=> FAIL: The method is not implemented
- Apply this patch
- Run:
 k$ prove t/db_dependent/Plugins.t
=> SUCCESS: Tests pass!
- Sign off :-D

Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
Comment 7 Arthur Suzuki 2019-05-13 14:28:55 UTC
Works as expected, the gif provided as an example is very rewarding, thanks ;)
Made my day.
Comment 8 Arthur Suzuki 2019-05-13 14:29:36 UTC
wrong bz, sry... (In reply to Arthur Suzuki from comment #7)
> Works as expected, the gif provided as an example is very rewarding, thanks
> ;)
> Made my day.
Comment 9 Agustín Moyano 2019-05-16 03:04:53 UTC
Created attachment 89809 [details] [review]
Bug 21073: (follow-up) QA fixes after rebase
Comment 10 Agustín Moyano 2019-05-16 03:06:02 UTC
Created attachment 89810 [details] [review]
Bug 22834: Add tests for Koha::Plugins::Base->bundle_path

Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
Comment 11 Agustín Moyano 2019-05-16 03:06:06 UTC
Created attachment 89811 [details] [review]
Bug 22834: Add Koha::Plugins::Base->bundle_path

This patch adds a 'bundle_path' method that return the base path for
assets included in the plugin. The idea is that it will be used for
calculation of the absolute path in the filesystem for static content.

To test:
- Apply the unit tests patch
- Run:
  $ kshell
 k$ prove t/db_dependent/Plugins.t
=> FAIL: The method is not implemented
- Apply this patch
- Run:
 k$ prove t/db_dependent/Plugins.t
=> SUCCESS: Tests pass!
- Sign off :-D

Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
Comment 12 Arthur Suzuki 2019-05-27 12:34:15 UTC
Indeed,
While trying to install some plugin I had to deal with having several "plugin_dir" in my koha-conf.xml.
That led to some errors in the plugin page (see https://github.com/bywatersolutions/koha-plugin-support/issues/9)

That would be solved by this patch.
I guess we can push for QA.
Comment 13 Kyle M Hall 2019-05-29 12:14:32 UTC
Created attachment 90181 [details] [review]
Bug 22834: Add tests for Koha::Plugins::Base->bundle_path

Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 14 Kyle M Hall 2019-05-29 12:14:41 UTC
Created attachment 90182 [details] [review]
Bug 22834: Add Koha::Plugins::Base->bundle_path

This patch adds a 'bundle_path' method that return the base path for
assets included in the plugin. The idea is that it will be used for
calculation of the absolute path in the filesystem for static content.

To test:
- Apply the unit tests patch
- Run:
  $ kshell
 k$ prove t/db_dependent/Plugins.t
=> FAIL: The method is not implemented
- Apply this patch
- Run:
 k$ prove t/db_dependent/Plugins.t
=> SUCCESS: Tests pass!
- Sign off :-D

Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 15 Martin Renvoize 2019-06-18 17:07:03 UTC
Nice work!

Pushed to master for 19.11.00
Comment 16 Lucas Gass 2020-02-06 21:17:35 UTC
backported to 19.05.x for 19.05.08.

backporting this without the bz21073 dependency after speaking with Tomas.
Comment 17 Hayley Pelham 2020-02-10 22:29:12 UTC
Enhancement will not be backported to 18.11.x series.