Bugzilla – Attachment 21162 Details for
Bug 9580
Cover image from Coce, a remote image URL cache
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch (v3 rebased on master)
0001-Bug-9580-Cover-images-from-Coce-a-remote-image-URL-c.patch (text/plain), 10.30 KB, created by
Frédéric Demians
on 2013-09-18 11:15:00 UTC
(
hide
)
Description:
Proposed patch (v3 rebased on master)
Filename:
MIME Type:
Creator:
Frédéric Demians
Created:
2013-09-18 11:15:00 UTC
Size:
10.30 KB
patch
obsolete
>From 0214d9828ef7ae2a435d4d37ec8c3efce2ee3c9d Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Demians?= <f.demians@tamil.fr> >Date: Thu, 7 Feb 2013 09:55:29 +0100 >Subject: [PATCH] Bug 9580 Cover images from Coce, a remote image URL cache > >Add to Koha support for displaying Book cover requested to Coce, a >remote image URL cache: > > https://github.com/fredericd/coce > >With this enhancement, cover images are not fetched directly from >Amazon, Google, and so on. Their URL are requested via a web service to >Coce which manages a cache of URLs. > >Three cover image providers are now available: Google Books (gb), Amazon >(aws), and Open Library (ol). Two system preferences enable this service: > > - CoceHost - URL of Coce server > - CoceProviders - Ordered list of requested providers. For example > gb,aws,ol, will return the first available URL from those providers. > >Several advantages to this architecture: > > - If a book cover is not available from a provider, but is available > from another one, Koha will be able to display a book cover, which > isn't the case now > - Since URLs are cached, it isn't necessary for each book cover to > request, again and again, the provider, and several of them if > necessary. > - Amazon book covers are retrieved with Amazon Product Advertising > API, which means that more covers are retrieved (ISBN13). > >Test plan: > >- Apply this patch >- You can verify that nothing has changed on OPAC result and detail > page, since new syspref haven't been filled >- Install Code: https://github.com/fredericd/coce > Or ask me directly for the URL of a Coce server >- In sysprefs, tab Enhanced content, modify: > CoceHost -- enter the URL of your Coce server > CoceProviders -- fill with: gb,aws,ol >- Do a search. On result page, and detail page, you will see cover > images originating from the 3 providers: fly over the image to see its > URL. Try to compare with a Koha with just GoogleJacket or Amazon cover > to confirm that you have more images. Verify that it's quick, and even > quicker for cacher images URLs. >--- > C4/Auth.pm | 2 + > .../admin/preferences/enhanced_content.pref | 9 ++++ > .../opac-tmpl/prog/en/includes/doc-head-close.inc | 3 + > koha-tmpl/opac-tmpl/prog/en/js/coce.js | 42 ++++++++++++++++++++ > koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 7 +++ > .../opac-tmpl/prog/en/modules/opac-results.tt | 11 ++++- > 6 files changed, 72 insertions(+), 2 deletions(-) > create mode 100644 koha-tmpl/opac-tmpl/prog/en/js/coce.js > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 1e17e59..b9647ca 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -303,6 +303,8 @@ sub get_template_and_user { > "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, > EnhancedMessagingPreferences => C4::Context->preference('EnhancedMessagingPreferences'), > GoogleJackets => C4::Context->preference("GoogleJackets"), >+ CoceHost => C4::Context->preference("CoceHost"), >+ CoceProviders => C4::Context->preference("CoceProviders"), > OpenLibraryCovers => C4::Context->preference("OpenLibraryCovers"), > KohaAdminEmailAddress => "" . C4::Context->preference("KohaAdminEmailAddress"), > LoginBranchcode => (C4::Context->userenv?C4::Context->userenv->{"branch"}:undef), >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 627f095..cf639aa 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 >@@ -337,3 +337,12 @@ Enhanced Content: > - "Show items from the OverDrive catalog of library #" > - pref: OverDriveLibraryID > - . >+ Coce Cover images cache: >+ - >+ - Coce server URL >+ - pref: CoceHost >+ class: url >+ - >+ - Providers >+ - pref: CoceProviders >+ - 'separated by comma, for example: aws,gb. Leave empty not to activate this service.' >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc >index 66666f4..ecb1b25 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc >@@ -112,6 +112,9 @@ > //]]> > </script> > [% END %] >+[% IF CoceProviders %] >+<script type="text/javascript" src="[% themelang %]/js/coce.js"></script> >+[% END %] > [% IF OpenLibraryCovers %] > <script type="text/javascript" src="[% themelang %]/js/openlibrary.js"></script> > <script type="text/javascript"> >diff --git a/koha-tmpl/opac-tmpl/prog/en/js/coce.js b/koha-tmpl/opac-tmpl/prog/en/js/coce.js >new file mode 100644 >index 0000000..523030f >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/prog/en/js/coce.js >@@ -0,0 +1,42 @@ >+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) { >+ ids.push($(this).attr("class")); // id=isbn >+ }); >+ 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).append(img); >+ }); >+ } >+ } >+ }); >+ } >+ >+}; >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >index d6520f5..f97097d 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >@@ -139,6 +139,11 @@ > [% IF ( GoogleJackets ) %] > KOHA.Google.GetCoverFromIsbn([% covernewwindow %]); > [% END %] >+ >+[% IF ( CoceProviders ) %] >+KOHA.coce.getURL('[% CoceHost %]', '[% CoceProviders %]',[% covernewwindow %]); >+[% END %] >+ > [% IF OpenLibraryCovers %] > KOHA.OpenLibrary.GetCoverFromIsbn(); > [% END %] >@@ -541,6 +546,8 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > > [% ELSE %]<span class="no-image">No cover image available</span>[% END %][% END %][% END %] > >+[% IF ( CoceProviders ) %]<div style="block" title="[% biblionumber |url %]" class="[% normalized_isbn %]" id="coce-thumbnail-preview"></div>[% END %] >+ > [% IF ( GoogleJackets ) %]<div style="block" title="[% biblionumber |url %]" class="[% normalized_isbn %]" id="gbs-thumbnail-preview"></div>[% END %] > [% IF OpenLibraryCovers %]<div style="block" title="[% biblionumber |url %]" class="[% normalized_isbn %]" id="openlibrary-thumbnail-preview"></div>[% END %] > [% IF ( BakerTaylorEnabled ) %][% IF ( normalized_isbn ) %][% IF ( OPACurlOpenInNewWindow ) %]<a href="https://[% BakerTaylorBookstoreURL |html %][% normalized_isbn %]" target="_blank"><img alt="See Baker & Taylor" src="[% BakerTaylorImageURL |html %][% normalized_isbn %]" /></a>[% ELSE %]<a href="https://[% BakerTaylorBookstoreURL |html %][% normalized_isbn %]"><img alt="See Baker & Taylor" src="[% BakerTaylorImageURL |html %][% normalized_isbn %]" /></a>[% END %][% END %][% END %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >index 9235b2b..7c04489 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >@@ -333,8 +333,9 @@ $(document).ready(function(){ > [% IF OPACLocalCoverImages %]KOHA.LocalCover.GetCoverFromBibnumber(false);[% END %] > [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %] > >+<<<<<<< HEAD > [% IF ( DidYouMean ) %] >- $("#didyoumean").load("/cgi-bin/koha/svc/suggestion?render=stub&q=[% querystring |uri %]", >+ $('#didyoumean').load('/cgi-bin/koha/svc/suggestion?render=stub&q=[% querystring | uri %]', > function() { > $(".searchsuggestion").parent().parent().css({ > "border-color": "#F4ECBE", >@@ -343,7 +344,10 @@ $(document).ready(function(){ > }); > [% END %] > >-}); >+[% IF ( CoceProviders ) %] >+KOHA.coce.getURL('[% CoceHost %]', '[% CoceProviders %]'); >+[% END %] >+ > > //]]> > </script> >@@ -724,6 +728,9 @@ $(document).ready(function(){ > [% END %] > > [% IF ( GoogleJackets ) %][% IF ( SEARCH_RESULT.normalized_isbn ) %]<span style="block" title="[% SEARCH_RESULT.biblionumber |url %]" class="[% SEARCH_RESULT.normalized_isbn %]" id="gbs-thumbnail[% loop.count %]"></span>[% ELSE %]<span class="no-image">No cover image available</span>[% END %][% END %] >+ >+[% IF ( CoceProviders ) %][% IF ( SEARCH_RESULT.normalized_isbn ) %]<span style="block" title="[% SEARCH_RESULT.biblionumber |url %]" class="[% SEARCH_RESULT.normalized_isbn %]" id="coce-thumbnail[% loop.count %]"></span>[% ELSE %]<span class="no-image">No cover image available</span>[% END %][% END %] >+ > [% IF OpenLibraryCovers %][% IF SEARCH_RESULT.normalized_isbn %]<span style="block" title="[% SEARCH_RESULT.biblionumber %]" class="[% SEARCH_RESULT.normalized_isbn %]" id="openlibrary-thumbnail[% loop.count %]"></span>[% ELSE %]<span class="no-image">No cover image available</span>[% END %][% END %] > </a> > [% IF ( BakerTaylorEnabled ) %][% IF ( SEARCH_RESULT.normalized_isbn ) %]<a href="https://[% BakerTaylorBookstoreURL |html %][% SEARCH_RESULT.normalized_isbn %]"><img alt="See Baker & Taylor" src="[% BakerTaylorImageURL |html %][% SEARCH_RESULT.normalized_isbn %]" /></a>[% ELSE %]<span class="no-image">No cover image available</span>[% END %][% END %] >-- >1.7.2.5 >
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 9580
:
15203
|
16778
|
21162
|
24071
|
24145
|
32794
|
32795
|
32801
|
32808
|
32809
|
32857
|
32891
|
32929
|
32942
|
32944
|
33201
|
34678
|
34679
|
37409
|
37410