Added Pate's Koha rss stuff.
This commit is contained in:
parent
73e31deb2e
commit
a16ed2e46c
|
|
@ -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
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE rss PUBLIC "-//Netscape Communications/DTD RSS 0.91/EN"
|
||||
"http://my.netscape.com/publish/formats/rss-0.91.dtd">
|
||||
|
||||
<rss version="0.91">
|
||||
|
||||
<channel>
|
||||
<title><TMPL_VAR CHANNELTITLE></title>
|
||||
<link><TMPL_VAR CHANNELLINK></link>
|
||||
<description><TMPL_VAR CHANNELDESC></description>
|
||||
<language><TMPL_VAR CHANNELLANG></language>
|
||||
<lastBuildDate><TMPL_VAR CHANNELLASTBUILD></lastBuildDate>
|
||||
|
||||
<image>
|
||||
<title><TMPL_VAR IMAGETITLE></title>
|
||||
<url><TMPL_VAR IMAGEURL></url>
|
||||
<link><TMPL_VAR IMAGELINK></link>
|
||||
</image>
|
||||
|
||||
<TMPL_LOOP NAME=ITEMS>
|
||||
<item>
|
||||
<title><TMPL_VAR TITLE>, by <TMPL_VAR AUTHOR></title>
|
||||
<link>http://opac.library.org.nz/cgi-bin/koha/opac-searchresults.pl?isbn=<TMPL_VAR ISBN></link>
|
||||
|
||||
</item>
|
||||
</TMPL_LOOP>
|
||||
|
||||
</channel>
|
||||
</rss>
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE rss PUBLIC "-//Netscape Communications/DTD RSS 0.91/EN"
|
||||
"http://my.netscape.com/publish/formats/rss-0.91.dtd">
|
||||
|
||||
<rss version="0.91">
|
||||
|
||||
<channel>
|
||||
<title><TMPL_VAR CHANNELTITLE></title>
|
||||
<link><TMPL_VAR CHANNELLINK></link>
|
||||
<description><TMPL_VAR CHANNELDESC></description>
|
||||
<language><TMPL_VAR CHANNELLANG></language>
|
||||
<lastBuildDate><TMPL_VAR CHANNELLASTBUILD></lastBuildDate>
|
||||
|
||||
<image>
|
||||
<title><TMPL_VAR IMAGETITLE></title>
|
||||
<url><TMPL_VAR IMAGEURL></url>
|
||||
<link><TMPL_VAR IMAGELINK></link>
|
||||
</image>
|
||||
|
||||
<TMPL_LOOP NAME=ITEMS>
|
||||
<item>
|
||||
<title><TMPL_VAR TITLE>, by <TMPL_VAR AUTHOR></title>
|
||||
<link>http://opac.library.org.nz/cgi-bin/koha/opac-searchresults.pl?isbn=<TMPL_VAR ISBN></link>
|
||||
|
||||
</item>
|
||||
</TMPL_LOOP>
|
||||
|
||||
</channel>
|
||||
</rss>
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE rss PUBLIC "-//Netscape Communications/DTD RSS 0.91/EN"
|
||||
"http://my.netscape.com/publish/formats/rss-0.91.dtd">
|
||||
|
||||
<rss version="0.91">
|
||||
|
||||
<channel>
|
||||
<title><TMPL_VAR CHANNELTITLE></title>
|
||||
<link><TMPL_VAR CHANNELLINK></link>
|
||||
<description><TMPL_VAR CHANNELDESC></description>
|
||||
<language><TMPL_VAR CHANNELLANG></language>
|
||||
<lastBuildDate><TMPL_VAR CHANNELLASTBUILD></lastBuildDate>
|
||||
|
||||
<image>
|
||||
<title><TMPL_VAR IMAGETITLE></title>
|
||||
<url><TMPL_VAR IMAGEURL></url>
|
||||
<link><TMPL_VAR IMAGELINK></link>
|
||||
</image>
|
||||
|
||||
<TMPL_LOOP NAME=ITEMS>
|
||||
<item>
|
||||
<title><TMPL_VAR TITLE>, by <TMPL_VAR AUTHOR></title>
|
||||
<link>http://opac.library.org.nz/cgi-bin/koha/opac-searchresults.pl?isbn=<TMPL_VAR ISBN></link>
|
||||
|
||||
</item>
|
||||
</TMPL_LOOP>
|
||||
|
||||
</channel>
|
||||
</rss>
|
||||
|
|
@ -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 (<FILE>) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Loading…
Reference in New Issue