2014-06-24 16:13:59 +02:00
|
|
|
|
# Copyright (C) 2004–2014 Alex Schroeder <alex@gnu.org>
|
2004-10-10 14:32:41 +00:00
|
|
|
|
#
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2008-09-21 23:23:01 +00:00
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2004-10-10 14:32:41 +00:00
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
#
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
#
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2008-09-21 23:23:01 +00:00
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-10-10 14:32:41 +00:00
|
|
|
|
|
2014-08-21 22:23:23 +02:00
|
|
|
|
AddModuleDescription('journal-rss.pl', 'Journal RSS Extension');
|
2004-10-10 14:32:41 +00:00
|
|
|
|
|
|
|
|
|
|
$Action{journal} = \&DoJournalRss;
|
|
|
|
|
|
|
|
|
|
|
|
# Currently RSS works like RecentChanges, which is not what bloggers
|
|
|
|
|
|
# expect. Produce a RSS feed that mimicks exactly how the journal tag
|
|
|
|
|
|
# works.
|
|
|
|
|
|
|
|
|
|
|
|
sub DoJournalRss {
|
2004-10-10 15:06:39 +00:00
|
|
|
|
return if $CollectingJournal; # avoid infinite loops
|
|
|
|
|
|
local $CollectingJournal = 1;
|
2008-09-21 22:07:01 +00:00
|
|
|
|
# Fake the result of GetRcLines()
|
|
|
|
|
|
local *GetRcLines = *JournalRssGetRcLines;
|
|
|
|
|
|
print GetHttpHeader('application/xml') . GetRcRss();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub JournalRssGetRcLines {
|
2004-10-10 15:39:16 +00:00
|
|
|
|
my $num = GetParam('rsslimit', 10);
|
|
|
|
|
|
my $match = GetParam('match', '^\d\d\d\d-\d\d-\d\d');
|
2007-09-14 21:18:58 +00:00
|
|
|
|
my $search = GetParam('search', '');
|
2004-10-10 15:39:16 +00:00
|
|
|
|
my $reverse = GetParam('reverse', 0);
|
2014-06-24 16:13:59 +02:00
|
|
|
|
my $monthly = GetParam('monthly', 0);
|
2008-09-21 22:07:01 +00:00
|
|
|
|
my @pages = sort JournalSort (grep(/$match/, $search ? SearchTitleAndBody($search) : AllPagesList()));
|
2014-06-24 16:13:59 +02:00
|
|
|
|
if ($monthly and not $match) {
|
|
|
|
|
|
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime();
|
|
|
|
|
|
$match = '^' . sprintf("%04d-%02d", $year+1900, $mon+1) . '-\d\d';
|
|
|
|
|
|
}
|
2004-10-10 15:39:16 +00:00
|
|
|
|
if ($reverse) {
|
2004-10-10 15:06:39 +00:00
|
|
|
|
@pages = reverse @pages;
|
|
|
|
|
|
}
|
2008-09-21 22:07:01 +00:00
|
|
|
|
# FIXME: Missing 'future' and 'past' keywords.
|
|
|
|
|
|
# FIXME: Do we need 'offset'? I don't think so.
|
|
|
|
|
|
my @result = ();
|
2004-10-10 15:06:39 +00:00
|
|
|
|
foreach my $id (@pages) {
|
|
|
|
|
|
# Now save information required for saving the cache of the current page.
|
|
|
|
|
|
local %Page;
|
2006-12-21 21:40:19 +00:00
|
|
|
|
local $OpenPageName = '';
|
2004-10-10 15:06:39 +00:00
|
|
|
|
OpenPage($id);
|
2009-03-07 16:05:34 +00:00
|
|
|
|
# If this is a minor edit, ignore it. Load the last major revision
|
|
|
|
|
|
# instead, if you can.
|
|
|
|
|
|
if ($Page{minor}) {
|
|
|
|
|
|
# Perhaps the old kept revision is gone due to $KeepMajor=0 or
|
|
|
|
|
|
# admin.pl or because a page was created as a minor change and
|
|
|
|
|
|
# never edited. Reading kept revisions in this case results in
|
|
|
|
|
|
# an error.
|
|
|
|
|
|
eval {
|
|
|
|
|
|
%Page = GetKeptRevision($Page{lastmajor});
|
2010-12-04 15:13:53 +00:00
|
|
|
|
};
|
|
|
|
|
|
next if $@;
|
2009-03-07 16:05:34 +00:00
|
|
|
|
}
|
2010-12-04 15:13:53 +00:00
|
|
|
|
next if $Page{text} =~ /^\s*$/; # only whitespace is also to be deleted
|
|
|
|
|
|
next if $DeletedPage && substr($Page{text}, 0, length($DeletedPage))
|
|
|
|
|
|
eq $DeletedPage; # no regexp
|
2008-09-21 22:54:28 +00:00
|
|
|
|
# Generate artifical rows in the list to pass to GetRcRss. We need
|
|
|
|
|
|
# to open every single page, because the meta-data ordinarily
|
|
|
|
|
|
# available in the rc.log file is not available to us. This is why
|
|
|
|
|
|
# we observe the rsslimit parameter. Without it, we would have to
|
|
|
|
|
|
# open *all* date pages.
|
2008-09-21 22:07:01 +00:00
|
|
|
|
my @languages = split(/,/, $languages);
|
2008-09-21 22:15:14 +00:00
|
|
|
|
push (@result, [$Page{ts}, $id, $Page{minor}, $Page{summary}, $Page{host},
|
|
|
|
|
|
$Page{username}, $Page{revision}, \@languages,
|
|
|
|
|
|
GetCluster($Page{text})]);
|
2008-09-21 22:54:28 +00:00
|
|
|
|
last if $num ne 'all' and $#result + 1 >= $num;
|
2004-10-10 15:06:39 +00:00
|
|
|
|
}
|
2008-09-21 22:07:01 +00:00
|
|
|
|
return @result;
|
2004-10-10 14:32:41 +00:00
|
|
|
|
}
|
2009-08-31 08:32:10 +00:00
|
|
|
|
|
|
|
|
|
|
# Prevent near links from being printed as a result of the search.
|
|
|
|
|
|
push(@MyInitVariables, sub {
|
|
|
|
|
|
$NearLinksException{journal} = 1;
|
|
|
|
|
|
});
|