summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-11-01 05:41:37 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-11-01 05:41:37 +0000
commit5a82103526ab32e018cd999bb6a53d9e097c83a8 (patch)
tree37a9177d56469c3f00f61dfaed560bc0e24fb2c2 /IkiWiki/Plugin
parent5a9064dea8de666912fc72bfac75f0275a25e8d6 (diff)
* Implemented expiry options for aggregate plugin.
* Use precalculated backlinks info when determining if files need an update due to a page they link to being added/removed. Mostly significant if there are lots of pages. * Remove duplicate link info when saving index. In some cases it could pile up rather badly. (Probably not the best way to deal with this problem.)
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/aggregate.pm35
1 files changed, 33 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm
index 2e1ab66e6..973f7a4ca 100644
--- a/IkiWiki/Plugin/aggregate.pm
+++ b/IkiWiki/Plugin/aggregate.pm
@@ -34,6 +34,7 @@ sub checkconfig () { #{{{
if ($config{aggregate}) {
IkiWiki::loadindex();
aggregate();
+ expire();
savestate();
}
IkiWiki::unlockwiki();
@@ -79,6 +80,7 @@ sub preprocess (@) { #{{{
$feed->{expireage}=defined $params{expireage} ? $params{expireage} : 0;
$feed->{expirecount}=defined $params{expirecount} ? $params{expirecount} : 0;
delete $feed->{remove};
+ delete $feed->{expired};
$feed->{lastupdate}=0 unless defined $feed->{lastupdate};
$feed->{numposts}=0 unless defined $feed->{numposts};
$feed->{newposts}=0 unless defined $feed->{newposts};
@@ -164,6 +166,11 @@ sub savestate () { #{{{
}
next;
}
+ elsif ($data->{expired} && exists $data->{page}) {
+ unlink pagefile($data->{page});
+ delete $data->{page};
+ delete $data->{md5};
+ }
my @line;
foreach my $field (keys %$data) {
@@ -183,6 +190,32 @@ sub savestate () { #{{{
close OUT;
} #}}}
+sub expire () { #{{{
+ foreach my $feed (values %feeds) {
+ next unless $feed->{expireage} || $feed->{expirecount};
+ my $count=0;
+ foreach my $item (sort { $IkiWiki::pagectime{$b->{page}} <=> $IkiWiki::pagectime{$a->{page}} }
+ grep { exists $_->{page} && $_->{feed} eq $feed->{name} && $IkiWiki::pagectime{$_->{page}} }
+ values %guids) {
+ if ($feed->{expireage}) {
+ my $days_old = (time - $IkiWiki::pagectime{$item->{page}}) / 60 / 60 / 24;
+ if ($days_old > $feed->{expireage}) {
+ debug("expiring ".$item->{page}." ($days_old days old)");
+ $item->{expired}=1;
+ }
+ }
+ elsif ($feed->{expirecount} &&
+ $count >= $feed->{expirecount}) {
+ debug("expiring ".$item->{page});
+ $item->{expired}=1;
+ }
+ else {
+ $count++;
+ }
+ }
+ }
+} #}}}
+
sub aggregate () { #{{{
eval q{use XML::Feed};
die $@ if $@;
@@ -237,8 +270,6 @@ sub aggregate () { #{{{
displaytime($feed->{lastupdate});
$feed->{error}=0;
}
-
- # TODO: expiry
} #}}}
sub add_page (@) { #{{{