-
Notifications
You must be signed in to change notification settings - Fork 0
/
kwikirss.cgi
60 lines (41 loc) · 1.42 KB
/
kwikirss.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl -w
# RSS generator from Kwiki RecentChanges
use lib '/home/ben/web/lib/perl';
use strict;
use XML::RSS;
use CGI qw(:standard);
use LWP::Simple 'get';
use HTML::TokeParser;
use Date::Manip;
my $tag;
my $cgi = CGI::new();
my $url = $cgi->param('url');
my $recent_changes_file = get("$url/csp?RecentChanges");
my $stream = HTML::TokeParser->new( \$recent_changes_file );
my $rss = new XML::RSS(version => '1.0');
$rss -> channel(title => "Recent Changes file for $url",
link => "$url/csp?RecentChanges",
description => "The latest changed pages on the EuroFoo wiki",
);
$stream->get_tag("table");
$stream->get_tag("/tr");
while ($tag = $stream->get_tag('tr')) {
$stream->get_tag('td');
$stream->get_tag('a');
my $changed_page = $stream->get_text();
$stream->get_tag('td');
my $changed_by = $stream->get_text();
$stream->get_tag('td');
my $edit_time = $stream->get_text();
$edit_time =~ s/ 2004 GMT/+00:00/g;
my $parsed_date = ParseDate($edit_time);
my $w3cdtf_date = UnixDate($parsed_date, "%Y-%m-%dT%H:%M:%S%z");
$rss -> add_item( title => "$changed_page",
link => "$url/null?$changed_page",
description => "Edited at $edit_time by $changed_by",
dc => { creator => "$changed_by",
date => "$w3cdtf_date",},
);
}
print header('application/xml+rss');
print $rss->as_string;