X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/bb93fccf0690344aa77f9538a508959a6de09847..8b5f2da2ea4a988a1046f242d927713470436927:/IkiWiki/Plugin/aggregate.pm diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm index 29bc6d0ce..e1baae666 100644 --- a/IkiWiki/Plugin/aggregate.pm +++ b/IkiWiki/Plugin/aggregate.pm @@ -4,7 +4,7 @@ package IkiWiki::Plugin::aggregate; use warnings; use strict; -use IkiWiki 2.00; +use IkiWiki 3.00; use HTML::Parser; use HTML::Tagset; use HTML::Entities; @@ -46,7 +46,7 @@ sub getsetup () { }, aggregateinternal => { type => "boolean", - example => 0, + example => 1, description => "enable aggregation to internal pages?", safe => 0, # enabling needs manual transition rebuild => 0, @@ -61,6 +61,10 @@ sub getsetup () { } sub checkconfig () { + if (! defined $config{aggregateinternal}) { + $config{aggregateinternal}=1; + } + if ($config{aggregate} && ! ($config{post_commit} && IkiWiki::commit_hook_enabled())) { launchaggregation(); @@ -245,6 +249,7 @@ sub preprocess (@) { $feed->{template}=$params{template} . ".tmpl"; delete $feed->{unseen}; $feed->{lastupdate}=0 unless defined $feed->{lastupdate}; + $feed->{lasttry}=$feed->{lastupdate} unless defined $feed->{lasttry}; $feed->{numposts}=0 unless defined $feed->{numposts}; $feed->{newposts}=0 unless defined $feed->{newposts}; $feed->{message}=gettext("new feed") unless defined $feed->{message}; @@ -342,7 +347,8 @@ sub savestate () { push @line, "tag=$_" foreach @{$data->{tags}}; } else { - push @line, "$field=".$data->{$field}; + push @line, "$field=".$data->{$field} + if defined $data->{$field}; } } print OUT join(" ", @line)."\n" || error("write $newfile: $!", $cleanup); @@ -390,8 +396,8 @@ sub mergestate () { # fields. foreach my $name (keys %myfeeds) { if (exists $feeds{$name}) { - foreach my $field (qw{message lastupdate numposts - newposts error}) { + foreach my $field (qw{message lastupdate lasttry + numposts newposts error}) { $feeds{$name}->{$field}=$myfeeds{$name}->{$field}; } } @@ -458,10 +464,10 @@ sub aggregate (@) { error($@) if $@; foreach my $feed (@_) { - $feed->{lastupdate}=time; + $feed->{lasttry}=time; $feed->{newposts}=0; $feed->{message}=sprintf(gettext("last checked %s"), - displaytime($feed->{lastupdate})); + displaytime($feed->{lasttry})); $feed->{error}=0; debug(sprintf(gettext("checking feed %s ..."), $feed->{name})); @@ -483,6 +489,10 @@ sub aggregate (@) { debug($feed->{message}); next; } + + # lastupdate is only set if we were able to contact the server + $feed->{lastupdate}=$feed->{lasttry}; + if ($res->status == URI::Fetch::URI_GONE()) { $feed->{message}=gettext("feed not found"); $feed->{error}=1; @@ -524,6 +534,11 @@ sub aggregate (@) { } foreach my $entry ($f->entries) { + # XML::Feed doesn't work around XML::Atom's bizarre + # API, so we will. Real unicode strings? Yes please. + # See [[bugs/Aggregated_Atom_feeds_are_double-encoded]] + local $XML::Atom::ForceUnicode = 1; + my $c=$entry->content; # atom feeds may have no content, only a summary if (! defined $c && ref $entry->summary) {