From addf3ab0c80685394c3d9f476c8af25a26c51a0e Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Tue, 7 Feb 2017 15:29:39 -0800 Subject: [PATCH] LP#1541559: ebook API integration for TPAC When this feature is enabled, Evergreen will use the open-ils.ebook_api service to look up title and patron information from specified vendor APIs and display that information in the TPAC. (The service should be configured using org settings before being enabled in config.tt2.) This frontend is essentially a JS layer over top of the OPAC, with some light use of Dojo since we're already using it, plus a few additions to TT2 templates. The JS layer uses OpenSRF JS bindings to talk to the backend service, which in turn makes the appropriate calls to the third-party API. Session IDs and (if logged in) patron information are stored in cookies, which are cleared when the patron logs out. The user will see the following changes: - On search results and record summary, for any records from a known e-book vendor, Evergreen will automatically look up holdings info from the vendor API. If detailed information on formats and available "copies" is provided by the API (e.g. for OverDrive), that information is displayed in a table within the record; if only basic availability info is available (e.g. for OneClickdigital), a line is added to each record indicating whether the title is available. (Eventually, "Place Hold" or "Check Out" links will be added to allow patrons to checkout/hold titles without leaving the TPAC.) - When the user is logged in, the dashboard will show a count of e-book checkouts and holds for all enabled e-book vendors, as will the account summary. This is separate from the "main" checkouts/holds display, since checkouts/holds on titles from third-party vendors are unrelated to checkouts/holds in Evergreen. - When the user is logged in, additional tabs will be available in My Account for displaying detailed information on the patron's ebook checkouts and holds. (Eventually, functionality will be added to My Account allowing the user to download or renew titles, suspend or cancel holds, etc.) Signed-off-by: Jeff Davis Signed-off-by: Kathy Lussier --- Open-ILS/src/templates/opac/css/style.css.tt2 | 10 +- .../templates/opac/myopac/circ_history.tt2 | 5 + Open-ILS/src/templates/opac/myopac/circs.tt2 | 5 + .../src/templates/opac/myopac/ebook_circs.tt2 | 42 ++++ .../src/templates/opac/myopac/ebook_holds.tt2 | 51 ++++ .../opac/myopac/ebook_holds_ready.tt2 | 50 ++++ .../templates/opac/myopac/hold_history.tt2 | 8 + Open-ILS/src/templates/opac/myopac/holds.tt2 | 8 + Open-ILS/src/templates/opac/parts/config.tt2 | 11 + .../templates/opac/parts/ebook_api/avail.tt2 | 49 ++++ .../opac/parts/ebook_api/avail_js.tt2 | 49 ++++ .../opac/parts/ebook_api/base_js.tt2 | 71 ++++++ .../opac/parts/ebook_api/login_js.tt2 | 41 ++++ Open-ILS/src/templates/opac/parts/header.tt2 | 4 + Open-ILS/src/templates/opac/parts/js.tt2 | 6 + .../src/templates/opac/parts/misc_util.tt2 | 50 ++++ .../templates/opac/parts/myopac/main_base.tt2 | 24 +- .../templates/opac/parts/record/summary.tt2 | 5 + .../src/templates/opac/parts/result/table.tt2 | 5 + Open-ILS/src/templates/opac/parts/topnav.tt2 | 16 ++ .../web/js/ui/default/opac/ebook_api/ebook.js | 48 ++++ .../js/ui/default/opac/ebook_api/loggedin.js | 221 ++++++++++++++++++ .../js/ui/default/opac/ebook_api/relation.js | 80 +++++++ .../js/ui/default/opac/ebook_api/session.js | 40 ++++ 24 files changed, 891 insertions(+), 8 deletions(-) create mode 100644 Open-ILS/src/templates/opac/myopac/ebook_circs.tt2 create mode 100644 Open-ILS/src/templates/opac/myopac/ebook_holds.tt2 create mode 100644 Open-ILS/src/templates/opac/myopac/ebook_holds_ready.tt2 create mode 100644 Open-ILS/src/templates/opac/parts/ebook_api/avail.tt2 create mode 100644 Open-ILS/src/templates/opac/parts/ebook_api/avail_js.tt2 create mode 100644 Open-ILS/src/templates/opac/parts/ebook_api/base_js.tt2 create mode 100644 Open-ILS/src/templates/opac/parts/ebook_api/login_js.tt2 create mode 100644 Open-ILS/web/js/ui/default/opac/ebook_api/ebook.js create mode 100644 Open-ILS/web/js/ui/default/opac/ebook_api/loggedin.js create mode 100644 Open-ILS/web/js/ui/default/opac/ebook_api/relation.js create mode 100644 Open-ILS/web/js/ui/default/opac/ebook_api/session.js diff --git a/Open-ILS/src/templates/opac/css/style.css.tt2 b/Open-ILS/src/templates/opac/css/style.css.tt2 index 864304bed7..98d8749888 100644 --- a/Open-ILS/src/templates/opac/css/style.css.tt2 +++ b/Open-ILS/src/templates/opac/css/style.css.tt2 @@ -114,12 +114,12 @@ div.select-box-wrapper { display:inline-block; } -#dashboard { +#dashboard, #dashboard_e { margin-top: 1em; height: 3em; } -#dashboard span.dash-align a { +#dashboard span.dash-align a, #dashboard_e span.dash-align a { font-weight: bold; text-decoration: none; } @@ -130,9 +130,9 @@ div.select-box-wrapper { #logout_link { left: 1px; } -#dash_checked { color: [% css_colors.text_attention %]; } -#dash_holds { color: [% css_colors.text_attention %]; } -#dash_pickup { color: [% css_colors.text_goodnews %]; } +#dash_checked, #dash_e_checked { color: [% css_colors.text_attention %]; } +#dash_holds, #dash_e_holds { color: [% css_colors.text_attention %]; } +#dash_pickup, #dash_e_pickup { color: [% css_colors.text_goodnews %]; } /* #dash_fines { color: [% css_colors.text_badnews %]; } diff --git a/Open-ILS/src/templates/opac/myopac/circ_history.tt2 b/Open-ILS/src/templates/opac/myopac/circ_history.tt2 index 7e6edc4f9d..8e989c4362 100644 --- a/Open-ILS/src/templates/opac/myopac/circ_history.tt2 +++ b/Open-ILS/src/templates/opac/myopac/circ_history.tt2 @@ -14,6 +14,11 @@ + [%- IF ebook_api.enabled %] + + [%- END %] diff --git a/Open-ILS/src/templates/opac/myopac/circs.tt2 b/Open-ILS/src/templates/opac/myopac/circs.tt2 index 4715925ed4..bd93d7bbcb 100644 --- a/Open-ILS/src/templates/opac/myopac/circs.tt2 +++ b/Open-ILS/src/templates/opac/myopac/circs.tt2 @@ -10,6 +10,11 @@ + [%- IF ebook_api.enabled %] + + [%- END %] diff --git a/Open-ILS/src/templates/opac/myopac/ebook_circs.tt2 b/Open-ILS/src/templates/opac/myopac/ebook_circs.tt2 new file mode 100644 index 0000000000..4a75f23102 --- /dev/null +++ b/Open-ILS/src/templates/opac/myopac/ebook_circs.tt2 @@ -0,0 +1,42 @@ +[% PROCESS "opac/parts/header.tt2"; + PROCESS "opac/parts/misc_util.tt2"; + PROCESS "opac/parts/myopac/column_sort_support.tt2"; + WRAPPER "opac/parts/myopac/base.tt2"; + myopac_page = "ebook_circs" %] +

