Bugzilla – Attachment 71322 Details for
Bug 18421
Make Coce cover images available for staff search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug18421 - Add Coce to the staff intranet
Bug18421---Add-Coce-to-the-staff-intranet.patch (text/plain), 20.50 KB, created by
Charles Farmer
on 2018-02-07 20:07:23 UTC
(
hide
)
Description:
Bug18421 - Add Coce to the staff intranet
Filename:
MIME Type:
Creator:
Charles Farmer
Created:
2018-02-07 20:07:23 UTC
Size:
20.50 KB
patch
obsolete
>From b981288edd61e52d6576a71224a6f3891fdf184b Mon Sep 17 00:00:00 2001 >From: Charles Farmer <charles.farmer@inLibro.com> >Date: Tue, 6 Feb 2018 18:06:17 -0500 >Subject: [PATCH] Bug18421 - Add Coce to the staff intranet > >TEST PLAN: > 1) Apply the patch with git-bz > 2) Run updatedatabase.pl > 2.1) Console output should confirm database modification > 3) Visit the 'Enhanced Content' tab of admin/syspref > 3.1) ressource is /cgi-bin/koha/admin/preferences.pl?tab=enhanced_content > 3.2) You should see that the previous preference, Coce, is now CoceOPAC, > and that a new preference was added, CoceIntranet > 4) Activate CoceIntranet > 5) Do a search for a book for which you have a Coce cover > 5.1) The cover image url should now point to a provider you defined in Coce > 5.2) Your Coce log should show a query > 6) Click on the book's name to visit the detail.pl page > 6.1) The book's cover should also be provided by Coce on that page >--- > .../atomicupdate/bug_18421_add_coce_intranet.perl | 30 +++++++++++++++ > installer/data/mysql/sysprefs.sql | 3 +- > .../admin/preferences/enhanced_content.pref | 10 ++++- > .../prog/en/modules/catalogue/detail.tt | 36 ++++++++++++++++-- > .../prog/en/modules/catalogue/results.tt | 25 ++++++++++++- > koha-tmpl/intranet-tmpl/prog/js/coce.js | 43 ++++++++++++++++++++++ > .../bootstrap/en/includes/opac-bottom.inc | 2 +- > .../bootstrap/en/includes/shelfbrowser.inc | 2 +- > .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 8 ++-- > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 4 +- > 10 files changed, 147 insertions(+), 16 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_18421_add_coce_intranet.perl > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/coce.js > >diff --git a/installer/data/mysql/atomicupdate/bug_18421_add_coce_intranet.perl b/installer/data/mysql/atomicupdate/bug_18421_add_coce_intranet.perl >new file mode 100755 >index 0000000..74aef50 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_18421_add_coce_intranet.perl >@@ -0,0 +1,30 @@ >+#! /usr/bin/perl >+ >+use strict; >+use warnings; >+use C4::Context; >+use Data::Dumper; >+my $dbh=C4::Context->dbh; >+ >+################# >+# Coce intranet # >+################# >+ >+# validate systempreferences.Coce and save the config for CoceOpac >+my $select = "SELECT * FROM systempreferences WHERE variable = 'Coce'"; >+my $sth = $dbh->prepare($select); >+$sth->execute; >+my $rows = $sth->fetchall_hashref(['variable']); >+my $current_coce_pref = 0; >+if ($rows and $rows->{Coce} and $rows->{Coce}->{value}) { >+ $current_coce_pref = $rows->{Coce}->{value}; >+} >+ >+# add two new systempreferences in order to have distinct behavior between intranet and OPAC >+$dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES >+ ('CoceIntranet','0', NULL, 'If on, enables cover retrieval from the configured Coce server in the staff intranet', 'YesNo'), >+ ('CoceOPAC','$current_coce_pref', NULL, 'If on, enables cover retrieval from the configured Coce server in the OPAC', 'YesNo') >+ ;") or die "Impossible d\'executer cam5446_ajouter_coce_intranet: erreur lors de l'ajout des nouvelles prefs: ". $dbh->errstr . "\n"; >+$dbh->do("DELETE FROM systempreferences WHERE variable = 'Coce';") >+ or die "Impossible d\'executer cam5446_ajouter_coce_intranet: erreur lors de la suppression de la préférence 'Coce': ". $dbh->errstr . "\n"; >+print "cam5446: Add Coce image cache to the staff intranet.\n"; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 68881d0..d0ff927 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -107,7 +107,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'), > ('CircSidebar','0',NULL,'Activate or deactivate the navigation sidebar on all Circulation pages','YesNo'), > ('ClaimsBccCopy','0','','Bcc the ClaimAcquisition and ClaimIssues alerts','YesNo'), >-('Coce','0', NULL, 'If on, enables cover retrieval from the configured Coce server', 'YesNo'), >+('CoceIntranet','0', NULL, 'If on, enables cover retrieval from the configured Coce server in the staff intranet', 'YesNo'), >+('CoceOPAC','0', NULL, 'If on, enables cover retrieval from the configured Coce server in the OPAC', 'YesNo'), > ('CoceHost', '', NULL, 'Coce server URL', 'Free'), > ('CoceProviders', '', 'aws,gb,ol', 'Coce providers', 'multiple'), > ('COinSinOPACResults','1','','If ON, use COinS in OPAC search results page. NOTE: this can slow down search response time significantly','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >index f62882d..be314f7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >@@ -374,11 +374,17 @@ Enhanced Content: > - with OverDrive. > Coce Cover images cache: > - >- - pref: Coce >+ - pref: CoceOPAC > choices: > yes: Enable > no: "Don't enable" >- - a Coce image cache service. >+ - a Coce image cache service in the OPAC. >+ - >+ - pref: CoceIntranet >+ choices: >+ yes: Enable >+ no: "Don't enable" >+ - a Coce image cache service in the staff intranet. > - > - Coce server URL > - pref: CoceHost >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index c3d9df3..9bebd95 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -64,7 +64,7 @@ > <span class="Z3988" title="[% ocoins %]"></span> > [% END %] > >- [% IF ( AmazonCoverImages || LocalCoverImages ) %] >+ [% IF ( AmazonCoverImages || LocalCoverImages || CoceIntranet ) %] > [% IF ( XSLTDetailsDisplay ) %] > <div class="yui-gc"> > <div id="catalogue_detail_biblio" class="yui-u first"> >@@ -125,7 +125,7 @@ > </span> > [% END %] > >- [% IF ( AmazonCoverImages || LocalCoverImages ) %] >+ [% IF ( AmazonCoverImages || LocalCoverImages || CoceIntranet ) %] > </div><div class="yui-u" id="bookcoverimg"> > [% IF ( LocalCoverImages ) %] > <div title="[% biblionumber |url %]" class="[% biblionumber %]" id="local-thumbnail-preview"></div> >@@ -136,6 +136,16 @@ > <img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn %].01.MZZZZZZZ.jpg" alt="" /> > </a></div> > [% END %] >+ [% IF ( CoceIntranet && CoceProviders ) %] >+ [% coce_id = normalized_ean || normalized_isbn %] >+ <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage %]?biblionumber=[% biblionumber |url %]"> >+ [% IF ( coce_id ) %] >+ <span style="block" title="[% biblionumber |url %]" class="[% coce_id %]" id="coce-thumbnail-preview"></span> >+ [% ELSE %] >+ <span class="no-image">No cover image available</span> >+ [% END %] >+ </a> >+ [% END %] > [% END %] > [% ELSE %] > >@@ -199,7 +209,7 @@ > </ul> > </div> > >- [% IF ( AmazonCoverImages || LocalCoverImages ) %] >+ [% IF ( AmazonCoverImages || LocalCoverImages || CoceIntranet ) %] > <div class="yui-u" id="bookcoverimg"> > [% IF ( LocalCoverImages ) %] > <div title="[% biblionumber |url %]" class="[% biblionumber %]" id="local-thumbnail-preview"></div> >@@ -211,6 +221,16 @@ > </a> > </div> > [% END %] >+ [% IF ( CoceIntranet && CoceProviders ) %] >+ [% coce_id = normalized_ean || normalized_isbn %] >+ <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage %]?biblionumber=[% biblionumber |url %]"> >+ [% IF ( coce_id ) %] >+ <span style="block" title="[% biblionumber |url %]" class="[% coce_id %]" id="coce-thumbnail-preview"></span> >+ [% ELSE %] >+ <span class="no-image">No cover image available</span> >+ [% END %] >+ </a> >+ [% END %] > </div> > [% END %] > >@@ -850,6 +870,7 @@ > [% INCLUDE 'catalog-strings.inc' %] > <script type="text/javascript" src="[% interface %]/[% theme %]/js/catalog.js"></script> > [% INCLUDE 'greybox.inc' %] >+ <script type="text/javascript" src="[% interface %]/prog/js/coce.js"></script> > <script type="text/javascript"> > // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html > function verify_images() { >@@ -1005,6 +1026,15 @@ > [% IF LocalCoverImages %] > KOHA.LocalCover.GetCoverFromBibnumber(true); > [% END %] >+ [% >+ CoceIntranet = Koha.Preference('CoceIntranet') >+ CoceProviders = Koha.Preference('CoceProviders') >+ CoceHost = Koha.Preference('CoceHost') >+ %] >+ [% IF ( CoceIntranet && CoceProviders ) %] >+ KOHA.coce.getURL('[% CoceHost %]', '[% CoceProviders %]'); >+ [% END %] >+ > $("body").on("click",".previewMARC", function(e){ > e.preventDefault(); > var page = $(this).attr("href"); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index a01a463..88489f1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -348,7 +348,7 @@ > <!-- TABLE RESULTS START --> > <table> > <tr> >- [% IF ( AmazonCoverImages || LocalCoverImages ) %]<th> </th>[% END %] >+ [% IF ( AmazonCoverImages || LocalCoverImages || CoceIntranet ) %]<th> </th>[% END %] > <th colspan="2">Results</th> > <th>Location</th> > </tr> >@@ -356,7 +356,7 @@ > [% SET MaxSearchResultsItemsPerRecordStatusCheck = Koha.Preference('MaxSearchResultsItemsPerRecordStatusCheck') %] > [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %] > <tr> >- [% IF ( AmazonCoverImages || LocalCoverImages ) %] >+ [% IF ( AmazonCoverImages || LocalCoverImages || CoceIntranet ) %] > <td> > [% IF ( LocalCoverImages) %] > <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage %]?biblionumber=[% SEARCH_RESULT.biblionumber |url %]"> >@@ -373,6 +373,17 @@ > [% END %] > </a> > [% END %] >+ [% IF ( CoceIntranet && CoceProviders ) %] >+ [% coce_id = SEARCH_RESULT.normalized_ean || SEARCH_RESULT.normalized_isbn %] >+ <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage %]?biblionumber=[% SEARCH_RESULT.biblionumber |url %]"> >+ [% IF ( coce_id ) %] >+ <span style="block" title="[% SEARCH_RESULT.biblionumber |url %]" class="[% coce_id %]" id="coce-thumbnail[% loop.count %]"></span> >+ [% ELSE %] >+ <span class="no-image">No cover image available</span> >+ [% END %] >+ </a> >+ [% END %] >+ > </td> > [% END %] > <td> >@@ -621,6 +632,7 @@ > [% INCLUDE 'browser-strings.inc' %] > <script type="text/javascript" src="[% interface %]/js/browser.js"></script> > <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script> >+ <script type="text/javascript" src="[% interface %]/prog/js/coce.js"></script> > <script type="text/javascript"> > var MSG_NO_ITEM_SELECTED = _("Nothing is selected."); > var MSG_NON_RESERVES_SELECTED = _("One or more selected items cannot be placed on hold."); >@@ -743,6 +755,15 @@ > KOHA.LocalCover.LoadResultsCovers(); > [% END %] > >+ [% >+ CoceIntranet = Koha.Preference('CoceIntranet') >+ CoceProviders = Koha.Preference('CoceProviders') >+ CoceHost = Koha.Preference('CoceHost') >+ %] >+ [% IF ( CoceIntranet && CoceProviders ) %] >+ KOHA.coce.getURL('[% CoceHost %]', '[% CoceProviders %]'); >+ [% END %] >+ > $("#select_all").on("click",function(e){ > e.preventDefault(); > selectAll(); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/coce.js b/koha-tmpl/intranet-tmpl/prog/js/coce.js >new file mode 100644 >index 0000000..95669a0 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/coce.js >@@ -0,0 +1,43 @@ >+if (KOHA === undefined || !KOHA) { var KOHA = {}; } >+ >+ >+/** >+ * A namespace for Coce cover images cache >+ */ >+KOHA.coce = { >+ >+ /** >+ * Search all: >+ * <div title="biblionumber" id="isbn" class="coce-thumbnail"></div> >+ * or >+ * <div title="biblionumber" id="isbn" class="coce-thumbnail-preview"></div> >+ * and run a search with all collected isbns to coce cover service. >+ * The result is asynchronously returned, and used to append <img>. >+ */ >+ getURL: function(host,provider,newWindow) { >+ var ids = []; >+ $("[id^=coce-thumbnail]").each(function(i) { >+ var id = $(this).attr("class"); // id=isbn >+ if ( id !== '' ) { ids.push(id); } >+ }); >+ if (ids.length == 0) return; >+ ids = ids.join(','); >+ var coceURL = host + '/cover?id=' + ids + '&provider=' + provider; >+ $.ajax({ >+ url: coceURL, >+ dataType: 'jsonp', >+ success: function(urlPerID){ >+ for (var id in urlPerID) { >+ var url = urlPerID[id]; >+ $("[id^=coce-thumbnail]."+id).each(function() { >+ var img = document.createElement("img"); >+ img.src = url; >+ img.title = url; //FIXME: to delete >+ $(this).html(img); >+ }); >+ } >+ } >+ }); >+ } >+ >+}; >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >index 8346691..848e941 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >@@ -188,7 +188,7 @@ $.widget.bridge('uitooltip', $.ui.tooltip); > //]]> > </script> > [% END %] >-[% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+[% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > <script type="text/javascript" src="[% interface %]/[% theme %]/js/coce.js"></script> > <script type="text/javascript"> > //<![CDATA[ >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/shelfbrowser.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/shelfbrowser.inc >index 161f279..e427b78 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/shelfbrowser.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/shelfbrowser.inc >@@ -53,7 +53,7 @@ > <span class="no-image">No cover image available</span> > [% END %] > [% END %] >- [% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+ [% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > [% coce_id = item.browser_normalized_ean || item.browser_normalized_isbn %] > <div title="[% item.biblionumber |url %]" class="[% coce_id %]" id="coce-thumbnail-preview-[% coce_id %]"></div> > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >index 84e6b7d..1a70c99 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -84,7 +84,7 @@ > [% IF ( GoogleJackets ) %] > <div title="[% biblio.biblionumber %]" class="[% normalized_isbn %]" id="gbs-thumbnail-preview"></div> > [% END %] >- [% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+ [% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > [% coce_id = normalized_ean || normalized_isbn %] > <div style="block" title="[% biblio.biblionumber %]" class="[% coce_id %]" id="coce-thumbnail-preview"></div> > [% END %] >@@ -1531,7 +1531,7 @@ > [% IF ( GoogleJackets ) %] > KOHA.Google.GetCoverFromIsbn([% covernewwindow %]); > [% END %] >- [% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+ [% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > KOHA.coce.getURL('[% Koha.Preference('CoceHost') %]', '[% Koha.Preference('CoceProviders') %]',[% covernewwindow %]); > [% END %] > >@@ -1604,7 +1604,7 @@ > [% IF ( GoogleJackets ) %] > KOHA.Google.GetCoverFromIsbn([% covernewwindow %]); > [% END %] >- [% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+ [% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > KOHA.coce.getURL('[% Koha.Preference('CoceHost') %]', '[% Koha.Preference('CoceProviders') %]',[% covernewwindow %]); > [% END %] > [% IF OpenLibraryCovers %] >@@ -1630,7 +1630,7 @@ > [% IF ( GoogleJackets ) %] > KOHA.Google.GetCoverFromIsbn([% covernewwindow %]); > [% END %] >- [% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+ [% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > KOHA.coce.getURL('[% Koha.Preference('CoceHost') %]', '[% Koha.Preference('CoceProviders') %]',[% covernewwindow %]); > [% END %] > [% IF OpenLibraryCovers %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >index 085f6c5..05ab121 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -255,7 +255,7 @@ > [% END %] > [% END %] > >- [% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+ [% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > [% coce_id = SEARCH_RESULT.normalized_ean || SEARCH_RESULT.normalized_isbn %] > [% IF ( coce_id ) %] > <span style="block" title="[% SEARCH_RESULT.biblionumber |url %]" class="[% coce_id %]" id="coce-thumbnail[% loop.count %]"></span> >@@ -973,7 +973,7 @@ $(document).ready(function(){ > [% IF OpenLibraryCovers %]KOHA.OpenLibrary.GetCoverFromIsbn();[% END %] > [% IF OPACLocalCoverImages %]KOHA.LocalCover.GetCoverFromBibnumber(false);[% END %] > [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %] >-[% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+[% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > KOHA.coce.getURL('[% Koha.Preference('CoceHost') %]', '[% Koha.Preference('CoceProviders') %]'); > [% END %] > >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18421
:
71322
|
71977
|
72772
|
73401
|
73495
|
74252
|
77597
|
77598
|
77599
|
77764
|
77765
|
80137
|
80138
|
80139
|
83633
|
83634
|
83635
|
83636
|
91552
|
91553
|
91554
|
91555
|
91786
|
91787
|
91788
|
91789
|
93654
|
93655
|
93656
|
93657