| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: RecentChangesRSS.pm,v 1.21 2005/11/06 23:47:58 peregrin Exp $ |
|
2
|
|
|
|
|
|
|
package Kwiki::RecentChangesRSS; |
|
3
|
1
|
|
|
1
|
|
39602
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
33
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
25
|
|
|
5
|
1
|
|
|
1
|
|
4093
|
use Kwiki::Plugin '-Base'; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Kwiki::Installer '-base'; |
|
7
|
|
|
|
|
|
|
use POSIX qw(strftime); |
|
8
|
|
|
|
|
|
|
use Time::Local; |
|
9
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
const class_id => 'RecentChangesRSS'; |
|
12
|
|
|
|
|
|
|
const class_title => 'RecentChangesRSS'; |
|
13
|
|
|
|
|
|
|
const screen_template => 'rss_screen.xml'; |
|
14
|
|
|
|
|
|
|
const config_file => 'rss.yaml'; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub register { |
|
17
|
|
|
|
|
|
|
my $registry = shift; |
|
18
|
|
|
|
|
|
|
$registry->add( action => 'RecentChangesRSS' ); |
|
19
|
|
|
|
|
|
|
$registry->add( |
|
20
|
|
|
|
|
|
|
toolbar => 'rss_button', |
|
21
|
|
|
|
|
|
|
template => 'rss_button.html', |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub RecentChangesRSS { |
|
26
|
|
|
|
|
|
|
use XML::RSS; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $display_the_page = $self->config->rss_display_page; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my %channel_info = ( |
|
31
|
|
|
|
|
|
|
link => $self->config->rss_link, |
|
32
|
|
|
|
|
|
|
copyright => $self->config->rss_copyright, |
|
33
|
|
|
|
|
|
|
language => $self->config->rss_language, |
|
34
|
|
|
|
|
|
|
description => $self->config->rss_description, |
|
35
|
|
|
|
|
|
|
title => $self->config->rss_title, |
|
36
|
|
|
|
|
|
|
docs => $self->config->rss_docs, |
|
37
|
|
|
|
|
|
|
generator => $self->config->rss_generator, |
|
38
|
|
|
|
|
|
|
managingEditor => $self->config->rss_managingEditor, |
|
39
|
|
|
|
|
|
|
webMaster => $self->config->rss_webMaster, |
|
40
|
|
|
|
|
|
|
category => $self->config->rss_category, |
|
41
|
|
|
|
|
|
|
image => $self->config->rss_image, |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
my $rss = new XML::RSS( version => '2.0' ); |
|
44
|
|
|
|
|
|
|
while ( my ( $key, $value ) = each %channel_info ) { |
|
45
|
|
|
|
|
|
|
$rss->channel( $key => $value ); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $depth = $self->config->rss_depth; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $pages; |
|
51
|
|
|
|
|
|
|
@$pages = sort { $b->modified_time <=> $a->modified_time; } |
|
52
|
|
|
|
|
|
|
$self->pages->all_since( $depth * 1440 ); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$ENV{SERVER_PROTOCOL} =~ m!^(\w+)/!; |
|
55
|
|
|
|
|
|
|
my $protocol = $1; |
|
56
|
|
|
|
|
|
|
foreach my $page (@$pages) { |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# |
|
59
|
|
|
|
|
|
|
# Because we are using RSS 2.0, we are forced to put the author/creator in |
|
60
|
|
|
|
|
|
|
# either the title or description. Putting the author/creator in |
|
61
|
|
|
|
|
|
|
# is not valid RSS 2.0 because it must include an email address, which we |
|
62
|
|
|
|
|
|
|
# currently don't have for each user. Perhaps future versions of Kwiki |
|
63
|
|
|
|
|
|
|
# will force users to have an email address. |
|
64
|
|
|
|
|
|
|
# Note: RSS 1.0 does not have this restriction -- it can use . |
|
65
|
|
|
|
|
|
|
# |
|
66
|
|
|
|
|
|
|
my ( $title, $description ); |
|
67
|
|
|
|
|
|
|
if ($display_the_page) { |
|
68
|
|
|
|
|
|
|
$title = $page->title |
|
69
|
|
|
|
|
|
|
. " (last edited by " |
|
70
|
|
|
|
|
|
|
. $page->metadata->edit_by . ")"; |
|
71
|
|
|
|
|
|
|
$description = 'to_html . ']]>',; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
else { |
|
74
|
|
|
|
|
|
|
$title = $page->title; |
|
75
|
|
|
|
|
|
|
$description = "Last edited by " . $page->metadata->edit_by; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$rss->add_item( |
|
79
|
|
|
|
|
|
|
title => $title, |
|
80
|
|
|
|
|
|
|
description => $description, |
|
81
|
|
|
|
|
|
|
link => $self->config->rss_link . '?' . $page->uri, |
|
82
|
|
|
|
|
|
|
pubDate => strftime( |
|
83
|
|
|
|
|
|
|
"%a, %d %b %Y %T %Z", |
|
84
|
|
|
|
|
|
|
localtime( $page->modified_time ) |
|
85
|
|
|
|
|
|
|
), |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# |
|
90
|
|
|
|
|
|
|
# lastBuildDate is the time the content last changed, therefore the time of |
|
91
|
|
|
|
|
|
|
# the latest wiki page... |
|
92
|
|
|
|
|
|
|
# However $@pages is the array of pages since $depth * 1440 and so will be |
|
93
|
|
|
|
|
|
|
# undefined if no page has changes since $depth * 1440. Otherwise we skip |
|
94
|
|
|
|
|
|
|
# it. |
|
95
|
|
|
|
|
|
|
$rss->channel( |
|
96
|
|
|
|
|
|
|
lastBuildDate => strftime( |
|
97
|
|
|
|
|
|
|
"%a, %d %b %Y %T %Z", |
|
98
|
|
|
|
|
|
|
localtime( $pages->[0]->modified_time ) |
|
99
|
|
|
|
|
|
|
) |
|
100
|
|
|
|
|
|
|
) |
|
101
|
|
|
|
|
|
|
if $pages->[0]; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# Set the correct Content-Type header |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$self->hub->headers->content_type('application/xml'); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$self->render_screen( |
|
108
|
|
|
|
|
|
|
xml => $rss->as_string, |
|
109
|
|
|
|
|
|
|
screen_title => "Changes in the last $depth " . $depth == 1 |
|
110
|
|
|
|
|
|
|
? "day" |
|
111
|
|
|
|
|
|
|
: "days", |
|
112
|
|
|
|
|
|
|
); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__DATA__ |