[% l('E-Items Currently Checked Out') %]

+
+ + + +
+ [% l('E-Items Currently Checked Out') %] +
+
+ + +
+[% END %] diff --git a/Open-ILS/src/templates/opac/myopac/ebook_holds.tt2 b/Open-ILS/src/templates/opac/myopac/ebook_holds.tt2 new file mode 100644 index 0000000000..f578a9fb9d --- /dev/null +++ b/Open-ILS/src/templates/opac/myopac/ebook_holds.tt2 @@ -0,0 +1,51 @@ +[% PROCESS "opac/parts/header.tt2"; + PROCESS "opac/parts/misc_util.tt2"; + PROCESS "opac/parts/hold_status.tt2"; + PROCESS "opac/parts/myopac/column_sort_support.tt2"; + WRAPPER "opac/parts/myopac/base.tt2"; + myopac_page = "ebook_holds"; + limit = (ctx.holds_limit.defined) ? ctx.holds_limit : 0; + offset = (ctx.holds_offset.defined) ? ctx.holds_offset : 0; + count = (ctx.holds_ids.size.defined) ? ctx.holds_ids.size : 0; +%] +

[% l('My E-Item Holds') %]

+
+ + + +
+ [% l('E-Items on Hold') %] +
+
+ + +
+[% END %] diff --git a/Open-ILS/src/templates/opac/myopac/ebook_holds_ready.tt2 b/Open-ILS/src/templates/opac/myopac/ebook_holds_ready.tt2 new file mode 100644 index 0000000000..b93bc95363 --- /dev/null +++ b/Open-ILS/src/templates/opac/myopac/ebook_holds_ready.tt2 @@ -0,0 +1,50 @@ +[% PROCESS "opac/parts/header.tt2"; + PROCESS "opac/parts/misc_util.tt2"; + PROCESS "opac/parts/hold_status.tt2"; + PROCESS "opac/parts/myopac/column_sort_support.tt2"; + WRAPPER "opac/parts/myopac/base.tt2"; + myopac_page = "ebook_holds_ready"; + limit = (ctx.holds_limit.defined) ? ctx.holds_limit : 0; + offset = (ctx.holds_offset.defined) ? ctx.holds_offset : 0; + count = (ctx.holds_ids.size.defined) ? ctx.holds_ids.size : 0; +%] +

