Bugzilla – Attachment 107658 Details for
Bug 26037
openlibrary.org is hit on every Koha requests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26037: openlibrary.org is hit on every Koha requests
Bug-26037-openlibraryorg-is-hit-on-every-Koha-requ.patch (text/plain), 7.21 KB, created by
Lucas Gass (lukeg)
on 2020-07-31 22:08:07 UTC
(
hide
)
Description:
Bug 26037: openlibrary.org is hit on every Koha requests
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2020-07-31 22:08:07 UTC
Size:
7.21 KB
patch
obsolete
>From 72ed04c4608dd032835a1e9afa42eeebadd77500 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Mon, 27 Jul 2020 12:26:41 +0000 >Subject: [PATCH] Bug 26037: openlibrary.org is hit on every Koha requests > >This patch moves the inclusion of Open Library JavaScript from >opac-bottom.inc to the three templates where it might be used. > >In addition, the Open Library JS has been modified to check for the >existence of the relevant markup on the page before executing a query. > >Unrelated: The Open Library label is now hidden when the status returned >is "Not found." Previously this information was displayed. > >To test, apply the patch and enable the OpenLibrarySearch system >preference. > > - Perform a search in the OPAC which will return results from Open > Library. Some ISBNs: 0140423826, 0395082552, 0679436405. > - On the search result page there should be an Open Library "Read > now" button for each result that can be opened for reading in Open > Library. > - Add these titles to a list and view the list. > - The "Read now" button should appear on the list page. > - View the details for one of these titles. > - The "Read now" button should appear on the page below the holdings. > - Watch the browser's developer tools on these and other pages in the > OPAC. There should be no errors in the console and no 404 errors in > the network tab. > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >--- > .../bootstrap/en/includes/opac-bottom.inc | 14 ++++-------- > .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 3 +++ > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 7 +++++- > .../opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 4 ++++ > koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js | 25 ++++++++++++---------- > 5 files changed, 31 insertions(+), 22 deletions(-) > >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 d4d8b23bb0..d9bc539446 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >@@ -176,6 +176,10 @@ $.widget.bridge('uitooltip', $.ui.tooltip); > var MSG_OVERDRIVE_DOWNLOAD_AS = _( "Download as: " ); > var MSG_OVERDRIVE_CANNOT_CHECKOUT = _("Item cannot be checked out. There are no available formats"); > [% END %] >+ [% IF OpenLibraryCovers || OpenLibrarySearch %] >+ var NO_OL_JACKET = _("No cover image available"); >+ var OL_PREVIEW = _("Preview"); >+ [% END %] > [% IF ( OPACAmazonCoverImages || SyndeticsCoverImages ) %] > $(window).load(function() { > verify_images(); >@@ -231,16 +235,6 @@ $.widget.bridge('uitooltip', $.ui.tooltip); > </script> > [% END %] > >-[% IF OpenLibraryCovers || OpenLibrarySearch %] >- [% Asset.js("js/openlibrary.js") | $raw %] >- <script> >- //<![CDATA[ >- var NO_OL_JACKET = _("No cover image available"); >- var OL_PREVIEW = _("Preview"); >- //]]> >- </script> >-[% END %] >- > [% IF OPACLocalCoverImages %] > [% Asset.js("js/localcovers.js") | $raw %] > <script> >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 9e89dea893..cc32512efd 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -1384,6 +1384,9 @@ > [% Asset.js("js/verovio.js") | $raw %] > [% END %] > [% Asset.js("lib/emoji-picker/js/emoji-picker-all.min.js") | $raw %] >+[% IF OpenLibraryCovers || OpenLibrarySearch %] >+ [% Asset.js("js/openlibrary.js") | $raw %] >+[% END %] > <script> > window.emojiPicker = new EmojiPicker({ > emojiable_selector: '[data-emojiable=true]', >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 3fd522cf62..e199aa77bf 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -619,7 +619,12 @@ > [% Asset.js("js/authtoresults.js") | $raw %] > [% Asset.js("lib/hc-sticky.js") | $raw %] > [% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %] >-[% END %]<script> >+[% END %] >+[% IF OpenLibraryCovers || OpenLibrarySearch %] >+ [% Asset.js("js/openlibrary.js") | $raw %] >+[% END %] >+ >+<script> > [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'RequestOnOpac' ) == 1 ) %] > function holdMultiple() { > var checkedBiblioNums = ""; // Separated by "/" >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >index ab9f776cb3..46cbf0fedb 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >@@ -496,6 +496,7 @@ > > [% INCLUDE 'title-actions-menu.inc' items=itemsloo %] > >+ [% INCLUDE "openlibrary-readapi.inc" bib = itemsloo %] > <!-- COinS / Openurl --> > <span class="Z3988" title="[% itemsloo.coins | html %]"></span> > </td> >@@ -762,6 +763,9 @@ > [% BLOCK jsinclude %] > [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %] > [% Asset.js("lib/hc-sticky.js") | $raw %] >+[% IF OpenLibraryCovers || OpenLibrarySearch %] >+ [% Asset.js("js/openlibrary.js") | $raw %] >+[% END %] > <script> > var MSG_REMOVE_FROM_LIST = _("Are you sure you want to remove these items from the list?"); > var MSG_REMOVE_ONE_FROM_LIST = _("Are you sure you want to remove this item from the list?"); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js b/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js >index c33778de3c..afd6e4c77a 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js >@@ -112,6 +112,8 @@ var ol_readapi_automator = > // 'constants' > var readapi_bibids = ['isbn', 'lccn', 'oclc', 'olid', 'iaid', 'bibkeys']; > var magic_classname = 'ol_readapi_book'; >+var ol_readapi_books = $("." + magic_classname ); >+var result; > > // added to book divs to correlate with API results > var magic_bookid = 'ol_bookid'; >@@ -171,9 +173,8 @@ function make_read_button(bookdata) { > function default_decorate_el_fn(el, bookdata) { > // Note that 'bookdata' may be undefined, if the Read API call > // didn't return results for this book >- if (!bookdata) { >- decoration = 'Not found'; >- } else { >+ var decoration; >+ if (bookdata) { > decoration = make_read_button(bookdata); > } > if (decoration) { >@@ -216,15 +217,17 @@ function do_query(q, decorate_el_fn) { > }); > } > >-// Do stuff >-var q = create_query(); >-do_query(q); >+if( ol_readapi_books.length > 0 ){ >+ // Do stuff >+ var q = create_query(); >+ do_query(q); > >-result = { >- do_query: do_query, >- create_query: create_query, >- make_read_button: make_read_button >-}; >+ result = { >+ do_query: do_query, >+ create_query: create_query, >+ make_read_button: make_read_button >+ }; >+} > > return result; > })(); // close anonymous scope >-- >2.11.0
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 26037
:
107429
|
107658
|
107842