{"id":603,"date":"2013-08-02T16:54:04","date_gmt":"2013-08-02T23:54:04","guid":{"rendered":"http:\/\/galencharlton.com\/blog\/?p=603"},"modified":"2013-08-02T16:54:04","modified_gmt":"2013-08-02T23:54:04","slug":"playing-around-with-coce","status":"publish","type":"post","link":"https:\/\/galencharlton.com\/blog\/2013\/08\/playing-around-with-coce\/","title":{"rendered":"Playing around with Coce"},"content":{"rendered":"<p>In the course of looking at the patch for Koha <a href=\"http:\/\/bugs.koha-community.org\/bugzilla3\/show_bug.cgi?id=9580\" title=\"Koha bug 9580\">bug 9580<\/a> today, I ended playing around with Coce.<\/p>\n<p><a href=\"https:\/\/github.com\/fredericd\/coce\" title=\"Coce\">Coce<\/a> is a piece of software written by Fr\u00e9d\u00e9ric Demians and licensed under the GPL that implements a cache for URLs of book cover images.  It arose during a <a href=\"http:\/\/lists.koha-community.org\/pipermail\/koha-devel\/2013-February\/thread.html#38833\">discussion<\/a> of cover images on the Koha development mailing list.<\/p>\n<p>The idea of Coce is rather than have the ILS either directly link to cover images by plugging the normalized ISBN into a URL pattern (as is done for Amazon, Baker &#038; Taylor and Syndetics) or by calling a web service to get the image&#8217;s URL (as is done for Google and Open Library), Coce queries the cover image providers and returns the image URLs.  Furthermore, Coce caches the URLs, meaning once it determines that the Open Library cover image for ISBN 9780563533191 can be found at <a href=\"http:\/\/covers.openlibrary.org\/b\/id\/2520432-L.jpg\">http:\/\/covers.openlibrary.org\/b\/id\/2520432-L.jpg<\/a>, it need not ask again, at least for a while.<\/p>\n<p>Having a cache like this provides some advantages:<\/p>\n<ul>\n<li>Caching the result of web service calls reduces the load on the providers.  That&#8217;s nice for the likes of the Open Library, and while even the most ambitious ILS is not likely to discomfit Amazon or Google, it doesn&#8217;t hurt to reduce the risk of getting rate-limited during summer reading.<\/li>\n<li>Since Coce queries each provider for valid image URLs, users are less likely to see broken cover images in the catalog.<\/li>\n<li>Since Coce can query multiple providers (it currently has support for the Open Library, Google Books, and Amazon&#8217;s Product Advertising API), more records can have cover images displayed as compared to using just one source.<\/li>\n<li>It lends itself to using one Coce instance to service multiple Koha instances.<\/li>\n<\/ul>\n<p>There are also some disadvantages:<\/p>\n<ul>\n<li>It would be yet another service to maintain.<\/li>\n<li>It would be another point of failure.  On the other hand, it looks like it would be easy to set up multiple, load-balanced instances of Coce.<\/li>\n<li>There is the possibility that image URLs might get cached for too long &#8212; although I don&#8217;t think any of the cover image services are in the habit of changing the static image URLs just for fun, they don&#8217;t necessarily guarantee that they will work forever.<\/li>\n<\/ul>\n<p>I set up Coce on a Debian Wheezy VM.  It was relatively simple to install; for posterity here is the procedure I used.  First, I installed Redis, which Coce uses as its cache:<\/p>\n<pre class=\"lang:shell\">\r\nsudo apt-get install redis-server\r\n<\/pre>\n<p>Next, I installed Node.js by <a href=\"https:\/\/github.com\/joyent\/node\/wiki\/Installing-Node.js-via-package-manager#debian-lmde\">building a Debian package, then installing it<\/a>:<\/p>\n<pre class=\"lang:shell\">\r\nsudo apt-get install python g++ make checkinstall\r\nmkdir ~\/src && cd $_\r\nwget -N http:\/\/nodejs.org\/dist\/node-latest.tar.gz\r\ntar xzvf node-latest.tar.gz && cd node-v*\r\n.\/configure\r\ncheckinstall\r\nsudo dpkg -i .\/node_0.10.15-1_amd64.deb <\/pre>\n<p>When I got to the point where <code>checkinstall<\/code> asked me to confirm the metadata for the package, I made sure to remove the &#8220;v&#8221; from the version number.<\/p>\n<p>Next, I checked out Coce and installed the Node.js packages it needs:<\/p>\n<pre class=\"lang:shell\">\r\ncd ~\r\ngit clone https:\/\/github.com\/fredericd\/coce\r\ncd coce\r\nnpm install express redis aws-lib util\r\n<\/pre>\n<p>I then copied &#8221;config.json-sample&#8221; to &#8221;config.json&#8221; and customized it.  The only change I made, though, was to remove Amazon from the list of providers.<\/p>\n<p>Finally, I started the service:<\/p>\n<pre class=\"lang:shell\">\r\nnode webservice.js\r\n<\/pre>\n<p>On my test Koha system, I installed the patch for bug 9580 and set the two system preferences it introduces to appropriate values to point to my Coce instance with the set of cover providers I wanted to use for the test.<\/p>\n<p>The result?  It worked: I did an OPAC search, and some of the titles that got displayed had their cover image provided by Google Books, while others were provided by the Open Library.<\/p>\n<p>There are a few rough edges to work out.  For example, the desired cover image size should probably be part of the client request to Coce, not part of Coce&#8217;s central configuration, and I suspect a bit more work is needed to get it to work properly if the OPAC is run under HTTPS.  That said, this looks promising, and I enjoyed the chance to start playing a bit with Redis and Node.js.<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-603\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/08\/playing-around-with-coce\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li><a href=\"#\" class=\"sharing-anchor sd-button share-more\"><span>More<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><div class=\"sharing-hidden\"><div class=\"inner\" style=\"display: none;\"><ul><li class=\"share-tumblr\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-tumblr sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/08\/playing-around-with-coce\/?share=tumblr\" target=\"_blank\" title=\"Click to share on Tumblr\"><span>Tumblr<\/span><\/a><\/li><li class=\"share-reddit\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-reddit sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/08\/playing-around-with-coce\/?share=reddit\" target=\"_blank\" title=\"Click to share on Reddit\"><span>Reddit<\/span><\/a><\/li><li class=\"share-end\"><\/li><li class=\"share-print\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-print sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/08\/playing-around-with-coce\/\" target=\"_blank\" title=\"Click to print\"><span>Print<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>In the course of looking at the patch for Koha bug 9580 today, I ended playing around with Coce. Coce is a piece of software&#8230;<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-603\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/08\/playing-around-with-coce\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li><a href=\"#\" class=\"sharing-anchor sd-button share-more\"><span>More<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><div class=\"sharing-hidden\"><div class=\"inner\" style=\"display: none;\"><ul><li class=\"share-tumblr\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-tumblr sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/08\/playing-around-with-coce\/?share=tumblr\" target=\"_blank\" title=\"Click to share on Tumblr\"><span>Tumblr<\/span><\/a><\/li><li class=\"share-reddit\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-reddit sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/08\/playing-around-with-coce\/?share=reddit\" target=\"_blank\" title=\"Click to share on Reddit\"><span>Reddit<\/span><\/a><\/li><li class=\"share-end\"><\/li><li class=\"share-print\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-print sd-button share-icon\" href=\"https:\/\/galencharlton.com\/blog\/2013\/08\/playing-around-with-coce\/\" target=\"_blank\" title=\"Click to print\"><span>Print<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"Playing around with Coce #code4lib #kohails","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3gJ9y-9J","_links":{"self":[{"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/posts\/603"}],"collection":[{"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/comments?post=603"}],"version-history":[{"count":20,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/posts\/603\/revisions"}],"predecessor-version":[{"id":623,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/posts\/603\/revisions\/623"}],"wp:attachment":[{"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/media?parent=603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/categories?post=603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/galencharlton.com\/blog\/wp-json\/wp\/v2\/tags?post=603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}