Teach result_common.js to OpenLibrary requests
authorDan Scott <dan@coffeecode.net>
Thu, 2 Jun 2011 18:40:57 +0000 (14:40 -0400)
committerBill Erickson <berick@esilibrary.com>
Tue, 21 Jun 2011 19:18:29 +0000 (15:18 -0400)
Now that the proxied OpenLibrary requests are working, teach
result_common.js to use them and get an advantage from being an
access-rights-authenticated IP address (if applicable).

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/OpenLibrary.pm
Open-ILS/web/opac/skin/default/js/result_common.js

index 32a0350..a157389 100644 (file)
@@ -247,6 +247,8 @@ sub proxy_json {
     my( $self, $key ) = @_;
 
     my $url = $read_api . $key;
+    $logger->debug("proxy_json with key '$key', url $url");
+
     $self->send_json($AC->get_url($url)->content());
 }
 
index 00194f1..3988e1e 100644 (file)
@@ -698,12 +698,14 @@ function fetchOpenLibraryLinks() {
             isbns += 'isbn:' + isbn + '|';
         });
         isbns = isbns.replace(/.$/, '');
-        dojo.require('dojo.io.script');
-        dojo.io.script.get({
-            "url":"http://openlibrary.org/api/volumes/brief/json/" + isbns + '?callback=renderOpenLibraryLinks',
-            "callback": "renderOpenLibraryLinks"
-        });
     }
+
+    dojo.xhrGet({
+        "url": "/opac/extras/ac/proxy/json/" + isbns,
+        "handleAs": "json",
+        "load": function (data) { renderOpenLibraryLinks(data); }
+    });
+
 }
 
 function renderOpenLibraryLinks(response) {