[Bug 22835] New: Serve static files from plugins through the API
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Bug ID: 22835 Summary: Serve static files from plugins through the API Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: new feature Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.org Target Milestone: --- The last step to avoid having to tweak (or even depend on) Apache for plugins is having a way to serve static files through the OpenAPI spec. The plugins serving static files would supply a static_files_routes (or similar) method that should return the OpenAPI spec for a directory tree bundled with the plugin itself. This could be done manually, but a way to auto-generate this spec will be added to the KitchenSink plugin so it can be automated through the use of gulp. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |agustinmoyano@theke.io |ity.org | Depends on| |22834 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22834 [Bug 22834] Add a method for plugins to return the absolute path for bundled files -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Change sponsored?|--- |Sponsored CC| |kyle@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Agustín Moyano <agustinmoyano@theke.io> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Agustín Moyano <agustinmoyano@theke.io> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Trivial patch Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #1 from Agustín Moyano <agustinmoyano@theke.io> --- Created attachment 89262 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=89262&action=edit Bug 22835: Serve plugin static files through API This patch serves static files declared within plugins. To declare static files the plugin must implement the method 'static_routes' which retrieves the spec of static file routes to add to the API. Once those routes are added to the API, the become available through the /api/v1/contrib/<api_namespace>/static/<path>/<to>/<file>/<filename> endpoint. To test: 1) Install bug-22835-plugin.kpz 2) Point your browser to /api/v1/contrib/kitchensink/static/static_files/mm.gif CHECK => No file is served 3) Apply this patch 4) restart_all 5) Repeat step 2. SUCCESS => File is served! 6) Sign off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #2 from Agustín Moyano <agustinmoyano@theke.io> ---
1) Install bug-22835-plugin.kpz
KPZ available at https://github.com/agmoyano/koha-plugin-kitchen-sink/releases/download/bug-2... -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Agustín Moyano <agustinmoyano@theke.io> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |agustinmoyano@theke.io -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Agustín Moyano <agustinmoyano@theke.io> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #89262|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #3 from Agustín Moyano <agustinmoyano@theke.io> --- Created attachment 89263 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=89263&action=edit Bug 22835: Serve plugin static files through API This patch serves static files declared within plugins. To declare static files the plugin must implement the method 'static_routes' which retrieves the spec of static file routes to add to the API. Once those routes are added to the API, the become available through the /api/v1/contrib/<api_namespace>/static/<path>/<to>/<file>/<filename> endpoint. To test: 1) Install bug-22835-plugin.kpz 2) Point your browser to /api/v1/contrib/kitchensink/static/static_files/mm.gif CHECK => No file is served 3) Apply this patch 4) restart_all 5) Repeat step 2. SUCCESS => File is served! 6) Sign off Sponsored-by: Theke -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #4 from Agustín Moyano <agustinmoyano@theke.io> --- Created attachment 89280 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=89280&action=edit Bug 22835: (follow-up) Remove unwanted warn -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Arthur Suzuki <arthur.suzuki@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |arthur.suzuki@biblibre.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Fridolin SOMERS <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fridolin.somers@biblibre.co | |m -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Arthur Suzuki <arthur.suzuki@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #89263|0 |1 is obsolete| | --- Comment #5 from Arthur Suzuki <arthur.suzuki@biblibre.com> --- Created attachment 89663 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=89663&action=edit Bug 22835: Serve plugin static files through API This patch serves static files declared within plugins. To declare static files the plugin must implement the method 'static_routes' which retrieves the spec of static file routes to add to the API. Once those routes are added to the API, the become available through the /api/v1/contrib/<api_namespace>/static/<path>/<to>/<file>/<filename> endpoint. To test: 1) Install bug-22835-plugin.kpz 2) Point your browser to /api/v1/contrib/kitchensink/static/static_files/mm.gif CHECK => No file is served 3) Apply this patch 4) restart_all 5) Repeat step 2. SUCCESS => File is served! 6) Sign off Sponsored-by: Theke Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Arthur Suzuki <arthur.suzuki@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #89280|0 |1 is obsolete| | --- Comment #6 from Arthur Suzuki <arthur.suzuki@biblibre.com> --- Created attachment 89664 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=89664&action=edit Bug 22835: (follow-up) Remove unwanted warn Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Arthur Suzuki <arthur.suzuki@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #7 from Arthur Suzuki <arthur.suzuki@biblibre.com> --- Works as expected, the gif provided as an example is very rewarding, thanks ;) Made my day! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@ptfs-europe | |.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rel_19_05_candidate -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #8 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- The patch contains some unexplained commented code : - @plugins = grep { $_->api_namespace } @plugins; + #@plugins = grep { $_->api_namespace } @plugins; + # $c->res->headers->content_type("image/jpeg"); -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #9 from Agustín Moyano <agustinmoyano@theke.io> --- Created attachment 89812 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=89812&action=edit Bug 22835: (follow-up) Remove comented code -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #10 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- I like the idea behind this, but it feels somewhat wrong that it's under the /api path.. it's not really serving an api. Trying to work out if we could instead use `/contrib/<plugin_namespace>/path/to/file.js` or something similar. Yes, it's one more route in the vhosts we'd need to ship, but would serve the same purpose of not requiring server admins to mess with the vhost for each plugin. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|rel_19_05_candidate | CC| |nick@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #11 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- What do you say Tomás ? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #12 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to Fridolin SOMERS from comment #11)
What do you say Tomás ?
I haven't pondered the effort required to implement a whole new endpoint in our current complex setup - New Apache config - New plack tweaks - New mojo app and controller? It all seems too much given the simplicity of this dev. I'd rather just allow an array of openapi specs and leave to the plugin authors the decision of making it a real API or not. The main dev here is the controller class for static files and I think it is pretty cool :-) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Arthur Suzuki <arthur.suzuki@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Pushed for QA --- Comment #13 from Arthur Suzuki <arthur.suzuki@biblibre.com> --- Thomas, I definitely agree with you :) Plus I've played a bit around the plugin system during this KohaCon! Tweaking into Plack + Apache/Nginx configuration quickly becomes a nightmare whenever several <plugin_dir> are defined in koha-conf.xml Also : I've had the opportunity to meet in person with Martin (great to meet IRL btw!!!) who also agreed on the greatness of the feature and saying we might just ignore his comment and take another opportunity to refactor/improve later on. Let's push it for QA! \o/ Arthur -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #14 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to Arthur Suzuki from comment #13)
Thomas, I definitely agree with you :)
Plus I've played a bit around the plugin system during this KohaCon! Tweaking into Plack + Apache/Nginx configuration quickly becomes a nightmare whenever several <plugin_dir> are defined in koha-conf.xml
Also : I've had the opportunity to meet in person with Martin (great to meet IRL btw!!!) who also agreed on the greatness of the feature and saying we might just ignore his comment and take another opportunity to refactor/improve later on.
Let's push it for QA! \o/ Arthur
So now you made our day :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |katrin.fischer@bsz-bw.de Status|Pushed for QA |Failed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Signed Off --- Comment #15 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- We don't really use 'pushed for QA' (meaning pushed to a branch in the repo) right now. Changing it to the more fitting "Signed off" :) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Michal Denar <black23@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |black23@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Michal Denar <black23@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |josef.moravec@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #89663|0 |1 is obsolete| | Attachment #89664|0 |1 is obsolete| | Attachment #89812|0 |1 is obsolete| | --- Comment #16 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 90148 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=90148&action=edit Bug 22835: Serve plugin static files through API This patch serves static files declared within plugins. To declare static files the plugin must implement the method 'static_routes' which retrieves the spec of static file routes to add to the API. Once those routes are added to the API, the become available through the /api/v1/contrib/<api_namespace>/static/<path>/<to>/<file>/<filename> endpoint. To test: 1) Install bug-22835-plugin.kpz 2) Point your browser to /api/v1/contrib/kitchensink/static/static_files/mm.gif CHECK => No file is served 3) Apply this patch 4) restart_all 5) Repeat step 2. SUCCESS => File is served! 6) Sign off Sponsored-by: Theke Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #17 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 90149 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=90149&action=edit Bug 22835: (follow-up) Remove unwanted warn Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #18 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 90150 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=90150&action=edit Bug 22835: (follow-up) Remove comented code Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |19.11.00 released in| | Status|Passed QA |Pushed to Master -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #19 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Nice work! Pushed to master for 19.11.00 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #20 from Arthur Suzuki <arthur.suzuki@biblibre.com> --- Yeay! Thanks everyone! \o/ -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #21 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- And now we talk nicely to Fridolin and ask if he's going to carry forward my policy during tenure as RMaint to backport non-breaking Plugin and API enhancement/new features to the stable branch ;) I believe in this case the whole dependency list should apply without issue and not cause any regressions. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #22 from Arthur Suzuki <arthur.suzuki@biblibre.com> --- Oh, that would be great :) he's already in the CC's list btw! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |release-notes-needed -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Text to go in the| |This development allows release notes| |plugins to serve static | |files through the API | |without the requirement to | |tweak the Apache | |configuration files. Routes | |to the static files tree | |are automatically loaded | |from a specially crafted | |file the plugin authors | |need to include in the | |distributed .kpz files. QA Contact|testopia@bugs.koha-communit |kyle@bywatersolutions.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #23 from Katrin Fischer <katrin.fischer@bsz-bw.de> ---
This development allows plugins to serve static files through the API without the requirement to tweak the Apache configuration files. Routes to the static files tree are automatically loaded from a specially crafted file the plugin authors need to include in the distributed .kpz files.
Could we document this somewhere? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|Architecture, internals, |Plugin architecture |and plumbing | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #24 from Tomás Cohen Arazi <tomascohen@gmail.com> --- @fridolin can we backport this? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 --- Comment #25 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- (In reply to Tomás Cohen Arazi from comment #24)
@fridolin can we backport this?
I'd love to but I'm actually on last release. You will have to see this with next maintainer. Best regards, -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Text to go in the|This development allows |This new feature allows release notes|plugins to serve static |plugin authors to serve |files through the API |static files through the |without the requirement to |API without the requirement |tweak the Apache |to tweak the Apache |configuration files. Routes |configuration files. Routes |to the static files tree |to the static files tree |are automatically loaded |are automatically loaded |from a specially crafted |from a specially crafted |file the plugin authors |file the plugin authors |need to include in the |need to include in the |distributed .kpz files. |distributed .kpz files. | | | |**Warning**: Care should be | |taken when installing any | |plugins and only plugins | |you trust should be used. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lucas@bywatersolutions.com Keywords|release-notes-needed | --- Comment #26 from Tomás Cohen Arazi <tomascohen@gmail.com> --- It applies to the 19.05.x branch! And works! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Lucas Gass <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to master |Pushed to stable Version(s)|19.11.00 |19.11.00, 19.05.08 released in| | --- Comment #27 from Lucas Gass <lucas@bywatersolutions.com> --- backported to 19.05.x for 19.05.08 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Lucas Gass <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to stable |Pushed to oldstable -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22835 Hayley Mapley <hayleymapley@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hayleymapley@catalyst.net.n | |z --- Comment #28 from Hayley Mapley <hayleymapley@catalyst.net.nz> --- Enhancement will not be backported to 18.11.x series. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org