[VUFIND-318] Add more configurable settings to Book Previews Created: 02/Sep/10  Updated: 10/Oct/12  Resolved: 16/May/12

Status: Resolved
Project: VuFind®
Components: Record, Search
Affects versions: 1.1
Fix versions: 1.4

Type: Improvement Priority: Minor
Reporter: Eoghan Ó Carragáin Assignee: Demian Katz
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original estimate: Not Specified
Environment: All

Attachments: File IndexOf.patch     File config previews 16-05-12.patch     Text File config-previews 09-05-12.patch     Text File config-previews 15-05-12.patch     Text File config-previews 29-03-12.patch     Text File config-previews 30-03-12.patch    

 Description   
Some additional configurable options include:
- Allow libraries in the United States to include the "pdus" (public domain united states) rights code for the Hathi Trust. It is currently limited to "world" and "pd"
- Allow configuration of Limited View only or Full View only or Both for Open Library and Google Book Search

These things are easy to do in the JS functions, but the difficulty is in passing the options specified in config.ini into scripts.js. Some suggestions from Demian:
1.) Modify the UInterface class and layout.tpl to make some additional global Javascript assignments (maybe even a JS "configArray" variable containing a handful of relevant settings). Main disadvantage: overhead on every single page for something used in only a few places.

2.) Create an .htaccess file that allows PHP processing of .js files, and inject the settings directly into scripts.js. Main disadvantage: more PHP processing.

3.) Add new parameters to the relevant functions; pass in the relevant values. Main disadvantage: more complicated function calls in the templates.

4.) Add some kind of AJAX handler to obtain the settings. Main disadvantage: extra AJAX calls - this is really overkill.

 Comments   
Comment by Ronan McHugh [ 29/Mar/12 ]
Uploaded patch config-previews 29-03-12.

Summary:

This patch modifies the various preview functions to enable an administrator to modify the preview parameters without altering the code. The reason for this is that different institutions may have different access rights to documents in Hathi Trust (for geographic or other reasons) or simply have different requirements in terms of what type of previews ought to be displayed. In both cases, the relevant settings are altered in config.ini. If no settings are found, the scripts will default to their current behaviour.

Hathi Trust:

Hathi Trust provide a large number of details about access rights for books. At present, the preview function is hard-coded to only accept books which are in the public domain (pd) or available to the whole world (world). American institutions may have the right to access books which are classified as umall. In addition, all libraries should have the right to access books which are classified as creative commons (several variants of cc). This fix allows the user to set the rights codes that will be accepted/rejected before displaying previews.

The permissible rights codes are set in config.ini. These are accessed in results.php and passed to list.tpl. list.tpl calls a js function which sets the value of the HathiRights codes accepted. These are then called in the Hathi trust callback function which checks results against them before displaying.

Google Books / Open Library:

Google Books and Open Library offer three types of "previews". These are full, partial and noview, where noview represents an index page with some additional content, including reviews and ratings. At present, the JS code is hardcoded to only accept full or partial previews. Some institutions may prefer to accept all three types, only full previews etc. This fix enables the administrator to specify which types of previews will be displayed.

The permissible rights codes are set in config.ini. These are accessed in results.php and passed to list.tpl. list.tpl calls a js function which sets the value of the view types accepted. These are then called in the GoogleBooks / OLcallback function which checks results against them before displaying.
Comment by Ronan McHugh [ 29/Mar/12 ]
Note that this patch caused an error in displaying previews on individual record pages. A fix for this has been made and will be uploaded once tested.
Comment by Ronan McHugh [ 30/Mar/12 ]
New patch uploaded which fixes bug in previous patch - previews now show correctly on individual record pages.
Comment by Ronan McHugh [ 09/May/12 ]
New patch uploaded. This allows users to set different settings for Google and Open Library and corrects some errors from the previous patch.
Comment by Ronan McHugh [ 15/May/12 ]
One more time with feeling: some refactoring and improvements.

1) redundant variables removed.
2) If / else statements replaced with ternary operator (*shudder*)
3) Blueprint tpls and js methods updated to make them more jqeryish
4) Config settings checked for whitespace before passing to functions.
5) Duplicate code replaced with single method in Interface.php.
Comment by Demian Katz [ 16/May/12 ]
Committed as r5641 with some minor adjustments (style fixes, reduced duplicate "<script>...</script>" tags, fixed incorrectly-named HathiTrust parameter in config.ini, finished incomplete mobile implementation). I've uploaded an updated patch reflecting the committed version of the code.
Comment by Ronan McHugh [ 10/Oct/12 ]
I introduced an error in this code - Internet Explorer doesn't support Array.indexOf() meaning that previews break in IE for blueprint. I have attached a patch which defines the function for non-compatible browsers which should fix this. Apologies for the error.

See: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf for more details.
Comment by Demian Katz [ 10/Oct/12 ]
Fix committed as r5970 -- thanks!
Generated at Thu Mar 28 23:29:46 UTC 2024 using Jira 1001.0.0-SNAPSHOT#100248-rev:6a03a54452e975225e04dfda06fdac6fd9e95b00.