Requests have been made for cover art to be provided by BDS. This bug is to create some hooks in the Koha templates that allow a plugin to attach cover art to the sliders. The idea is that these hooks could be used for any provider using the same format of plugin, not just BDS.
Created attachment 145457 [details] [review] Bug 32680: Add hooks to allow cover art to come from plugins This patch adds hooks to Koha core that allow a plugin for cover art to inject the images into the OPAC and staff client. These hooks could be re-used for other providers. As an example, a plugin has been created for BDS covers, the link is in another comment Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art
Plugin link: https://github.com/PTFS-Europe/koha-plugin-addBDSCovers
*** Bug 19044 has been marked as a duplicate of this bug. ***
Created attachment 145458 [details] [review] Bug 32680: Add hooks to allow cover art to come from plugins This patch adds hooks to Koha core that allow a plugin for cover art to inject the images into the OPAC and staff client. These hooks could be re-used for other providers. As an example, a plugin has been created for BDS covers, the link is in another comment Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art
Created attachment 145459 [details] [review] Bug 32680: Add hooks to allow cover art to come from plugins This patch adds hooks to Koha core that allow a plugin for cover art to inject the images into the OPAC and staff client. These hooks could be re-used for other providers. As an example, a plugin has been created for BDS covers, the link is in another comment Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art
Created attachment 145474 [details] [review] Bug 32680: Add hooks to allow cover art to come from plugins This patch adds hooks to Koha core that allow a plugin for cover art to inject the images into the OPAC and staff client. These hooks could be re-used for other providers. As an example, a plugin has been created for BDS covers, the link is in another comment Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art
Created attachment 145475 [details] [review] Bug 32680: Add hooks to allow cover art to come from plugins This patch adds hooks to Koha core that allow a plugin for cover art to inject the images into the OPAC and staff client. These hooks could be re-used for other providers. As an example, a plugin has been created for BDS covers, the link is in another comment Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art
Comment on attachment 145475 [details] [review] Bug 32680: Add hooks to allow cover art to come from plugins Review of attachment 145475 [details] [review]: ----------------------------------------------------------------- Overall, I like the idea, but I'm not sure about the implementation. I think this could benefit from a dedicated plugin hook. ::: catalogue/detail.pl @@ +684,5 @@ > > $template->param(biblio => $biblio); > > +my $intranet_js_plugins = Koha::Template::Plugin::KohaPlugins->get_plugins_intranet_js; > +if(index($intranet_js_plugins, "Cover Image Plugin") != -1){ To me this looks like hacking a different plugin hook rather than adding a plugin hook https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks ::: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ +1310,4 @@ > [% Asset.js("js/recalls.js") | $raw %] > [% Asset.js("js/coce.js") | $raw %] > [% Asset.js("lib/Chocolat/js/chocolat.js") | $raw %] > + [% IF ( Cover_Images_Required ) %] I'd suggest going with CoverImagesRequired. We tend to use camel case rather than snake case in the templates. ::: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ +465,2 @@ > <td class="bookcoverimg"> > + <div id="cover-slides-[% SEARCH_RESULT.biblionumber | html %]" class="cover-slides search_cover_images_required" data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]"> This seems like it would be the place to add the SEARCH_RESULT data you would need for your plugin. @@ +782,5 @@ > [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] > [% INCLUDE 'select2.inc' %] > + [% IF ( Cover_Images_Required ) %] > + <script> > + const search_results = {}; It seems strange to me to create a separate data structure when you already have the HTML available.
I think David has lots of valid points.. marking failed for now and I'll work with Matt to refine it a bit :). It's all good learning
Created attachment 145898 [details] [review] Bug 32680: (follow-up) Add new plugin hook and reformat data structures This patch adds two new plugin hooks to add cover images and adds data tags to the templates to provide the isbn numbers for this Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art
Created attachment 145899 [details] [review] Bug 32680: (follow-up) Add new plugin hook and reformat data structures This patch adds two new plugin hooks to add cover images and adds data tags to the templates to provide the isbn numbers for this Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art
Based on David's comments I've added two new plugin hooks to handle injecting the plugin into the template and also modified the data structuring to use the HTML datasets rather than a new javascript object
Created attachment 146695 [details] [review] Bug 32680: (follow-up) Add new plugin hook and reformat data structures This patch adds two new plugin hooks to add cover images and adds data tags to the templates to provide the isbn numbers for this Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art Sponsored-by: PTFS Europe
Created attachment 147992 [details] [review] Bug 32680: Add hooks to allow cover art to come from plugins This patch adds hooks to Koha core that allow a plugin for cover art to inject the images into the OPAC and staff client. These hooks could be re-used for other providers. As an example, a plugin has been created for BDS covers, the link is in another comment Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art
Created attachment 147993 [details] [review] Bug 32680: (follow-up) Add new plugin hook and reformat data structures This patch adds two new plugin hooks to add cover images and adds data tags to the templates to provide the isbn numbers for this Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art Sponsored-by: PTFS Europe
Sorry, patch doesn't apply: Applying: Bug 32680: Add hooks to allow cover art to come from plugins .git/rebase-apply/patch:74: trailing whitespace. var normalized_isbn = "[% normalized_isbn %]"; .git/rebase-apply/patch:118: trailing whitespace. [% END %] .git/rebase-apply/patch:143: trailing whitespace. var normalized_isbn = "[% normalized_isbn %]"; .git/rebase-apply/patch:180: trailing whitespace. [% END %] warning: 4 lines add whitespace errors. Using index info to reconstruct a base tree... M koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt M koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt .git/rebase-apply/patch:74: trailing whitespace. var normalized_isbn = "[% normalized_isbn %]"; .git/rebase-apply/patch:118: trailing whitespace. [% END %] .git/rebase-apply/patch:143: trailing whitespace. var normalized_isbn = "[% normalized_isbn %]"; .git/rebase-apply/patch:180: trailing whitespace. [% END %] warning: 4 lines applied after fixing whitespace errors. Falling back to patching base and 3-way merge... Auto-merging koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt error: Failed to merge in the changes. Patch failed at 0001 Bug 32680: Add hooks to allow cover art to come from plugins
Created attachment 147996 [details] [review] Bug 32680: Add hooks to allow cover art to come from plugins This patch adds hooks to Koha core that allow a plugin for cover art to inject the images into the OPAC and staff client. These hooks could be re-used for other providers. As an example, a plugin has been created for BDS covers, the link is in another comment Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art
Created attachment 147997 [details] [review] Bug 32680: (follow-up) Add new plugin hook and reformat data structures This patch adds two new plugin hooks to add cover images and adds data tags to the templates to provide the isbn numbers for this Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art Sponsored-by: PTFS Europe
Re-rebased, hopefully this applies now :)
(In reply to Matt Blenkinsop from comment #19) > Re-rebased, hopefully this applies now :) Sorry Matt, still getting the same error :(
Created attachment 148129 [details] [review] Bug 32680: (follow-up) Add new plugin hook and reformat data structures This patch adds two new plugin hooks to add cover images and adds data tags to the templates to provide the isbn numbers for this Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art Sponsored-by: PTFS Europe
Hi Sally, I've made some minor changes and the QA tests are all passing on my end, could you try again and see if you get the same error? Thanks
Sorry Matt, I'm still getting the same error: 148129 - Bug 32680: (follow-up) Add new plugin hook and reformat data structures Applying: Bug 32680: Add hooks to allow cover art to come from plugins .git/rebase-apply/patch:74: trailing whitespace. var normalized_isbn = "[% normalized_isbn %]"; .git/rebase-apply/patch:118: trailing whitespace. [% END %] .git/rebase-apply/patch:143: trailing whitespace. var normalized_isbn = "[% normalized_isbn %]"; .git/rebase-apply/patch:180: trailing whitespace. [% END %] warning: 4 lines add whitespace errors. Using index info to reconstruct a base tree... M koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt M koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt .git/rebase-apply/patch:74: trailing whitespace. var normalized_isbn = "[% normalized_isbn %]"; .git/rebase-apply/patch:118: trailing whitespace. [% END %] .git/rebase-apply/patch:143: trailing whitespace. var normalized_isbn = "[% normalized_isbn %]"; .git/rebase-apply/patch:180: trailing whitespace. [% END %] warning: 4 lines applied after fixing whitespace errors. Falling back to patching base and 3-way merge... Auto-merging koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt error: Failed to merge in the changes. Patch failed at 0001 Bug 32680: Add hooks to allow cover art to come from plugins I can leave it for someone else to try, see if they get the same error?
Hi Sally, Thanks for trying again. It looks like there is an error in the sandboxes when applying a bug after sandbox creation. Martin has just created a sandbox with the bug already provisioned if you could try testing in that one? Thanks, Matt
Created attachment 148158 [details] [review] Bug 32680: Add hooks to allow cover art to come from plugins This patch adds hooks to Koha core that allow a plugin for cover art to inject the images into the OPAC and staff client. These hooks could be re-used for other providers. As an example, a plugin has been created for BDS covers, the link is in another comment Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art Signed-off-by: Martin <martin.renvoize@ptfs-europe.com>
Created attachment 148159 [details] [review] Bug 32680: (follow-up) Add new plugin hook and reformat data structures This patch adds two new plugin hooks to add cover images and adds data tags to the templates to provide the isbn numbers for this Test plan: 1) Apply patch 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art Sponsored-by: PTFS Europe Signed-off-by: Martin <martin.renvoize@ptfs-europe.com>
(In reply to Matt Blenkinsop from comment #24) > Hi Sally, > > Thanks for trying again. It looks like there is an error in the sandboxes > when applying a bug after sandbox creation. Martin has just created a > sandbox with the bug already provisioned if you could try testing in that > one? > > Thanks, > Matt Oh, I should've realised it was a sandbox error! :( Thanks both - have tested in the OPAC and the staff client, and all is working well, so signing off (masquerading as Martin!).
I like this idea, it expands upon the current: CustomCoverImagesURL system preference, and would allow for adding services that need authentication, or more specialized formats. There are a few issues I see: 1 - In both the staff and opac we have lines like below in the scripts: use Koha::Template::Plugin::KohaPlugins; ... my $intranet_cover_images_plugins = Koha::Template::Plugin::KohaPlugins->get_plugins_intranet_cover_images; if($intranet_cover_images_plugins){ $template->param( CoverImagesRequired => 1 ) } I don't think we should be calling template plugins in the scripts. We can do something like: [% SET CoverImagesRequired = KohaPlugins.get_plugins_intranet_cover_images %] early in the template, then add the code in later like: [% CoverImagesRequired | $raw %] 2 - I am not sure the code below is necessary, we add normalized isbn to the results, and the plugin seems to simply fetch the results with JS " const search_results_images = document.querySelectorAll('.cover_images_required');" Am I correct? + [% IF ( CoverImagesRequired ) %] + <script> + const search_results = {}; + [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %] + var cover_index = "[% loop.count | html %]"; + search_results[cover_index] = {}; + search_results[cover_index].isbn = "[% SEARCH_RESULT.normalized_isbn | html %]"; + search_results[cover_index].biblionumber = "[% SEARCH_RESULT.biblionumber | html %]"; + search_results[cover_index].processedBiblio = "[% PROCESS biblio_a_href biblionumber => SEARCH_RESULT.biblionumber | html %]"; + [% END %] + </script> + [% END %] 3 - CoverImagesRequired is misleading. I think it should be renamed like 'CoverImagePlugins' 4 - I would suggest squashing the patches, as the second rewrites the first, it would make for easier review
Created attachment 149868 [details] [review] Bug 32680: Add cover images plugin hook This patch adds a plugin hook to inject cover images into the templates Test plan: 1) Apply all patches 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art
Created attachment 149869 [details] [review] Bug 32680: Add classes to template files This patch adds the classes to the template files so that the plugin hook can identify that cover images are required and where to inject them Test plan as per first commit Sponsored-by: PTFS Europe
QA comments addressed: All changes removed from .pl files and plugins dealt with exclusively in the template files Unnecessary JS variables removed from template scripts Class names updated as suggested, plugin .kpz files also updated and re-released to reflect this Patch also rebased, hopefully everything should work as expected!
Created attachment 149886 [details] [review] Bug 32680: Add classes to template files This patch adds the classes to the template files so that the plugin hook can identify that cover images are required and where to inject them Test plan as per first commit Sponsored-by: PTFS Europe
Created attachment 149887 [details] [review] Bug 32680: Add cover images plugin hook This patch adds a plugin hook to inject cover images into the templates Test plan: 1) Apply all patches 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Created attachment 149888 [details] [review] Bug 32680: Add classes to template files This patch adds the classes to the template files so that the plugin hook can identify that cover images are required and where to inject them Test plan as per first commit Sponsored-by: PTFS Europe Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Created attachment 149889 [details] [review] Bug 32680: (QA follow-up) Fix opac call and remove second fetch Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Please minor rebase required. Will be included in next release.
Created attachment 151191 [details] [review] Bug 32680: Add cover images plugin hook This patch adds a plugin hook to inject cover images into the templates Test plan: 1) Apply all patches 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Created attachment 151192 [details] [review] Bug 32680: Add classes to template files This patch adds the classes to the template files so that the plugin hook can identify that cover images are required and where to inject them Test plan as per first commit Sponsored-by: PTFS Europe Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Created attachment 151193 [details] [review] Bug 32680: (QA follow-up) Fix opac call and remove second fetch Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Rebased to latest master version
Pushed to master for 23.05. Nice work everyone, thanks!
Hi Matt, could you please complete my entry for this on https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks ?
You beat me to it, I requested my wiki account last night to add it to the list and hadn't got round to logging in yet! I'll complete it as soon as I can log in
(In reply to Matt Blenkinsop from comment #43) > You beat me to it, I requested my wiki account last night to add it to the > list and hadn't got round to logging in yet! I'll complete it as soon as I > can log in :) It looks like David already moderated your request last night - could you please check?
Enhancement - not backporting to 22.11.x
Great work!... but I've noticed that this doesn't apply on shelves (neither in OPAC or Staff), which I assume it should. Files that needs to be altered I guess is: opac-shelves.tt and shelves.tt
(In reply to Johan Sahlberg from comment #46) > Great work!... but I've noticed that this doesn't apply on shelves (neither > in OPAC or Staff), which I assume it should. > Files that needs to be altered I guess is: opac-shelves.tt and shelves.tt Hi, as this change has already been released, please file a new bug. You can use the "depends on" in your new bug to link to this one and it will also create a notice informing people watching this bug.