View | Details | Raw Unified | Return to bug 9000
Collapse All | Expand All

(-)a/misc/cronjobs/rss/README (-18 / +17 lines)
Lines 21-27 is invoked like this (in the case of lastAcquired): Link Here
21
21
22
The basic process is that rss reads the config file
22
The basic process is that rss reads the config file
23
(lastAcquired.conf) to determine RSS header information, the SQL query
23
(lastAcquired.conf) to determine RSS header information, the SQL query
24
used to generate the results, and the HTML::Template style used to
24
used to generate the results, and the Template Tookit style used to
25
format the output.  Since you'll likely to want to create your own RSS
25
format the output.  Since you'll likely to want to create your own RSS
26
content, or at least modify the ones present here, let's review the
26
content, or at least modify the ones present here, let's review the
27
config file and the template file.
27
config file and the template file.
Lines 51-66 title=Koha, the worlds best Open Source Library System Link Here
51
url=http://www.koha-community.org/images/foo.jpg
51
url=http://www.koha-community.org/images/foo.jpg
52
link=http://www.koha-community.org
52
link=http://www.koha-community.org
53
config
53
config
54
tmpl=lastAcquired.tmpl
54
tmpl=lastAcquired.tt
55
output=lastAcquired.xml
55
output=lastAcquired.xml
56
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
56
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
57
57
58
58
59
This data (and the data acquired from the query) are then used to fill
59
This data (and the data acquired from the query) are then used to fill
60
in the template.  Most of the template is boilerplate and should not
60
in the template.  Most of the template is boilerplate and should not
61
be edited.  The section within the <TMPL_LOOP NAME=ITEMS>
61
be edited.  The section within the [% FOREACH i IN ITEMS %] ... [% END %]
62
... </TMPL_LOOP> is the part which can be modified to create your own
62
is the part which can be modified to create your own RSS content.
63
RSS content.  
64
63
65
Here's the lastAcquired.tmpl file:
64
Here's the lastAcquired.tmpl file:
66
65
Lines 72-96 Here's the lastAcquired.tmpl file: Link Here
72
<rss version="0.91">
71
<rss version="0.91">
73
72
74
<channel>
73
<channel>
75
 <title><TMPL_VAR CHANNELTITLE></title>
74
 <title>[% CHANNELTITLE %]</title>
76
 <link><TMPL_VAR CHANNELLINK></link>
75
 <link>[% CHANNELLINK %]</link>
77
 <description><TMPL_VAR CHANNELDESC></description>
76
 <description>[% CHANNELDESC %]</description>
78
 <language><TMPL_VAR CHANNELLANG></language>
77
 <language>[% CHANNELLANG %]</language>
79
 <lastBuildDate><TMPL_VAR CHANNELLASTBUILD></lastBuildDate>
78
 <lastBuildDate>[% CHANNELLASTBUILD %]</lastBuildDate>
80
79
81
 <image>
80
 <image>
82
  <title><TMPL_VAR IMAGETITLE></title>
81
  <title>[% IMAGETITLE %]</title>
83
  <url><TMPL_VAR IMAGEURL></url>
82
  <url>[% IMAGEURL %]</url>
84
  <link><TMPL_VAR IMAGELINK></link>
83
  <link>[% IMAGELINK %]</link>
85
 </image>
84
 </image>
86
85
87
<TMPL_LOOP NAME=ITEMS>
86
[% FOREACH i IN ITEMS %]
88
 <item>
87
 <item>
89
  <title><TMPL_VAR TITLE>, by <TMPL_VAR AUTHOR></title>
88
  <title>[% i.TITLE %], by [% i.AUTHOR %]</title>
90
  <link>http://opac.library.org.nz/cgi-bin/koha/opac-searchresults.pl?isbn=<TMPL_VAR ISBN></link>
89
  <link>http://opac.library.org.nz/cgi-bin/koha/opac-searchresults.pl?isbn=[% i.ISBN %]</link>
91
92
 </item>
90
 </item>
