[Koha-patches] [PATCH] LibraryThing Cover Images
Kyle Hall
kyle.m.hall at gmail.com
Wed Sep 16 15:35:47 CEST 2009
Does anyone have a better idea for storing the cached images?
LibraryThing limits the number of images you can access per day, and
recommends caching them. As it stands, they are stored in
KOHA_ROOL/koha-tmpl/intranet-tmpl
Kyle
http://www.kylehall.info
Information Technology
Crawford County Federated Library System ( http://www.ccfls.org )
On Wed, Sep 16, 2009 at 9:12 AM, Kyle M Hall <kyle.m.hall at gmail.com> wrote:
> ---
> C4/External/LibraryThing.pm | 104 ++++++++++++++++++++
> catalogue/detail.pl | 7 ++
> catalogue/search.pl | 7 ++
> installer/data/mysql/en/mandatory/sysprefs.sql | 5 +
> .../1-Obligatoire/unimarc_standard_systemprefs.sql | 5 +
> installer/data/mysql/updatedatabase.pl | 11 ++
> koha-tmpl/intranet-tmpl/cover_images/large/readme | 2 +
> koha-tmpl/intranet-tmpl/cover_images/medium/readme | 2 +
> koha-tmpl/intranet-tmpl/cover_images/small/readme | 2 +
> .../prog/en/modules/catalogue/detail.tmpl | 16 +++-
> .../prog/en/modules/catalogue/results.tmpl | 7 ++
> .../opac-tmpl/prog/en/modules/opac-detail.tmpl | 2 +-
> .../opac-tmpl/prog/en/modules/opac-results.tmpl | 5 +
> opac/opac-detail.pl | 17 +++-
> opac/opac-search.pl | 9 ++
> 15 files changed, 193 insertions(+), 8 deletions(-)
> create mode 100644 C4/External/LibraryThing.pm
> create mode 100644 koha-tmpl/intranet-tmpl/cover_images/large/readme
> create mode 100644 koha-tmpl/intranet-tmpl/cover_images/medium/readme
> create mode 100644 koha-tmpl/intranet-tmpl/cover_images/small/readme
>
> diff --git a/C4/External/LibraryThing.pm b/C4/External/LibraryThing.pm
> new file mode 100644
> index 0000000..4abe599
> --- /dev/null
> +++ b/C4/External/LibraryThing.pm
> @@ -0,0 +1,104 @@
> +package C4::External::LibraryThing;
> +# Copyright (C) 2009 Kyle Hall
> +# <kyle.m.hall at gmail dot com>
> +#
> +# This file is part of Koha.
> +#
> +# Koha is free software; you can redistribute it and/or modify it under the
> +# terms of the GNU General Public License as published by the Free Software
> +# Foundation; either version 2 of the License, or (at your option) any later
> +# version.
> +#
> +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
> +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
> +# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License along with
> +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
> +# Suite 330, Boston, MA 02111-1307 USA
> +
> +use LWP::Simple;
> +
> +use C4::Context;
> +
> +use strict;
> +use warnings;
> +
> +use vars qw($VERSION @ISA @EXPORT);
> +
> +BEGIN {
> + require Exporter;
> + $VERSION = 1;
> + @ISA = qw(Exporter);
> + @EXPORT = qw(
> + get_librarything_cover_url
> + );
> +}
> +
> +our $LIBRARYTHING_BASE_URL = 'http://covers.librarything.com/devkey/KEY/SIZE/isbn/ISBN';
> +our $COVERIMAGE_CACHE_URL = '/intranet-tmpl/cover_images/SIZE/';
> +our $COVERIMAGE_CACHE_DIR = C4::Context->intranetdir . '/koha-tmpl/intranet-tmpl/cover_images/SIZE/';
> +
> +=head1 NAME
> +
> +C4::External::LibraryThing - Functions for retrieving LibraryThing.com content in Koha
> +
> +=head2 FUNCTIONS
> +
> +This module provides facilities for retrieving LibraryThing.com content in Koha
> +
> +=cut
> +
> +=head2 slashifyDate
> +
> + $cover_url = get_librarything_cover_url( $isbn, $type );
> +
> + $isbn is the ISBN of the book to whose cover we are to get the URL for.
> + $type is the target for the image ( 'list' as in a list of results OR 'detail' as in a single bib view ). Defaults to 'list'.
> +=cut
> +
> +
> +sub get_librarything_cover_url {
> + my ( $isbn, $type ) = @_;
> + my $filename = "$isbn.jpg";
> +
> + unless ( $type eq 'list' || $type eq 'detail' ) { $type = 'list'; }
> +
> + my $image_size;
> + if ( $type eq 'list' ) { $image_size = C4::Context->preference('LibraryThingCoverImageSizeResults'); }
> + if ( $type eq 'detail' ) { $image_size = C4::Context->preference('LibraryThingCoverImageSizeDetails'); }
> + unless ( $image_size ) { $image_size = 'medium'; } ## $image_size must be 'small', 'medium', or 'large'
> +
> + my $coverimage_path = $COVERIMAGE_CACHE_DIR;
> + $coverimage_path =~ s/SIZE/$image_size/;
> + $coverimage_path .= $filename;
> +
> + my $coverimage_url = $COVERIMAGE_CACHE_URL;
> + $coverimage_url =~ s/SIZE/$image_size/;
> + $coverimage_url .= $filename;
> +
> + ## Check to see if cover image is already cached for this isbn
> + unless ( -e $coverimage_path ) {
> + ## Image not cached, grab it first
> + my $developer_key = C4::Context->preference('LibraryThingDeveloperKey');
> + my $librarything_url = $LIBRARYTHING_BASE_URL;
> + $librarything_url =~ s/KEY/$developer_key/;
> + $librarything_url =~ s/ISBN/$isbn/;
> + $librarything_url =~ s/SIZE/$image_size/;
> +
> + my $tmp = getstore( $librarything_url, $coverimage_path );
> + }
> +
> + return $coverimage_url;
> +}
> +
> +1;
> +__END__
> +
> +=head1 NOTES
> +
> +=head1 AUTHOR
> +
> +Kyle M Hall <kyle.m.hall at gmail.com>
> +
> +=cut
> diff --git a/catalogue/detail.pl b/catalogue/detail.pl
> index 6c2afdc..71d7911 100755
> --- a/catalogue/detail.pl
> +++ b/catalogue/detail.pl
> @@ -34,6 +34,7 @@ use C4::Members;
> use C4::Serials;
> use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn);
> use C4::External::Amazon;
> +use C4::External::LibraryThing;
> use C4::Search; # enabled_staff_search_views
> use C4::VirtualShelves;
>
> @@ -65,6 +66,12 @@ my $ean = GetNormalizedEAN($record,$marcflavour);
> my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
> my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
>
> +# LibraryThing Stuff
> +if ( C4::Context->preference('LibraryThingCoverImages') ) {
> + my $librarything_cover_url = get_librarything_cover_url( $isbn, 'detail' );
> + $template->param( LibraryThingCoverImage => $librarything_cover_url );
> +}
> +
> $template->param(
> normalized_upc => $upc,
> normalized_ean => $ean,
> diff --git a/catalogue/search.pl b/catalogue/search.pl
> index 33da2b0..4b41270 100755
> --- a/catalogue/search.pl
> +++ b/catalogue/search.pl
> @@ -146,6 +146,7 @@ use C4::Languages qw(getAllLanguages);
> use C4::Koha;
> use POSIX qw(ceil floor);
> use C4::Branch; # GetBranches
> +use C4::External::LibraryThing;
>
> # create a new CGI object
> # FIXME: no_undef_params needs to be tested
> @@ -521,6 +522,12 @@ for (my $i=0;$i<@servers;$i++) {
> exit;
> }
>
> + if ( C4::Context->preference("LibraryThingCoverImages") ) {
> + foreach my $result ( @newresults ) {
> + ## Add LibraryThing Cover Images
> + $result->{LibraryThingCoverImageURL} = get_librarything_cover_url( $result->{normalized_isbn}, 'list' );
> + }
> + }
>
> if ($hits) {
> $template->param(total => $hits);
> diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql
> index 6f60fa7..ccb5d3e 100644
> --- a/installer/data/mysql/en/mandatory/sysprefs.sql
> +++ b/installer/data/mysql/en/mandatory/sysprefs.sql
> @@ -262,3 +262,8 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
> INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', '', 'If ON, displays the format, audience, type icons in XSLT MARC21 results and display pages.', 'YesNo');
> INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');
> INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('ShowPatronImageInWebBasedSelfCheck', '0', 'If ON, displays patron image when a patron uses web-based self-checkout', '', 'YesNo');
> +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('LibraryThingCoverImages', '0', '', 'Display Cover Images in Staff Client from LibraryThing.', 'YesNo');
> +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('LibraryThingCoverImageSizeResults', 'small', 'small|medium|large', 'LibraryThing Cover Image size for search results lists.', 'Choice');
> +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('LibraryThingCoverImageSizeDetails', 'medium', 'small|medium|large', 'LibraryThing Cover Image size for details view', 'Choice');
> +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('LibraryThingDeveloperKey', '', '', 'Necessary for using LibraryThing Cover Images. See http://www.librarything.com/services/keys.php', '');
> +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('OPACLibraryThingCoverImages', '0', '', 'Display cover images in OPAC from LibraryThing', 'YesNo');
> diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
> index bee360a..ba4bbda 100644
> --- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
> +++ b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
> @@ -261,3 +261,8 @@ INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('H
> INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', '', 'Si activé, affiche le format, le type de public et les icônes de type en XSLT (MARC21)).', 'YesNo');
> INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');
> INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('ShowPatronImageInWebBasedSelfCheck', '0', 'Si activé, affiche la photo de l''adhérent lors de l''utilisation de la console de prêt auto-contrôlé', '', 'YesNo');
> +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('LibraryThingCoverImages', '0', '', 'Display Cover Images in Staff Client from LibraryThing.', 'YesNo');
> +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('LibraryThingCoverImageSizeResults', 'small', 'small|medium|large', 'LibraryThing Cover Image size for search results lists.', 'Choice');
> +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('LibraryThingCoverImageSizeDetails', 'medium', 'small|medium|large', 'LibraryThing Cover Image size for details view', 'Choice');
> +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('LibraryThingDeveloperKey', '', '', 'Necessary for using LibraryThing Cover Images. See http://www.librarything.com/services/keys.php', '');
> +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('OPACLibraryThingCoverImages', '0', '', 'Display cover images in OPAC from LibraryThing', 'YesNo');
> diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
> index 10c3451..e5fd30e 100755
> --- a/installer/data/mysql/updatedatabase.pl
> +++ b/installer/data/mysql/updatedatabase.pl
> @@ -2675,6 +2675,17 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
> SetVersion ($DBversion);
> }
>
> +$DBversion = '3.01.00.062';
> +if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
> + $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('LibraryThingCoverImages', '0', '', 'Display Cover Images in Staff Client from LibraryThing.', 'YesNo')");
> + $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('LibraryThingDeveloperKey', '', '', 'Necessary for using LibraryThing Cover Images. See http://www.librarything.com/services/keys.php', '')");
> + $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('OPACLibraryThingCoverImages', '0', '', 'Display cover images in OPAC from LibraryThing', 'YesNo')");
> + $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('LibraryThingCoverImageSizeResults', 'small', 'small|medium|large', 'LibraryThing Cover Image size for search results lists.', 'Choice')");
> + $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('LibraryThingCoverImageSizeDetails', 'medium', 'small|medium|large', 'LibraryThing Cover Image size for details view', 'Choice')");
> + SetVersion ($DBversion);
> + print "Upgrade to $DBversion done ( Added system preferences for LibraryThing Cover Images )\n";
> +}
> +
> =item DropAllForeignKeys($table)
>
> Drop all foreign keys of the table $table
> diff --git a/koha-tmpl/intranet-tmpl/cover_images/large/readme b/koha-tmpl/intranet-tmpl/cover_images/large/readme
> new file mode 100644
> index 0000000..11f7402
> --- /dev/null
> +++ b/koha-tmpl/intranet-tmpl/cover_images/large/readme
> @@ -0,0 +1,2 @@
> +Please do not delete this file. It exists to keep the cms from deleting this
> +directory.
> \ No newline at end of file
> diff --git a/koha-tmpl/intranet-tmpl/cover_images/medium/readme b/koha-tmpl/intranet-tmpl/cover_images/medium/readme
> new file mode 100644
> index 0000000..11f7402
> --- /dev/null
> +++ b/koha-tmpl/intranet-tmpl/cover_images/medium/readme
> @@ -0,0 +1,2 @@
> +Please do not delete this file. It exists to keep the cms from deleting this
> +directory.
> \ No newline at end of file
> diff --git a/koha-tmpl/intranet-tmpl/cover_images/small/readme b/koha-tmpl/intranet-tmpl/cover_images/small/readme
> new file mode 100644
> index 0000000..11f7402
> --- /dev/null
> +++ b/koha-tmpl/intranet-tmpl/cover_images/small/readme
> @@ -0,0 +1,2 @@
> +Please do not delete this file. It exists to keep the cms from deleting this
> +directory.
> \ No newline at end of file
> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
> index 251c6df..98a63c5 100644
> --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
> +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
> @@ -108,9 +108,21 @@ function verify_images() {
> <!-- /TMPL_IF -->
> </ul>
> </div>
> +
> +<!-- TMPL_IF NAME="LibraryThingCoverImage" -->
> + <div class="yui-u" id="bookcoverimg">
> + <img border="0" src="<!-- TMPL_VAR NAME="LibraryThingCoverImage" -->" alt="" />
> + </div>
> +<!-- /TMPL_IF -->
>
> -<!-- TMPL_IF NAME="AmazonEnabled" --><!-- TMPL_IF NAME="AmazonCoverImages" --><div class="yui-u" id="bookcoverimg">
> -<a href="http://www.amazon<!-- TMPL_VAR NAME="AmazonTld" -->/gp/reader/<!-- TMPL_VAR NAME="normalized_isbn" -->/ref=sib_dp_pt/002-7879865-0184864#reader-link"><img border="0" src="http://images.amazon.com/images/P/<!-- TMPL_VAR NAME="normalized_isbn" -->.01.MZZZZZZZ.jpg" alt="" /></a></div><!-- /TMPL_IF --><!-- /TMPL_IF -->
> +<!-- TMPL_IF NAME="AmazonEnabled" -->
> + <!-- TMPL_IF NAME="AmazonCoverImages" -->
> + <div class="yui-u" id="bookcoverimg">
> + <a href="http://www.amazon<!-- TMPL_VAR NAME="AmazonTld" -->/gp/reader/<!-- TMPL_VAR NAME="normalized_isbn" -->/ref=sib_dp_pt/002-7879865-0184864#reader-link"><img border="0" src="http://images.amazon.com/images/P/<!-- TMPL_VAR NAME="normalized_isbn" -->.01.MZZZZZZZ.jpg" alt="" /></a>
> + </div>
> + <!-- /TMPL_IF -->
> +<!-- /TMPL_IF -->
> +
>
> <div class="yui-u" style="margin-top: 1em;">
> <ul>
> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl
> index 5bb82c2..53a76c4 100644
> --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl
> +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl
> @@ -328,6 +328,13 @@ function GetZ3950Terms(){
> <img src="<!-- TMPL_IF NAME="normalized_isbn" -->http://images.amazon.com/images/P/<!-- TMPL_VAR name="normalized_isbn" -->.01.TZZZZZZZ.jpg<!-- TMPL_ELSE -->http://g-images.amazon.com/images/G/01/x-site/icons/no-img-sm.gif<!-- /TMPL_IF -->" alt="image" class="thumbnail" /> <!-- /TMPL_IF -->
> </a></td>
> <!-- /TMPL_IF -->
> +
> + <!-- TMPL_IF NAME="LibraryThingCoverImageURL" -->
> + <td>
> + <img src="<!-- TMPL_VAR NAME="LibraryThingCoverImageURL" -->" alt="" class="thumbnail" />
> + </td>
> + <!-- /TMPL_IF -->
> +
> <td>
> <input type="checkbox" class="selection" value="<!-- TMPL_VAR NAME="biblionumber" -->" style="display:none" />
> </td>
> diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
> index ae40837..d7929ab 100644
> --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
> +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
> @@ -70,7 +70,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
> <div id="catalogue_detail_biblio">
>
> <div id="bookcover">
> - <!-- TMPL_IF NAME="OPACAmazonEnabled" --><!-- TMPL_IF NAME="OPACAmazonCoverImages" --><!-- TMPL_IF NAME="OPACURLOpenInNewWindow" --><a href="http://www.amazon<!-- TMPL_VAR NAME="AmazonTld" -->/gp/reader/<!-- TMPL_VAR NAME="normalized_isbn" -->/ref=sib_dp_pt/002-7879865-0184864#reader-link" target="_blank"><img border="0" src="http://images.amazon.com/images/P/<!-- TMPL_VAR NAME="normalized_isbn" -->.01.MZZZZZZZ.jpg" alt="Cover Image" /></a><!-- TMPL_ELSE --><a href="http://www.amazon<!-- TMPL_VAR NAME="AmazonTld" -->/gp/reader/<!-- TMPL_VAR NAME="normalized_isbn" -->/ref=sib_dp_pt/002-7879865-0184864#reader-link"><img border="0" src="http://images.amazon.com/images/P/<!-- TMPL_VAR NAME="normalized_isbn" -->.01.MZZZZZZZ.jpg" alt="Cover Image" /></a><!-- /TMPL_IF --><!-- /TMPL_IF --><!-- /TMPL_IF -->
> + <!-- TMPL_IF NAME="OPACLibraryThingCoverImage" --><img border="0" src="<!-- TMPL_VAR NAME="OPACLibraryThingCoverImage" -->" /><!-- /TMPL_IF -->
> <!-- TMPL_IF NAME="SyndeticsEnabled" --><!-- TMPL_IF NAME="SyndeticsCoverImages" --><!-- TMPL_IF NAME="content_identifier_exists" --><img src="http://www.syndetics.com/index.aspx?isbn=<!-- TMPL_VAR NAME="normalized_isbn" -->/<!-- TMPL_VAR NAME="SyndeticsCoverImageSize" -->.GIF&client=<!-- TMPL_VAR NAME="SyndeticsClientCode" -->&type=xw10<!-- TMPL_IF NAME="normalized_upc" -->&upc=<!-- TMPL_VAR NAME="normalized_upc" --><!-- /TMPL_IF --><!-- TMPL_IF NAME="normalized_oclc" -->&oclc=<!-- TMPL_VAR NAME="normalized_oclc" --><!-- /TMPL_IF -->" alt="" class="thumbnail" /><!-- TMPL_ELSE --><span class="no-image">No cover image available</span><!-- /TMPL_IF --><!-- /TMPL_IF --><!-- /TMPL_IF -->
> <!-- TMPL_IF NAME="GoogleJackets" --><div style="block" title="<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->" class="<!-- TMPL_VAR NAME="normalized_isbn" -->" id="gbs-thumbnail-preview"></div><!-- /TMPL_IF -->
> <!-- TMPL_IF NAME="BakerTaylorEnabled" --><!-- TMPL_IF NAME="normalized_isbn" --><!-- TMPL_IF NAME="OPACURLOpenInNewWindow" --><a href="https://<!-- TMPL_VAR NAME="BakerTaylorBookstoreURL" ESCAPE="HTML" --><!-- TMPL_VAR NAME="normalized_isbn" -->" target="_blank"><img alt="See Baker & Taylor" src="<!-- TMPL_VAR NAME="BakerTaylorImageURL" ESCAPE="HTML" --><!-- TMPL_VAR NAME="normalized_isbn" -->" /></a><!-- TMPL_ELSE --><a href="https://<!-- TMPL_VAR NAME="BakerTaylorBookstoreURL" ESCAPE="HTML" --><!-- TMPL_VAR NAME="normalized_isbn" -->"><img alt="See Baker & Taylor" src="<!-- TMPL_VAR NAME="BakerTaylorImageURL" ESCAPE="HTML" --><!-- TMPL_VAR NAME="normalized_isbn" -->" /></a><!-- /TMPL_IF --><!-- /TMPL_IF --><!-- /TMPL_IF -->
> diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
> index eb995f1..6abab5a 100644
> --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
> +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
> @@ -473,6 +473,11 @@ $(document).ready(function(){
> </span>
> </td><td>
> <a class="p1" href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">
> +
> + <!-- TMPL_IF NAME="OPACLibraryThingCoverImageURL" -->
> + <img src="<!-- TMPL_VAR NAME="OPACLibraryThingCoverImageURL" -->" alt="" class="thumbnail" />
> + <!-- /TMPL_IF -->
> +
> <!-- TMPL_IF NAME="OPACAmazonEnabled" --><!-- TMPL_IF NAME="OPACAmazonCoverImages" --><!-- TMPL_IF NAME="normalized_isbn" --><img src="http://images.amazon.com/images/P/<!-- TMPL_VAR NAME="normalized_isbn" -->.01.TZZZZZZZ.jpg" alt="" class="thumbnail" /><!-- TMPL_ELSE --><span class="no-image">No cover image available</span><!-- /TMPL_IF --><!-- /TMPL_IF --><!-- /TMPL_IF -->
>
> <!-- TMPL_IF NAME="SyndeticsEnabled" --><!-- TMPL_IF NAME="SyndeticsCoverImages" --><!-- TMPL_IF NAME="content_identifier_exists" --><img src="http://www.syndetics.com/index.aspx?isbn=<!-- TMPL_VAR NAME="normalized_isbn" -->/SC.GIF&client=<!-- TMPL_VAR NAME="SyndeticsClientCode" -->&type=xw10<!-- TMPL_IF NAME="normalized_upc" -->&upc=<!-- TMPL_VAR NAME="normalized_upc" --><!-- /TMPL_IF --><!-- TMPL_IF NAME="normalized_oclc" -->&oclc=<!-- TMPL_VAR NAME="normalized_oclc" --><!-- /TMPL_IF -->" alt="" class="thumbnail" /><!-- TMPL_ELSE --><span class="no-image">No cover image available</span><!-- /TMPL_IF --><!-- /TMPL_IF --><!-- /TMPL_IF -->
> diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl
> index c3b104b..526cb69 100755
> --- a/opac/opac-detail.pl
> +++ b/opac/opac-detail.pl
> @@ -34,6 +34,7 @@ use C4::Tags qw(get_tags);
> use C4::Dates qw/format_date/;
> use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn);
> use C4::External::Amazon;
> +use C4::External::LibraryThing;
> use C4::External::Syndetics qw(get_syndetics_index get_syndetics_summary get_syndetics_toc get_syndetics_excerpt get_syndetics_reviews get_syndetics_anotes );
> use C4::Review;
> use C4::Serials;
> @@ -42,10 +43,10 @@ use C4::VirtualShelves;
> use C4::XSLT;
>
> BEGIN {
> - if (C4::Context->preference('BakerTaylorEnabled')) {
> - require C4::External::BakerTaylor;
> - import C4::External::BakerTaylor qw(&image_url &link_url);
> - }
> + if (C4::Context->preference('BakerTaylorEnabled')) {
> + require C4::External::BakerTaylor;
> + import C4::External::BakerTaylor qw(&image_url &link_url);
> + }
> }
>
> my $query = new CGI;
> @@ -268,7 +269,6 @@ $template->param(
> );
>
> # Lists
> -
> if (C4::Context->preference("virtualshelves") ) {
> $template->param( 'GetShelves' => GetBibliosShelves( $biblionumber ) );
> }
> @@ -283,6 +283,13 @@ if (C4::Context->preference("OPACFRBRizeEditions")==1) {
> };
> if ($@) { warn "XISBN Failed $@"; }
> }
> +
> +# LibraryThing Stuff
> +if ( C4::Context->preference('OPACLibraryThingCoverImages') ) {
> + my $librarything_cover_url = get_librarything_cover_url( $isbn, 'detail' );
> + $template->param( OPACLibraryThingCoverImage => $librarything_cover_url );
> +}
> +
> # Amazon.com Stuff
> if ( C4::Context->preference("OPACAmazonEnabled") ) {
> $template->param( AmazonTld => get_amazon_tld() );
> diff --git a/opac/opac-search.pl b/opac/opac-search.pl
> index 9261b55..323c82d 100755
> --- a/opac/opac-search.pl
> +++ b/opac/opac-search.pl
> @@ -14,6 +14,7 @@ use C4::Auth qw(:DEFAULT get_session);
> use C4::Search;
> use C4::Biblio; # GetBiblioData
> use C4::Koha;
> +use C4::External::LibraryThing;
> use C4::Tags qw(get_tags);
> use POSIX qw(ceil floor strftime);
> use C4::Branch; # GetBranches
> @@ -467,6 +468,14 @@ for (my $i=0;$i<=@servers;$i++) {
> $template->param(SEARCH_RESULTS => \@newresults,
> OPACItemsResultsDisplay => (C4::Context->preference("OPACItemsResultsDisplay") eq "itemdetails"?1:0),
> );
> +
> + if ( C4::Context->preference("OPACLibraryThingCoverImages") ) {
> + foreach my $result ( @newresults ) {
> + ## Add LibraryThing Cover Images
> + $result->{OPACLibraryThingCoverImageURL} = get_librarything_cover_url( $result->{normalized_isbn}, 'list' );
> + }
> + }
> +
> ## Build the page numbers on the bottom of the page
> my @page_numbers;
> # total number of pages there will be
> --
> 1.5.6.5
>
>
More information about the Koha-patches
mailing list