From a16ed2e46c28f005d349696224326b86cedc83fa Mon Sep 17 00:00:00 2001 From: joshferraro Date: Fri, 9 Jan 2004 20:44:42 +0000 Subject: [PATCH] Added Pate's Koha rss stuff. --- rss/lastAcquired.conf | 15 ++++++ rss/lastAcquired.tmpl | 30 ++++++++++++ rss/longestUnseen.conf | 14 ++++++ rss/longestUnseen.tmpl | 30 ++++++++++++ rss/mostReserved.conf | 14 ++++++ rss/mostReserved.tmpl | 30 ++++++++++++ rss/rss.pl | 109 +++++++++++++++++++++++++++++++++++++++++ rss/sm-koha-icon.jpg | Bin 0 -> 1503 bytes 8 files changed, 242 insertions(+) create mode 100755 rss/lastAcquired.conf create mode 100644 rss/lastAcquired.tmpl create mode 100755 rss/longestUnseen.conf create mode 100644 rss/longestUnseen.tmpl create mode 100755 rss/mostReserved.conf create mode 100644 rss/mostReserved.tmpl create mode 100755 rss/rss.pl create mode 100644 rss/sm-koha-icon.jpg diff --git a/rss/lastAcquired.conf b/rss/lastAcquired.conf new file mode 100755 index 0000000000..e133157f48 --- /dev/null +++ b/rss/lastAcquired.conf @@ -0,0 +1,15 @@ +channel +title=Recent Koha Acquisitions +link=http://www.koha.org +desc=The 15 most recent acquisitions +lang=en +lastBuild=Fri, 09 May 2003 08:00:00 +image +title=Koha, the world's best Open Source Library System +url=http://www.koha.org/images/foo.jpg +link=http://www.koha.org +config +tmpl=lastAcquired.tmpl +output=lastAcquired.xml +query=select biblioitems.isbn as isbn, biblio.title as title, biblio.author as author from biblio, biblioitems, items where biblioitems.biblionumber = items.biblionumber and biblio.biblionumber = items.biblionumber and items.dateaccessioned is not NULL order by items.dateaccessioned desc + diff --git a/rss/lastAcquired.tmpl b/rss/lastAcquired.tmpl new file mode 100644 index 0000000000..99893bc896 --- /dev/null +++ b/rss/lastAcquired.tmpl @@ -0,0 +1,30 @@ + + + + + + + + <TMPL_VAR CHANNELTITLE> + + + + + + + <TMPL_VAR IMAGETITLE> + + + + + + + <TMPL_VAR TITLE>, by <TMPL_VAR AUTHOR> + http://opac.library.org.nz/cgi-bin/koha/opac-searchresults.pl?isbn= + + + + + + diff --git a/rss/longestUnseen.conf b/rss/longestUnseen.conf new file mode 100755 index 0000000000..91d7186ffe --- /dev/null +++ b/rss/longestUnseen.conf @@ -0,0 +1,14 @@ +channel +title=Longest Unseen Koha Items +link=http://www.koha.org +desc=The 15 least recently seen items +lang=en +image +title=Koha, the worlds best Open Source Library System +url=http://www.koha.org/images/foo.jpg +link=http://www.koha.org +config +tmpl=longestUnseen.tmpl +output=longestUnseen.xml +query=select biblioitems.isbn as isbn, biblio.title as title, biblio.author as author from biblio, biblioitems, items where biblioitems.biblionumber = items.biblionumber and biblio.biblionumber = items.biblionumber and items.datelastseen is not NULL and items.datelastseen != items.datelastborrowed order by items.datelastseen + diff --git a/rss/longestUnseen.tmpl b/rss/longestUnseen.tmpl new file mode 100644 index 0000000000..99893bc896 --- /dev/null +++ b/rss/longestUnseen.tmpl @@ -0,0 +1,30 @@ + + + + + + + + <TMPL_VAR CHANNELTITLE> + + + + + + + <TMPL_VAR IMAGETITLE> + + + + + + + <TMPL_VAR TITLE>, by <TMPL_VAR AUTHOR> + http://opac.library.org.nz/cgi-bin/koha/opac-searchresults.pl?isbn= + + + + + + diff --git a/rss/mostReserved.conf b/rss/mostReserved.conf new file mode 100755 index 0000000000..437b660a80 --- /dev/null +++ b/rss/mostReserved.conf @@ -0,0 +1,14 @@ +channel +title=Most Reserved Items +link=http://www.koha.org +desc=The 15 most reserved items +lang=en +image +title=Koha, the worlds best Open Source Library System +url=http://www.koha.org/images/foo.jpg +link=http://www.koha.org +config +tmpl=mostReserved.tmpl +output=mostReserved.xml +query=select biblioitems.isbn as isbn, biblio.title as title, biblio.author as author from biblio, biblioitems, items where biblioitems.biblionumber = items.biblionumber and biblio.biblionumber = items.biblionumber and items.reserves is not NULL order by items.reserves desc + diff --git a/rss/mostReserved.tmpl b/rss/mostReserved.tmpl new file mode 100644 index 0000000000..99893bc896 --- /dev/null +++ b/rss/mostReserved.tmpl @@ -0,0 +1,30 @@ + + + + + + + + <TMPL_VAR CHANNELTITLE> + + + + + + + <TMPL_VAR IMAGETITLE> + + + + + + + <TMPL_VAR TITLE>, by <TMPL_VAR AUTHOR> + http://opac.library.org.nz/cgi-bin/koha/opac-searchresults.pl?isbn= + + + + + + diff --git a/rss/rss.pl b/rss/rss.pl new file mode 100755 index 0000000000..a37cf4ae9d --- /dev/null +++ b/rss/rss.pl @@ -0,0 +1,109 @@ +#!/usr/bin/perl -w + +# This script can be used to generate rss 0.91 files for syndication. + + +# it should be run from cron like: +# +# rss.pl config.conf +# + +# Copyright 2003 Katipo Communications +# +# 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 strict; +use HTML::Template; +use C4::Context; +use Time::Local; + +my $file = $ARGV[0]; +my %config = getConf("config"); +my $outFile = $config{"output"}; +my $feed = HTML::Template->new(filename => $config{"tmpl"}); + +my %channel = getConf("channel"); +$feed->param(CHANNELTITLE => $channel{'title'}); +$feed->param(CHANNELLINK => $channel{'link'}); +$feed->param(CHANNELDESC => $channel{'desc'}); +$feed->param(CHANNELLANG => $channel{'lang'}); +$feed->param(CHANNELLASTBUILD => getDate()); + +my %image = getConf("image"); +$feed->param(IMAGETITLE => $image{'title'}); +$feed->param(IMAGEURL => $image{'url'}); +$feed->param(IMAGELINK => $image{'link'}); + +# +# handle the items +# +$feed->param(ITEMS => getItems($config{'query'})); + +open(FILE, ">$outFile") or die "can't open $outFile"; +print FILE $feed->output(); +close FILE; + +sub getDate { + my $date = localtime(timelocal(localtime)); + return $date; +} + +sub getConf { + my $section = shift; + my %return; + my $inSection = 0; + + open(FILE,$file) or die "can't open $file"; + while () { + if ($inSection) { + my @line = split(/=/,$_,2); + unless ($line[1]) { + $inSection=0; + } else { + my ($key, $value) = @line; + chomp $value; + $return{$key} = $value; + } + } else { + if ($_ eq "$section\n") { $inSection = 1 } + } + } + return %return; +} +sub getItems { + my $query = shift; + $query .= " limit 15"; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare($query); + $sth->execute; + my @return; + while (my $data = $sth->fetchrow_hashref) { + foreach my $key (keys %$data) { + my $value=$data->{$key}; + $value=~s/\&/\&/g and $data->{$key}=$value; + } + push @return, $data; + } + $sth->finish; + return \@return; +} + + + + + + diff --git a/rss/sm-koha-icon.jpg b/rss/sm-koha-icon.jpg new file mode 100644 index 0000000000000000000000000000000000000000..152d6c9b54d8309cd3bddbbf89b4733872bdd6cf GIT binary patch literal 1503 zcmb7x_jNf_xb+$`F!8s&sRJuo&u129T*M(2!eoT)JV{tf50#Q#>+fWCG)8A!aXhNb;D0n@Zr5V|RXi6df2?617I6@w=ML}T;SqrB{ z{@)U}0w`I)3ZO$lZ2*D-p(s$?3E%(#0)a~2_*YPvlr#WBWMn0-84`ei5Gha=4uSn0 z0U=N+6d;Y(a+6WgCXsF33o$xDF=_c1>IVwiV9F{4dk=Q0WOFMBNT~n80#FH71|qTa zQ4*+>1PlA;CJ2$ZC@nOpO&X(}reqtGU;klIJPshBprk1j1y}=-2Ldpg;RlV4vr?&~ z2We9Q6=wa=)|S07@_H+oTMnTM$FKJ@qiXpGzDDd#pY#zqb%su^yfe~}F2C}rJ>#d# zHG86t>C)JZZ_HJ0N1&xQiVq0)w~S||5g6EA-9g08>Y-GzJ*eFZ>uc^)^aI| zkPV_1%e^Ldk!%v!W|!o4V*X4QwrP}ibyRS)x#h_+(_TajBRZeo$Kv{ZR6{CM?;l?E z{XAHu8feZe*F(=SDfN_s9_;q)0)d+1HKnV~EB4m~{hUnEu)o3F(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