93
</TMPL_LOOP>
91
[% END %]
94
92
95
</channel>
93
</channel>
96
</rss>
94
</rss>
Lines 100-102 Originally written by Pat Eyler (pate@eylerfamily.org), suggestions, Link Here
100
advice, and help came from 'Content Syndication with RSS', Chris
98
advice, and help came from 'Content Syndication with RSS', Chris
101
Cormack, Mike Hansen, Steve Tonnesen and a variety of folks on #koha at 
99
Cormack, Mike Hansen, Steve Tonnesen and a variety of folks on #koha at 
102
irc.katipo.co.nz.
100
irc.katipo.co.nz.
101
Updated for use with Template Toolkit by Kyle M Hall, ByWater Solutions
(-)a/misc/cronjobs/rss/rss.pl (-28 / +26 lines)
Lines 8-13 Link Here
8
#
8
#
9
9
10
# Copyright 2003 Katipo Communications
10
# Copyright 2003 Katipo Communications
11
# Copyright 2014 ByWater Solutions
11
#
12
#
12
# This file is part of Koha.
13
# This file is part of Koha.
13
#
14
#
Lines 24-33 Link Here
24
# with Koha; if not, write to the Free Software Foundation, Inc.,
25
# with Koha; if not, write to the Free Software Foundation, Inc.,
25
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26
27
27
use strict;
28
use Modern::Perl;
28
use warnings;
29
29
30
use HTML::Template::Pro;
30
use Template;
31
use C4::Context;
31
use C4::Context;
32
use Time::Local;
32
use Time::Local;
33
use POSIX;
33
use POSIX;
Lines 36-70 my $dbh = C4::Context->dbh; Link Here
36
my $file    = $ARGV[0];
36
my $file    = $ARGV[0];
37
my %config  = getConf("config");
37
my %config  = getConf("config");
38
my $outFile = $config{"output"};
38
my $outFile = $config{"output"};
39
my $feed    = HTML::Template::Pro->new( filename => $config{"tmpl"} );
39
my $feed    = Template->new();
40
40
41
my %channel = getConf("channel");
41
my %channel = getConf("channel");
42
$feed->param( CHANNELTITLE     => $channel{'title'} );
42
my %image   = getConf("image");
43
$feed->param( CHANNELLINK      => $channel{'link'} );
43
my $vars    = {
44
$feed->param( CHANNELDESC      => $channel{'desc'} );
44
    CHANNELTITLE     => $channel{'title'},
45
$feed->param( CHANNELLANG      => $channel{'lang'} );
45
    CHANNELLINK      => $channel{'link'},
46
$feed->param( CHANNELLASTBUILD => getDate() );
46
    CHANNELDESC      => $channel{'desc'},
47
    CHANNELLANG      => $channel{'lang'},
48
    CHANNELLASTBUILD => getDate(),
47
49
48
my %image = getConf("image");
50
    IMAGETITLE       => $image{'title'},
49
$feed->param( IMAGETITLE       => $image{'title'} );
51
    IMAGEURL         => $image{'url'},
50
$feed->param( IMAGEURL         => $image{'url'} );
52
    IMAGELINK        => $image{'link'},
51
$feed->param( IMAGELINK        => $image{'link'} );
53
    IMAGEDESCRIPTION => $image{'description'},
52
$feed->param( IMAGEDESCRIPTION => $image{'description'} );
54
    IMAGEWIDTH       => $image{'width'},
53
$feed->param( IMAGEWIDTH       => $image{'width'} );
55
    IMAGEHEIGHT      => $image{'height'},
54
$feed->param( IMAGEHEIGHT      => $image{'height'} );
55
56
56
#
57
    ITEMS => getItems( $config{'query'} )
57
# handle the items
58
};
58
#
59
$feed->param( ITEMS => getItems( $config{'query'} ) );
60
59
61
open( FILE, ">$outFile" ) or die "can't open $outFile";
60
my $template_path = $config{"tmpl"};
62
print FILE $feed->output();
61
open( my $fh, "<", $template_path ) or die "cannot open $template_path : $!";
63
close FILE;
62
$feed->process( $fh, $vars, $outFile );
64
63
65
sub getDate {
64
sub getDate {
66
67
    #    my $date = localtime(timelocal(localtime));
68
    my $date = strftime( "%a, %d %b %Y %T %Z", localtime );
65
    my $date = strftime( "%a, %d %b %Y %T %Z", localtime );
69
    return $date;
66
    return $date;
70
}
67
}
Lines 80-91 sub getConf { Link Here
80
            my @line = split( /=/, $_, 2 );
77
            my @line = split( /=/, $_, 2 );
81
            unless ( $line[1] ) {
78
            unless ( $line[1] ) {
82
                $inSection = 0;
79
                $inSection = 0;
83
            } else {
80
            }
81
            else {
84
                my ( $key, $value ) = @line;
82
                my ( $key, $value ) = @line;
85
                chomp $value;
83
                chomp $value;
86
                $return{$key} = $value;
84
                $return{$key} = $value;
87
            }
85
            }
88
        } else {
86
        }
87
        else {
89
            if ( $_ eq "$section\n" ) { $inSection = 1 }
88
            if ( $_ eq "$section\n" ) { $inSection = 1 }
90
        }
89
        }
91
    }
90
    }
92
- 

Return to bug 9000