[% l('E-Items Ready for Checkout') %]

+
+ + + +
+ [% l('E-Items Ready for Checkout') %] +
+
+ + +
+[% END %] diff --git a/Open-ILS/src/templates/opac/myopac/hold_history.tt2 b/Open-ILS/src/templates/opac/myopac/hold_history.tt2 index 9905e6c60f..16b4c029b9 100644 --- a/Open-ILS/src/templates/opac/myopac/hold_history.tt2 +++ b/Open-ILS/src/templates/opac/myopac/hold_history.tt2 @@ -15,6 +15,14 @@ + [% IF ebook_api.enabled %] + + + [% END %] diff --git a/Open-ILS/src/templates/opac/myopac/holds.tt2 b/Open-ILS/src/templates/opac/myopac/holds.tt2 index 7fc808c8f3..1ba5c9ce1b 100644 --- a/Open-ILS/src/templates/opac/myopac/holds.tt2 +++ b/Open-ILS/src/templates/opac/myopac/holds.tt2 @@ -15,6 +15,14 @@ + [% IF ebook_api.enabled %] + + + [% END %] diff --git a/Open-ILS/src/templates/opac/parts/config.tt2 b/Open-ILS/src/templates/opac/parts/config.tt2 index 4e0e3b9fe9..3af7bb73ef 100644 --- a/Open-ILS/src/templates/opac/parts/config.tt2 +++ b/Open-ILS/src/templates/opac/parts/config.tt2 @@ -50,6 +50,17 @@ openurl.baseurl = 'http://sfx.example.com/instance'; google_analytics.enabled = 'false'; google_analytics.code = 'UA-9999999-99'; +############################################################################## +# Ebook API integration +############################################################################## +ebook_api.enabled = 'false'; +ebook_api.ebook_test.enabled = 'false'; +ebook_api.ebook_test.base_uris = [ 'http://example.com/ebookapi/t/' ]; +ebook_api.oneclickdigital.enabled = 'false'; +ebook_api.oneclickdigital.base_uris = [ 'http://example.oneclickdigital.com/Products/ProductDetail.aspx' ]; +ebook_api.overdrive.enabled = 'false'; +ebook_api.overdrive.base_uris = [ 'http://elm.lib.overdrive.com/' ]; + ############################################################################## # Enable "Forgot your password?" prompt at login ############################################################################## diff --git a/Open-ILS/src/templates/opac/parts/ebook_api/avail.tt2 b/Open-ILS/src/templates/opac/parts/ebook_api/avail.tt2 new file mode 100644 index 0000000000..f75a951459 --- /dev/null +++ b/Open-ILS/src/templates/opac/parts/ebook_api/avail.tt2 @@ -0,0 +1,49 @@ +[%- +# Display holdings/availability info from ebook API +# +# We require the following info: +# - rec_id: internal ID for this record (rec.id in search results, ctx.bre_id in record summary) +# - ebook_id: external ID for title (ISBN for OneClickdigital, unique identifier for OverDrive) +# - vendor (oneclickdigital, overdrive) + +IF args.ebook_test_id; + ebook.ebook_id = args.ebook_test_id; + ebook.vendor = 'ebook_test'; +ELSIF args.oneclickdigital_id; + ebook.ebook_id = args.oneclickdigital_id; + ebook.vendor = 'oneclickdigital'; +ELSIF args.overdrive_id; + ebook.ebook_id = args.overdrive_id; + ebook.vendor = 'overdrive'; +END; + +IF ebook.ebook_id; + + IF ctx.page == 'rresult'; + ebook.rec_id = rec.id; + ELSE; + ebook.rec_id = ctx.bre_id; + END; + +# This div is hidden by default. The JS layer will unhide it, use the ebook_id +# to retrieve holdings/availability info via the appropriate vendor API, and +# overwrite the div's contents with that information. +-%] + +[% END %] diff --git a/Open-ILS/src/templates/opac/parts/ebook_api/avail_js.tt2 b/Open-ILS/src/templates/opac/parts/ebook_api/avail_js.tt2 new file mode 100644 index 0000000000..f70f115163 --- /dev/null +++ b/Open-ILS/src/templates/opac/parts/ebook_api/avail_js.tt2 @@ -0,0 +1,49 @@ + diff --git a/Open-ILS/src/templates/opac/parts/ebook_api/base_js.tt2 b/Open-ILS/src/templates/opac/parts/ebook_api/base_js.tt2 new file mode 100644 index 0000000000..632e534aba --- /dev/null +++ b/Open-ILS/src/templates/opac/parts/ebook_api/base_js.tt2 @@ -0,0 +1,71 @@ +[% +# HTML display chunks +progress_icon = '' _ l(' +%] + + + + + +[%- IF ctx.user %] + + +[%- END %] + diff --git a/Open-ILS/src/templates/opac/parts/ebook_api/login_js.tt2 b/Open-ILS/src/templates/opac/parts/ebook_api/login_js.tt2 new file mode 100644 index 0000000000..23ed256086 --- /dev/null +++ b/Open-ILS/src/templates/opac/parts/ebook_api/login_js.tt2 @@ -0,0 +1,41 @@ + diff --git a/Open-ILS/src/templates/opac/parts/header.tt2 b/Open-ILS/src/templates/opac/parts/header.tt2 index 8b60ba9c7b..5b34c1672d 100644 --- a/Open-ILS/src/templates/opac/parts/header.tt2 +++ b/Open-ILS/src/templates/opac/parts/header.tt2 @@ -124,6 +124,10 @@ want_dojo = 1; END; + IF ebook_api.enabled == 'true'; + want_dojo = 1; + END; + # Especially useful for image 'alt' tags and link title tags, # where the content may need to be unique (making it longer) # but should not exceed 75 chars for ideal screen reader support. diff --git a/Open-ILS/src/templates/opac/parts/js.tt2 b/Open-ILS/src/templates/opac/parts/js.tt2 index 5cfdebeef5..245af4347a 100644 --- a/Open-ILS/src/templates/opac/parts/js.tt2 +++ b/Open-ILS/src/templates/opac/parts/js.tt2 @@ -107,6 +107,12 @@ src="[% ctx.media_prefix %]/js/ui/default/opac/copyloc.js"> [% END %] +[% IF ebook_api.enabled == 'true' %] + [% INCLUDE "opac/parts/ebook_api/base_js.tt2" %] + [% INCLUDE "opac/parts/ebook_api/avail_js.tt2" IF (ctx.page == 'rresult' OR ctx.page == 'record') %] + [% INCLUDE "opac/parts/ebook_api/login_js.tt2" IF (ctx.page == 'login') %] +[% END %] +