@@ -, +, @@ --- installer/data/mysql/sysprefs.sql | 3 + installer/data/mysql/updatedatabase.pl | 8 +++ .../admin/preferences/enhanced_content.pref | 19 ++++++ koha-tmpl/opac-tmpl/ccsr/en/css/opac.css | 50 +++++++++++++++ koha-tmpl/opac-tmpl/prog/en/css/opac.css | 50 +++++++++++++++ koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 65 ++++++++++++++++++++ .../opac-tmpl/prog/en/modules/opac-results.tt | 41 ++++++++++++ opac/opac-detail.pl | 4 + opac/opac-search.pl | 3 + 9 files changed, 243 insertions(+), 0 deletions(-) --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -383,3 +383,6 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowLibrariesPulldownMobile','1','Show the libraries pulldown on the mobile version of the OPAC.',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowFiltersPulldownMobile','1','Show the search filters pulldown on the mobile version of the OPAC.',NULL,'YesNo'); INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('AuthDisplayHierarchy','0','Display authority hierarchies','','YesNo'); +INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReviews','0','Display book review snippets from IDreamBooks.com','','YesNo'); +INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReadometer','0','Display Readometer from IDreamBooks.com','','YesNo'); +INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksResults','0','Display IDreamBooks.com rating in search results','','YesNo'); --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -5973,6 +5973,14 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion ="3.09.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReviews','0','Display book review snippets from IDreamBooks.com','','YesNo');"); + $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReadometer','0','Display Readometer from IDreamBooks.com','','YesNo');"); + $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksResults','0','Display IDreamBooks.com rating in search results','','YesNo');"); + print "Upgrade to $DBversion done (Add IDreamBooks enhanced content)\n"; + SetVersion($DBversion); +} $DBversion = "3.09.00.057"; if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref @@ -141,6 +141,25 @@ Enhanced Content: choices: yes: in tabs. no: in line with the bibliographic information. + IDreamLibraries: + - + - pref: IDreamBooksReviews + choices: + yes: Add + no: "Don't add" + - a tab on the OPAC details with book reviews from critics aggregated by IDreamBooks.com. + - + - pref: IDreamBooksReadometer + choices: + yes: Add + no: "Don't add" + - a "Readometer" that summarizes the reviews gathered by IDreamBooks.com to the OPAC details page. + - + - pref: IDreamBooksResults + choices: + yes: Add + no: "Don't add" + - the rating from IDreamBooks.com to OPAC search results. OCLC: - - pref: XISBN --- a/koha-tmpl/opac-tmpl/ccsr/en/css/opac.css +++ a/koha-tmpl/opac-tmpl/ccsr/en/css/opac.css @@ -2637,3 +2637,53 @@ body#opac-main #opacmainuserblockmobile { .mobile_only { display : none; } + +.review { + margin-bottom: 20px; +} + +#idreambooksreadometer { + float: right; +} +a.idreambooksrating { + font-size: 30px; + color: #29ADE4; + padding-left: 85px; + line-height: 30px; + text-decoration: none; +} + +.idreambookslegend { + font-size: small; +} + +a.reviewlink,a.reviewlink:visited { + text-decoration: none; + color: black; + font-weight: normal; +} + +.idreambookssummary a { + color: #707070; + text-decoration: none; +} + +.idreambookssummary img, .idbresult img { + vertical-align: middle; +} + +.idbresult { + color: #29ADE4; + text-align: center; + margin: 0.5em; + padding: 0.5em; +} + +.idbresult a, .idbresult a:visited { + text-decoration: none; + color: #29ADE4; +} + +.idbresult img { + padding-right: 6px; +} --- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css +++ a/koha-tmpl/opac-tmpl/prog/en/css/opac.css @@ -2767,3 +2767,53 @@ body#opac-main #opacmainuserblockmobile { .mobile_only { display : none; } + +.review { + margin-bottom: 20px; +} + +#idreambooksreadometer { + float: right; +} +a.idreambooksrating { + font-size: 30px; + color: #29ADE4; + padding-left: 85px; + line-height: 30px; + text-decoration: none; +} + +.idreambookslegend { + font-size: small; +} + +a.reviewlink,a.reviewlink:visited { + text-decoration: none; + color: black; + font-weight: normal; +} + +.idreambookssummary a { + color: #707070; + text-decoration: none; +} + +.idreambookssummary img, .idbresult img { + vertical-align: middle; +} + +.idbresult { + color: #29ADE4; + text-align: center; + margin: 0.5em; + padding: 0.5em; +} + +.idbresult a, .idbresult a:visited { + text-decoration: none; + color: #29ADE4; +} + +.idbresult img { + padding-right: 6px; +} --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt @@ -160,7 +160,60 @@ $(function () { }); // ----------------------------------------------------- [% END %] +[% IF ( IDreamBooksReviews || IDreamBooksReadometer ) %] + var isbn = $(".isbn:last").text().split(" ")[1]; + if (isbn) { + isbn = isbn.replace(/\W*$/, ''); + + if ($.browser.msie && parseInt($.browser.version, 10) >= 8 && window.XDomainRequest) { + // Use Microsoft XDR for IE version 8 or above + var xdr = new XDomainRequest(); + xdr.open("get", "http://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e"); + xdr.onload = function() { + json = 'json = '+xdr.responseText; // the string now looks like.. json = { ... }; + eval(json); // json is now a regular JSON object + parseIDBJSON(json); // parse using same function as for jQuery's success event + } + xdr.send(); + } else { + $.getJSON("http://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e", function(json){ + parseIDBJSON(json); + }); + } + } + +[% END %] }); +[% IF ( IDreamBooksReviews || IDreamBooksReadometer ) %] +function parseIDBJSON( json ) { + if(json.total_results > 0 && json.book.rating > 0){ + var isbn = $(".isbn:last").text().split(" ")[1]; + +[% IF ( IDreamBooksReadometer ) %] + $(".title").append(''+json.book.title+' by '+json.book.author+''); +[% END %] + + +[% IF ( IDreamBooksReviews ) %] + //build new tab for critic reviews + $("#tab_idb_critic_reviews a").text($("#tab_idb_critic_reviews a").text().replace('XXX', json.book.review_count)); + + //append happy-sad cloud review + + $("#catalogue_detail_biblio").append(""+json.book.title+" by "+json.book.author+""+json.book.rating+"% rating based on reviews at iDreamBooks.com"); + + //insert data into Book reviews tab + $.each(json.book.critic_reviews, function(){ + $("#idb_review_snippets").append("
"+this.source+"
\"..."+this.snippet+"...\"
Review date: "+this.review_date+"
Review result: "+this.pos_or_neg+" iDreamBooks.com rating
"); + }); + $("#seemoreidb").attr('href', json.book.detail_link); + $("#tab_idb_critic_reviews").show(); +[% END %] + + } + +} +[% END %] [% IF ( OpacBrowseResults && busc ) %] var timeoutRFW; @@ -708,6 +761,9 @@ YAHOO.util.Event.onContentReady("furtherm", function () { [% IF ( OPACLocalCoverImages ) %][% IF ( localimages ) %]
  • Images
  • [% END %][% END %] +[% IF ( IDreamBooksReviews ) %] + +[% END %] [% IF ( serialcollection ) %] @@ -1153,6 +1209,14 @@ YAHOO.util.Event.onContentReady("furtherm", function () { [% END %] +[% IF ( IDreamBooksReviews ) %] +
    +
    +
    + More book reviews at iDreamBooks.com +
    +[% END %] + [% IF ( NovelistSelectProfile ) %][% IF ( NovelistSelectView == 'below' ) %] @@ -1172,6 +1236,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
    [% END %] + --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt +++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt @@ -103,6 +103,39 @@ $(document).ready(function(){ }); [% END %] + [% IF ( IDreamBooksResults ) %] + $('.idbresult').each(function() { + var isbn = $(this).children('a').text().replace(/\s*/,''); + var element = this; + + if ($.browser.msie && parseInt($.browser.version, 10) >= 8 && window.XDomainRequest) { + // Use Microsoft XDR for IE version 8 or above + var xdr = new XDomainRequest(); + xdr.open("get", "http://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e"); + xdr.onload = function() { + json = 'json = '+xdr.responseText; // the string now looks like.. json = { ... }; + eval(json); // json is now a regular JSON object + if(json.total_results > 0 && json.book.rating > 0){ + $(element).children('a').html(""+json.book.title+" by "+json.book.author+""+json.book.rating+"%"); + $(element).show(); + } else { + $(element).remove(); + } + } + xdr.send(); + } else { + $.getJSON("http://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e", function(json){ + if(json.total_results > 0 && json.book.rating > 0){ + $(element).children('a').html(""+json.book.title+" by "+json.book.author+""+json.book.rating+"%"); + $(element).show(); + } else { + $(element).remove(); + } + }); + } + }); + [% END %] + [% IF ( opacbookbag ) %]$(".addtocart").show();[% END %] [% IF ( opacbookbag ) %] @@ -643,6 +676,14 @@ $(document).ready(function(){ [% IF OpenLibraryCovers %][% IF SEARCH_RESULT.normalized_isbn %][% ELSE %]No cover image available[% END %][% END %] [% IF ( BakerTaylorEnabled ) %][% IF ( SEARCH_RESULT.normalized_isbn ) %]See Baker & Taylor[% ELSE %]No cover image available[% END %][% END %] + [% IF ( IDreamBooksResults ) %][% IF ( SEARCH_RESULT.normalized_isbn ) %] + [% END %][% END %] [% END %] --- a/opac/opac-detail.pl +++ a/opac/opac-detail.pl @@ -970,6 +970,10 @@ if (C4::Context->preference('OPACLocalCoverImages') == 1) { $template->{VARS}->{localimages} = \@images; } +$template->{VARS}->{IDreamBooksReviews} = C4::Context->preference('IDreamBooksReviews'); +$template->{VARS}->{IDreamBooksReadometer} = C4::Context->preference('IDreamBooksReadometer'); +$template->{VARS}->{IDreamBooksResults} = C4::Context->preference('IDreamBooksResults'); + if (C4::Context->preference('OpacHighlightedWords')) { $template->{VARS}->{query_desc} = $query->param('query_desc'); } --- a/opac/opac-search.pl +++ a/opac/opac-search.pl @@ -824,6 +824,9 @@ if (C4::Context->preference('GoogleIndicTransliteration')) { } $template->{VARS}->{DidYouMeanFromAuthorities} = C4::Context->preference('DidYouMeanFromAuthorities'); +$template->{VARS}->{IDreamBooksReviews} = C4::Context->preference('IDreamBooksReviews'); +$template->{VARS}->{IDreamBooksReadometer} = C4::Context->preference('IDreamBooksReadometer'); +$template->{VARS}->{IDreamBooksResults} = C4::Context->preference('IDreamBooksResults'); $template->param( borrowernumber => $borrowernumber); output_with_http_headers $cgi, $cookie, $template->output, $content_type; --