Bugzilla – Attachment 30219 Details for
Bug 9000
misc/cronjobs/rss/rss.pl uses HTP
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 9000 [1] - Update rss.pl to use Template Toolkit
SIGNED-OFF-Bug-9000-1---Update-rsspl-to-use-Templa.patch (text/plain), 6.68 KB, created by
Bernardo Gonzalez Kriegel
on 2014-07-28 16:01:12 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 9000 [1] - Update rss.pl to use Template Toolkit
Filename:
MIME Type:
Creator:
Bernardo Gonzalez Kriegel
Created:
2014-07-28 16:01:12 UTC
Size:
6.68 KB
patch
obsolete
>From f1312e27ef94705b92e34929e225f1fffdc7b207 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 28 Jul 2014 10:07:45 -0400 >Subject: [PATCH] [SIGNED-OFF] Bug 9000 [1] - Update rss.pl to use Template > Toolkit > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> > >Tested using script with sample conf files >RSS feeds generated are 'well formed' xml >Some koha-qa errors fixed in followup >--- > misc/cronjobs/rss/README | 35 +++++++++++++++--------------- > misc/cronjobs/rss/rss.pl | 53 +++++++++++++++++++++++----------------------- > 2 files changed, 43 insertions(+), 45 deletions(-) > >diff --git a/misc/cronjobs/rss/README b/misc/cronjobs/rss/README >index 896a1d9..6c4a70f 100644 >--- a/misc/cronjobs/rss/README >+++ b/misc/cronjobs/rss/README >@@ -21,7 +21,7 @@ is invoked like this (in the case of lastAcquired): > > The basic process is that rss reads the config file > (lastAcquired.conf) to determine RSS header information, the SQL query >-used to generate the results, and the HTML::Template style used to >+used to generate the results, and the Template Tookit style used to > format the output. Since you'll likely to want to create your own RSS > content, or at least modify the ones present here, let's review the > config file and the template file. >@@ -51,16 +51,15 @@ title=Koha, the worlds best Open Source Library System > url=http://www.koha-community.org/images/foo.jpg > link=http://www.koha-community.org > config >-tmpl=lastAcquired.tmpl >+tmpl=lastAcquired.tt > 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 > > > This data (and the data acquired from the query) are then used to fill > in the template. Most of the template is boilerplate and should not >-be edited. The section within the <TMPL_LOOP NAME=ITEMS> >-... </TMPL_LOOP> is the part which can be modified to create your own >-RSS content. >+be edited. The section within the [% FOREACH i IN ITEMS %] ... [% END %] >+is the part which can be modified to create your own RSS content. > > Here's the lastAcquired.tmpl file: > >@@ -72,25 +71,24 @@ Here's the lastAcquired.tmpl file: > <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> >+ <title>[% CHANNELTITLE %]</title> >+ <link>[% CHANNELLINK %]</link> >+ <description>[% CHANNELDESC %]</description> >+ <language>[% CHANNELLANG %]</language> >+ <lastBuildDate>[% CHANNELLASTBUILD %]</lastBuildDate> > > <image> >- <title><TMPL_VAR IMAGETITLE></title> >- <url><TMPL_VAR IMAGEURL></url> >- <link><TMPL_VAR IMAGELINK></link> >+ <title>[% IMAGETITLE %]</title> >+ <url>[% IMAGEURL %]</url> >+ <link>[% IMAGELINK %]</link> > </image> > >-<TMPL_LOOP NAME=ITEMS> >+[% FOREACH i IN 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> >- >+ <title>[% i.TITLE %], by [% i.AUTHOR %]</title> >+ <link>http://opac.library.org.nz/cgi-bin/koha/opac-searchresults.pl?isbn=[% i.ISBN %]</link> > </item> >-</TMPL_LOOP> >+[% END %] > > </channel> > </rss> >@@ -100,3 +98,4 @@ Originally written by Pat Eyler (pate@eylerfamily.org), suggestions, > advice, and help came from 'Content Syndication with RSS', Chris > Cormack, Mike Hansen, Steve Tonnesen and a variety of folks on #koha at > irc.katipo.co.nz. >+Updated for use with Template Toolkit by Kyle M Hall, ByWater Solutions >diff --git a/misc/cronjobs/rss/rss.pl b/misc/cronjobs/rss/rss.pl >index 1d475d7..d87e342 100755 >--- a/misc/cronjobs/rss/rss.pl >+++ b/misc/cronjobs/rss/rss.pl >@@ -8,6 +8,7 @@ > # > > # Copyright 2003 Katipo Communications >+# Copyright 2014 ByWater Solutions > # > # This file is part of Koha. > # >@@ -24,10 +25,9 @@ > # with Koha; if not, write to the Free Software Foundation, Inc., > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > >-use strict; >-use warnings; >+use Modern::Perl; > >-use HTML::Template::Pro; >+use Template; > use C4::Context; > use Time::Local; > use POSIX; >@@ -36,35 +36,32 @@ my $dbh = C4::Context->dbh; > my $file = $ARGV[0]; > my %config = getConf("config"); > my $outFile = $config{"output"}; >-my $feed = HTML::Template::Pro->new( filename => $config{"tmpl"} ); >+my $feed = Template->new(); > > 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"); >+my $vars = { >+ CHANNELTITLE => $channel{'title'}, >+ CHANNELLINK => $channel{'link'}, >+ CHANNELDESC => $channel{'desc'}, >+ CHANNELLANG => $channel{'lang'}, >+ CHANNELLASTBUILD => getDate(), > >-my %image = getConf("image"); >-$feed->param( IMAGETITLE => $image{'title'} ); >-$feed->param( IMAGEURL => $image{'url'} ); >-$feed->param( IMAGELINK => $image{'link'} ); >-$feed->param( IMAGEDESCRIPTION => $image{'description'} ); >-$feed->param( IMAGEWIDTH => $image{'width'} ); >-$feed->param( IMAGEHEIGHT => $image{'height'} ); >+ IMAGETITLE => $image{'title'}, >+ IMAGEURL => $image{'url'}, >+ IMAGELINK => $image{'link'}, >+ IMAGEDESCRIPTION => $image{'description'}, >+ IMAGEWIDTH => $image{'width'}, >+ IMAGEHEIGHT => $image{'height'}, > >-# >-# handle the items >-# >-$feed->param( ITEMS => getItems( $config{'query'} ) ); >+ ITEMS => getItems( $config{'query'} ) >+}; > >-open( FILE, ">$outFile" ) or die "can't open $outFile"; >-print FILE $feed->output(); >-close FILE; >+my $template_path = $config{"tmpl"}; >+open( my $fh, "<", $template_path ) or die "cannot open $template_path : $!"; >+$feed->process( $fh, $vars, $outFile ); > > sub getDate { >- >- # my $date = localtime(timelocal(localtime)); > my $date = strftime( "%a, %d %b %Y %T %Z", localtime ); > return $date; > } >@@ -80,12 +77,14 @@ sub getConf { > my @line = split( /=/, $_, 2 ); > unless ( $line[1] ) { > $inSection = 0; >- } else { >+ } >+ else { > my ( $key, $value ) = @line; > chomp $value; > $return{$key} = $value; > } >- } else { >+ } >+ else { > if ( $_ eq "$section\n" ) { $inSection = 1 } > } > } >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9000
:
29088
|
29127
|
29134
|
30202
|
30203
|
30204
|
30205
|
30206
|
30207
|
30219
|
30220
|
30221
|
30222
|
30223
|
30229
|
30230
|
30231
|
30232
|
30233