Bug 28180: Reintroduce and adjust Google Jackets

Test plan:
1. Turn on GoogleJackets
2. Display the cover images in the gallery

Sponsored-by: Gerhard Sondermann Dialog e.K. (presseplus.de, presseshop.at, presseshop.ch)

Signed-off-by: Rasmus Leißner <rasmus.leissner@solutions-factory.de>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-04-20 14:08:01 +02:00
parent ca25ef9673
commit 511720999a
2 changed files with 36 additions and 15 deletions

View file

@ -93,6 +93,13 @@
[% END %]
[% END %]
[% IF ( GoogleJackets ) %]
<div class="cover-image" id="googlejacket-coverimg">
<div title="[% img_title | html %]" class="[% normalized_isbn | html %]" id="gbs-thumbnail-preview" data-use-data-link="1"></div>
<div class="hint">Image from Google Jackets</div>
</div>
[% END %]
[% IF ( Koha.Preference('OPACCoce') && Koha.Preference('CoceProviders') && normalized_isbn ) %]
[% coce_id = normalized_ean || normalized_isbn %]
<div class="cover-image" id="coce-coverimg">
@ -1487,6 +1494,10 @@
[% END %]
[% END %]
[% IF ( GoogleJackets ) %]
KOHA.Google.GetCoverFromIsbn([% covernewwindow | html %]);
[% END %]
[% IF ( Koha.Preference('OpacCoce') && Koha.Preference('CoceProviders') ) %]
KOHA.coce.getURL('[% Koha.Preference('CoceHost') | html %]', '[% Koha.Preference('CoceProviders') | html %]',[% covernewwindow | html %]);
[% END %]
@ -1530,6 +1541,8 @@
}
} else if( div.attr("id") == "syndetics-coverimg" ){
lightbox_descriptions.push("Image from Syndetics")
} else if( div.attr("id") == "googlejacket-coverimg" ){
lightbox_descriptions.push(_("Image from Google Jacket (<a href='%s'>see the original image</a>)").format($(img).data('link')));
} else if( div.attr("id") == "coce-coverimg" ){
// Identify which service's image is being loaded by Coce
var coce_description;

View file

@ -46,22 +46,30 @@ KOHA.Google = {
for (id in booksInfo) {
var book = booksInfo[id];
$("[id^=gbs-thumbnail]."+book.bib_key).each(function() {
var a = document.createElement("a");
a.href = book.info_url;
if (typeof(book.thumbnail_url) != "undefined") {
var img = document.createElement("img");
img.src = book.thumbnail_url;
$(this).empty().append(img);
var re = /^gbs-thumbnail-preview/;
if ( re.exec($(this).attr("id")) ) {
$(this).append(
'<div class="google-books-preview">' +
'<a '+target+'href="' +
book.info_url +
'"><img src="' +
'https://books.google.com/intl/en/googlebooks/images/gbs_preview_sticker1.gif' +
'"></a></div>'
);
if ( $(this).data('use-data-link') ) {
var a = document.createElement("a");
a.href = book.thumbnail_url;
var img = document.createElement("img");
img.src = book.thumbnail_url;
img.setAttribute('data-link', book.info_url);
a.append(img)
$(this).empty().append(a);
} else {
var img = document.createElement("img");
img.src = book.thumbnail_url;
$(this).empty().append(img);
var re = /^gbs-thumbnail-preview/;
if ( re.exec($(this).attr("id")) ) {
$(this).append(
'<div class="google-books-preview">' +
'<a '+target+'href="' +
book.info_url +
'"><img src="' +
'https://books.google.com/intl/en/googlebooks/images/gbs_preview_sticker1.gif' +
'"></a></div>'
);
}
}
} else {
var message = document.createElement("span");