From 01a912aeb8278bef8ed626bb81bb87762d695cc7 Mon Sep 17 00:00:00 2001
From: phasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Wed, 23 Jun 2010 18:09:13 +0000
Subject: [PATCH] correct the logic for detecting whether ChiliFresh has been
 configured, and add similar support for Novelist

git-svn-id: svn://svn.open-ils.org/ILS/trunk@16791 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/examples/apache/eg_vhost.conf             |  4 +++
 Open-ILS/web/opac/locale/en-US/opac.dtd            |  1 +
 Open-ILS/web/opac/skin/default/js/rdetail.js       | 29 +++++++++++++++++++---
 Open-ILS/web/opac/skin/default/js/result_common.js |  6 ++---
 .../skin/default/xml/rdetail/rdetail_extras.xml    | 28 +++++++++++++++++++--
 .../opac/skin/default/xml/result/result_table.xml  |  3 ++-
 Open-ILS/web/opac/theme/default/css/colors.css     |  2 ++
 7 files changed, 64 insertions(+), 9 deletions(-)

diff --git a/Open-ILS/examples/apache/eg_vhost.conf b/Open-ILS/examples/apache/eg_vhost.conf
index b8b7bc1993..1f3c6b833d 100644
--- a/Open-ILS/examples/apache/eg_vhost.conf
+++ b/Open-ILS/examples/apache/eg_vhost.conf
@@ -102,6 +102,10 @@ RewriteRule - - [E=locale:%1] [L]
     #SetEnv OILS_CHILIFRESH_ACCOUNT
     #SetEnv OILS_CHILIFRESH_PROFILE
     #SetEnv OILS_CHILIFRESH_URL http://chilifresh.com/on-site/js/evergreen.js
+
+    # Specify the initial script URL for Novelist (containing account credentials, etc.)
+    #SetEnv OILS_NOVELIST_URL
+
 </LocationMatch>
 
 
diff --git a/Open-ILS/web/opac/locale/en-US/opac.dtd b/Open-ILS/web/opac/locale/en-US/opac.dtd
index 959c4b5b1e..5751373148 100644
--- a/Open-ILS/web/opac/locale/en-US/opac.dtd
+++ b/Open-ILS/web/opac/locale/en-US/opac.dtd
@@ -549,6 +549,7 @@ We recommend that you remove this title from any bookbags it may have been added
 <!ENTITY rdetail.extras.preview.fulltext "Full text">
 <!ENTITY rdetail.extras.preview.title "See the full text of this book.">
 <!ENTITY rdetail.extras.preview.badge "Show a preview of this book from Google Book Search">
+<!ENTITY rdetail.extras.novelist "Suggestions by Novelist">
 <!ENTITY rdetail.loading "Loading copy information...">
 <!ENTITY rdetail.noneAvailable " * There are no copies in this location">
 <!ENTITY rdetail.summary.online "Online Resources">
