#!/usr/bin/perl -w
my
$BASE
;
BEGIN {
$BASE
=
'/var/www/cpanwiki'
;
}
use
lib
qw|../cgi-bin/lib ../cgi-bin/plugins|
;
my
@types
= (
{
type
=>
'rss'
,
version
=>
'2.0'
},
{
type
=>
'atom'
,
version
=>
'1.0'
},
);
Labyrinth::Globals::LoadSettings(
"$BASE/cgi-bin/config/settings.ini"
);
Labyrinth::Globals::DBConnect();
$settings
{perma} =
$tvars
{webpath} .
'/wiki/'
;
my
$wiki
= Labyrinth::Plugin::Wiki->new();
$wiki
->Recent();
for
my
$item
(@{
$tvars
{wikihash}{recent}}) {
my
%xml
;
$xml
{data}{
$_
} =
$item
->{
$_
}
for
(
qw(pagename createdate)
);
$xml
{data}{body} =
$item
->{comment} ||
'-- no comment added --'
;
$xml
{data}{title} =
"$item->{pagename} : Version $item->{version}"
;
$xml
{data}{pageid} =
"$item->{pagename}&version=$item->{version}"
;
$xml
{data}{permapath} =
"/wiki/$item->{pagename}&version=$item->{version}"
;
push
@{
$tvars
{xmlhash}}, \
%xml
;
}
for
my
$item
(
@types
) {
my
$rss
= Labyrinth::RSS->new(
%$item
,
perma
=>
$settings
{perma},
id
=>
'pageid'
);
my
$xml
=
$rss
->feed(@{
$tvars
{xmlhash}});
write_xml(
"rss/$item->{type}-$item->{version}.xml"
,
$xml
);
}
sub
write_xml {
my
$file
=
shift
;
my
$xml
=
shift
;
my
$target
=
"$BASE/html/$file"
;
mkpath(dirname(
$target
));
my
$fh
= IO::File->new(
$target
,
'w'
) or
die
"Cannot write to file [$target]: $!"
;
print
$fh
$xml
;
$fh
->
close
;
}