Bug 22834 - Add a method for plugins to return the absolute path for bundled files
Summary: Add a method for plugins to return the absolute path for bundled files
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Plugin architecture (show other bugs)
Version: master
Hardware: All All
: P5 - low new feature (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Testopia
URL:
Keywords:
Depends on: 21073
Blocks: 22835
  Show dependency treegraph
 
Reported: 2019-05-02 18:29 UTC by Tomás Cohen Arazi
Modified: 2019-11-27 10:56 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
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


Attachments
Bug 22834: Add tests for Koha::Plugins::Base->bundle_path (1.54 KB, patch)
2019-05-02 18:54 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 22834: Add Koha::Plugins::Base->bundle_path (1.49 KB, patch)
2019-05-02 18:54 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 22834: Add tests for Koha::Plugins::Base->bundle_path (1.54 KB, patch)
2019-05-02 19:16 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 22834: Add Koha::Plugins::Base->bundle_path (1.49 KB, patch)
2019-05-02 19:16 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 22834: Add tests for Koha::Plugins::Base->bundle_path (1.60 KB, patch)
2019-05-13 13:40 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 22834: Add Koha::Plugins::Base->bundle_path (1.55 KB, patch)
2019-05-13 13:40 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 21073: (follow-up) QA fixes after rebase (4.58 KB, patch)
2019-05-16 03:04 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 22834: Add tests for Koha::Plugins::Base->bundle_path (2.55 KB, patch)
2019-05-16 03:06 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 22834: Add Koha::Plugins::Base->bundle_path (1.55 KB, patch)
2019-05-16 03:06 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 22834: Add tests for Koha::Plugins::Base->bundle_path (2.61 KB, patch)
2019-05-29 12:14 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 22834: Add Koha::Plugins::Base->bundle_path (1.62 KB, patch)
2019-05-29 12:14 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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