Bugzilla – Attachment 14345 Details for
Bug 8733
Adding critic reviews to book pages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8733: Add IDreamBooks.com enhanced content
Bug-8733-Add-IDreamBookscom-enhanced-content.patch (text/plain), 17.07 KB, created by
Jared Camins-Esakov
on 2013-01-01 00:35:11 UTC
(
hide
)
Description:
Bug 8733: Add IDreamBooks.com enhanced content
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2013-01-01 00:35:11 UTC
Size:
17.07 KB
patch
obsolete
>From 779a32ebce8ab315fd1c05fba26041fad7ea6751 Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Mon, 24 Sep 2012 07:47:11 -0400 >Subject: [PATCH] Bug 8733: Add IDreamBooks.com enhanced content > >Adds the following enhanced content to the OPAC, all controlled by >separate sysprefs: >1) A "Readometer" which summarizes reviews on the OPAC detail page >2) A tab with snippets of critical reviews on the OPAC detail page >3) A computed rating on the results page > >To test: >Find a book that is listed on IDreamBooks.com (you may have to make >sure that you have the first edition), and one that is not. Try >each of IDreamBooksReadometer, IDreamBooksReviews, and >IDreamBooksResults sysprefs, taking note of the content appearing (or >not) as appropriate. > >Updated to add missing CSS to new theme. > >Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com> >all tests pass. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >Rebased to latest master 2012-12-31 >--- > installer/data/mysql/sysprefs.sql | 3 + > installer/data/mysql/updatedatabase.pl | 10 +++ > .../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, 245 insertions(+) > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index d5d15d7..a4c291e 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -406,3 +406,6 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('NotesBlacklist','','List of notes fields that should not appear in the title notes/description separator of details',NULL,'free'); > INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('SCOUserCSS', '', NULL, 'Add CSS to be included in the SCO module in an embedded <style> tag.', 'free'); > INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('SCOUserJS', '', NULL, 'Define custom javascript for inclusion in the SCO module', 'free'); >+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'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 77265f4..9ec594f 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -6339,6 +6339,16 @@ if ( CheckVersion($DBversion) ) { > SetVersion ($DBversion); > } > >+$DBversion ="3.11.00.XXX"; >+if ( CheckVersion($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); >+} >+ >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >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 655ae34..74e6553 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 >@@ -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 <a href='http://idreambooks.com/'>IDreamBooks.com</a>. >+ - >+ - pref: IDreamBooksReadometer >+ choices: >+ yes: Add >+ no: "Don't add" >+ - a "Readometer" that summarizes the reviews gathered by <a href='http://idreambooks.com/'>IDreamBooks.com</a> to the OPAC details page. >+ - >+ - pref: IDreamBooksResults >+ choices: >+ yes: Add >+ no: "Don't add" >+ - the rating from <a href='http://idreambooks.com/'>IDreamBooks.com</a> to OPAC search results. > OCLC: > - > - pref: XISBN >diff --git a/koha-tmpl/opac-tmpl/ccsr/en/css/opac.css b/koha-tmpl/opac-tmpl/ccsr/en/css/opac.css >index e939a1b..d212137 100644 >--- a/koha-tmpl/opac-tmpl/ccsr/en/css/opac.css >+++ b/koha-tmpl/opac-tmpl/ccsr/en/css/opac.css >@@ -2698,3 +2698,53 @@ body#opac-main #opacmainuserblockmobile { > .tagweight9 { > font-size: 30px; > } >+ >+.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; >+} >diff --git a/koha-tmpl/opac-tmpl/prog/en/css/opac.css b/koha-tmpl/opac-tmpl/prog/en/css/opac.css >index 3149784..a8fad2d 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css >+++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css >@@ -2850,3 +2850,53 @@ body#opac-main #opacmainuserblockmobile { > video { > width: 480px; > } >+ >+.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; >+} >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 fa5ec3d..9ea4ea0 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >@@ -181,7 +181,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('<a href="'+json.book.detail_link+'" id="idreambooksreadometer"><img src="http://idreambooks.com/remotereadometer/'+isbn+'.jpg" alt="'+json.book.title+' by '+json.book.author+'" title="Rating based on reviews of '+json.book.title+'"></a>'); >+[% 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("<span class='idreambookssummary results_summary'><a href='"+json.book.detail_link+"'><img src='"+json.book.to_read_or_not_small+"' alt='"+json.book.title+" by "+json.book.author+"' title='Rating based on reviews of "+json.book.title+"'>"+json.book.rating+"%</a> <a href='http://www.idreambooks.com/'>rating based on reviews at iDreamBooks.com</a></span>"); >+ >+ //insert data into Book reviews tab >+ $.each(json.book.critic_reviews, function(){ >+ $("#idb_review_snippets").append("<div class='review'><div><a href='"+this.review_link+"'>"+this.source+"</a></div><div>\"..."+this.snippet+"...\"</div><div>Review date: "+this.review_date+"</div><div><a class='reviewlink' href='"+json.book.detail_link+"'>Review result: "+this.pos_or_neg+" <img src='"+this.smiley_or_sad_small+"' alt='iDreamBooks.com rating' title='"+this.pos_or_neg+"' /></a></div></div>"); >+ }); >+ $("#seemoreidb").attr('href', json.book.detail_link); >+ $("#tab_idb_critic_reviews").show(); >+[% END %] >+ >+ } >+ >+} >+[% END %] > > [% IF ( OpacBrowseResults && busc ) %] > var timeoutRFW; >@@ -724,6 +777,9 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > <li id="tab_html5media"><a href="#html5media">Play media</a></li> > [% END %][% END %] > >+[% IF ( IDreamBooksReviews ) %] >+ <li id='tab_idb_critic_reviews' style="display:none;"><a href='#idb_critic_reviews'>Book reviews by critics ( XXX )</a></li> >+[% END %] > </ul> > > [% IF ( serialcollection ) %] >@@ -1083,6 +1139,14 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > </div> > [% END %] > >+[% IF ( IDreamBooksReviews ) %] >+ <div id="idb_critic_reviews"> >+ <div id="idb_review_snippets"> >+ </div> >+ <span><a id="seemoreidb">More book reviews at iDreamBooks.com</a></span> >+ </div> >+[% END %] >+ > > </div> > [% IF ( NovelistSelectProfile ) %][% IF ( NovelistSelectView == 'below' ) %] >@@ -1102,6 +1166,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > <div id="BW_videos"></div> > [% END %] > >+ > </div> > > >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 2e3ad22..fe96259 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >@@ -109,6 +109,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("<img src='"+json.book.to_read_or_not_small+"' alt='"+json.book.title+" by "+json.book.author+"' title='Rating based on reviews of "+json.book.title+"'>"+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("<img src='"+json.book.to_read_or_not_small+"' alt='"+json.book.title+" by "+json.book.author+"' title='Rating based on reviews of "+json.book.title+"'>"+json.book.rating+"%"); >+ $(element).show(); >+ } else { >+ $(element).remove(); >+ } >+ }); >+ } >+ }); >+ [% END %] >+ > [% IF ( opacbookbag ) %]$(".addtocart").show();[% END %] > > [% IF ( opacbookbag ) %] >@@ -648,6 +681,14 @@ $(document).ready(function(){ > [% 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 %] >+ [% IF ( IDreamBooksResults ) %][% IF ( SEARCH_RESULT.normalized_isbn ) %]<div class="idbresult" style="display: none;"> >+ [% IF ( IDreamBooksReviews ) %] >+ <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]#idb_critic_reviews"> >+ [% ELSE %] >+ <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]"> >+ [% END %] >+ [% SEARCH_RESULT.normalized_isbn %]</a></div> >+ [% END %][% END %] > </td> > </tr> > [% END %] >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 22c922b..cb88010 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -1003,6 +1003,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'); > } >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 9708176..97a7bc4 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -833,6 +833,9 @@ if (C4::Context->preference('GoogleIndicTransliteration')) { > } > > $template->{VARS}->{DidYouMean} = C4::Context->preference('OPACdidyoumean') =~ m/enable/; >+$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; >-- >1.7.9.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 8733
:
11996
|
12015
|
12016
|
12017
|
12018
|
12493
|
12501
|
12583
|
12587
|
12588
|
14345
|
14980
|
15001
|
15012
|
15013
|
15024
|
15025
|
15026