diff --git a/Open-ILS/web/opac/skin/default/js/rdetail.js b/Open-ILS/web/opac/skin/default/js/rdetail.js
index 7adfa0028f..8dee437fa1 100644
--- a/Open-ILS/web/opac/skin/default/js/rdetail.js
+++ b/Open-ILS/web/opac/skin/default/js/rdetail.js
@@ -469,16 +469,32 @@ function _rdetailDraw(r) {
 	resultDrawSeries();
 
 	// grab added content 
+
+    // Proxied through Evergreen AddedContent module
 	acCollectData(cleanISBN(record.isbn()), rdetailhandleAC);
 
-    // different type of added content
     var currentISBN = cleanISBN(record.isbn());
-    if (chilifresh && currentISBN) {
+
+    // Not proxied, cross-site javascript
+
+    // ChiliFresh
+    if (chilifresh && chilifresh != '(none)' && currentISBN) {
         $('chilifreshReviewLink').setAttribute('id','isbn_'+currentISBN);
         $('chilifreshReviewResult').setAttribute('id','chili_review_'+currentISBN);
         unHideMe($('rdetail_reviews_link'));
         unHideMe($('rdetail_chilifresh_reviews'));
-        chili_init();
+        try {
+            chili_init();
+        } catch(E) {
+            dump(E + '\n');
+            hideMe($('rdetail_reviews_link'));
+            hideMe($('rdetail_chilifresh_reviews'));
+        }
+    }
+
+    // Novelist
+    if (novelist && currentISBN) {
+        unHideMe($('rdetail_novelist_link'));
     }
 }
 
@@ -560,6 +576,7 @@ function rdetailShowExtra(type, args) {
 	hideMe($('rdetail_marc_div'));
 	hideMe($('cn_browse'));
 	hideMe($('rdetail_cn_browse_div'));
+	hideMe($('rdetail_novelist_div'));
 	hideMe($('rdetail_notes_div'));
 
 	removeCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
@@ -571,6 +588,7 @@ function rdetailShowExtra(type, args) {
 	removeCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
 	removeCSSClass($('rdetail_annotation_link'), 'rdetail_extras_selected');
 	removeCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
+	removeCSSClass($('rdetail_novelist_link'), 'rdetail_extras_selected');
 
 	switch(type) {
 
@@ -616,6 +634,11 @@ function rdetailShowExtra(type, args) {
 			req.send();
 			break;
 
+		case "novelist": 
+			addCSSClass($('rdetail_novelist_link'), 'rdetail_extras_selected');
+			unHideMe($('rdetail_novelist_div')); 
+			break;
+
 		case 'cn':
 			addCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
 			unHideMe($('rdetail_cn_browse_div'));
diff --git a/Open-ILS/web/opac/skin/default/js/result_common.js b/Open-ILS/web/opac/skin/default/js/result_common.js
index 743420a97f..1ae9074c52 100644
--- a/Open-ILS/web/opac/skin/default/js/result_common.js
+++ b/Open-ILS/web/opac/skin/default/js/result_common.js
@@ -453,7 +453,7 @@ function resultDisplayRecord(rec, pos, is_mr) {
         }
     }
 
-    if (currentISBN && chilifresh) {
+    if (currentISBN && chilifresh && chilifresh != '(none)') {
         var cfrow = $n(r, "chilifreshReview");
         if (cfrow) {
             removeCSSClass( cfrow, 'hide_me' );
@@ -672,8 +672,8 @@ function fetchGoogleBooksLink () {
 }
 
 function fetchChiliFreshReviews() {
-    if (chilifresh) {
-        chili_init();
+    if (chilifresh && chilifresh != '(none)') {
+        try { chili_init(); } catch(E) { dump(E + '\n'); }
     }
 }
 
diff --git a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_extras.xml b/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_extras.xml
index 9842985151..1913c694f7 100644
--- a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_extras.xml
+++ b/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_extras.xml
@@ -46,7 +46,6 @@
 						class='classic_link'>&rdetail.extras.author.notes;</a>
 				</td>
 
-
 				<td id='rdetail_annotation_link' class='hide_me rdetail_extras_td'
 					style='padding-right: 15px; padding-left: 15px;' >
 					<a href='javascript:rdetailShowExtra("annotation");' 
@@ -59,6 +58,11 @@
 						class='classic_link'>&rdetail.extras.marc;</a>
 				</td>
 
+				<td id='rdetail_novelist_link' class='hide_me rdetail_extras_td'
+					style='padding-right: 15px; padding-left: 15px;' >
+					<a href='javascript:rdetailShowExtra("novelist");' 
+						class='classic_link'>&rdetail.extras.novelist;</a>
+				</td>
 
 			</tr>
 		</thead>
@@ -95,6 +99,16 @@
 			<div id='rdetail_view_marc_box'> </div>
 		</div>
 
+        <div id='rdetail_novelist_div' class='rdetail_extras_div hide_me'>
+            <div id="NoveListSelect" class="NoveListSelect">
+                <div id="NoveListAnchor" class="NoveListSelect"></div>
+                <div id="novsuggestions"></div>
+                <div id="nextreads"></div>
+                <div id="novrelatedauthors"></div>
+               <div id="novrelateditems"></div>
+            </div>
+        </div>
+
 		<div id='rdetail_cn_browse_div' style='text-align: center;' class='hide_me'>
 
 			<div id='cn_browse_none' class='hide_me color_4' style='width: 90%; text-align: center; margin: 10px;'>
@@ -122,8 +136,9 @@
     <!-- ChiliFresh setup -->
     <script language='javascript' type='text/javascript'>
         var chilifresh = '<!--#echo var="OILS_CHILIFRESH_ACCOUNT"-->';
+        if (chilifresh == '(none)') { chilifresh = false; }
     </script>
-    <!--if expr="$OILS_CHILIFRESH_ACCOUNT"-->
+    <!--if expr="${OILS_CHILIFRESH_ACCOUNT} && ${OILS_CHILIFRESH_ACCOUNT}!='(none)'"-->
         <input type="hidden" id="chilifresh_account" name="chilifresh_account"
             value="<!--#echo var='OILS_CHILIFRESH_ACCOUNT'-->" />
         <input type="hidden" id="chilifresh_profile" name="chilifresh_profile"
@@ -133,4 +148,13 @@
         <script language="javascript" type="text/javascript" src="<!--#echo var='OILS_CHILIFRESH_URL'-->"></script>
     <!--endif-->
 
+    <!-- Novelist setup -->
+    <!--if expr="${OILS_NOVELIST_URL} && ${OILS_NOVELIST_URL}!='(none)'"-->
+        <script type="text/javascript" id="EIT" src="<!--#echo var='OILS_NOVELIST_URL'-->"></script>
+    <!--endif-->
+    <script language='javascript' type='text/javascript'>
+        var novelist = '<!--#echo var="OILS_NOVELIST_URL"-->';
+        if (novelist == '(none)') { novelist = false; }
+    </script>
+
 </div>
diff --git a/Open-ILS/web/opac/skin/default/xml/result/result_table.xml b/Open-ILS/web/opac/skin/default/xml/result/result_table.xml
index b34f4d3c1d..46edda88c0 100644
--- a/Open-ILS/web/opac/skin/default/xml/result/result_table.xml
+++ b/Open-ILS/web/opac/skin/default/xml/result/result_table.xml
@@ -222,8 +222,9 @@
     <!-- ChiliFresh setup -->
     <script language='javascript' type='text/javascript'>
         var chilifresh = '<!--#echo var="OILS_CHILIFRESH_ACCOUNT"-->';
+        if (chilifresh=='(none)') { chilifresh = false; }
     </script>
-    <!--if expr="$OILS_CHILIFRESH_ACCOUNT"-->
+    <!--if expr="${OILS_CHILIFRESH_ACCOUNT} && ${OILS_CHILIFRESH_ACCOUNT}!='(none)'"-->
         <input type="hidden" id="chilifresh_account" name="chilifresh_account"
             value="<!--#echo var='OILS_CHILIFRESH_ACCOUNT'-->" />
         <input type="hidden" id="chilifresh_profile" name="chilifresh_profile"
diff --git a/Open-ILS/web/opac/theme/default/css/colors.css b/Open-ILS/web/opac/theme/default/css/colors.css
index fe250477bd..0412887196 100644
--- a/Open-ILS/web/opac/theme/default/css/colors.css
+++ b/Open-ILS/web/opac/theme/default/css/colors.css
@@ -1,6 +1,8 @@
 body a			{ color: black; text-decoration: none;}
 body a:visited { color: black; text-decoration: none;}
 body a:hover	{ color: red; text-decoration: underline;}
+.NoveListSelect a			{ color: blue; text-decoration: underline;}
+.NoveListSelect a:visited	{ color: purple; text-decoration: underline;}
 
 
 /* the idea is to have 4 complimentary colors that 
-- 
2.11.0