]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/aggregate.pm
cleanup
[git.ikiwiki.info.git] / IkiWiki / Plugin / aggregate.pm
index e473fc6430819bbb19a0120d0acca4106b25edc7..59185e97ffdd43eb283fbbf2d454cbbb40b3d894 100644 (file)
@@ -8,7 +8,6 @@ use IkiWiki 3.00;
 use HTML::Parser;
 use HTML::Tagset;
 use HTML::Entities;
-use URI;
 use open qw{:utf8 :std};
 
 my %feeds;
@@ -210,6 +209,8 @@ sub needsbuild (@) {
                        markunseen($feed->{sourcepage});
                }
        }
+
+       return $needsbuild;
 }
 
 sub preprocess (@) {
@@ -359,14 +360,9 @@ sub savestate () {
 
        my $timestamp=undef;
        foreach my $feed (keys %feeds) {
-               if (defined $feeds{$feed}->{lastupdate}) {
-                       my $t=$feeds{$feed}->{lastupdate}+$feeds{$feed}->{updateinterval};
-                       if (! defined $timestamp || $timestamp > $t) {
-                               $timestamp=$t;
-                       }
-               }
-               else {
-                       $timestamp=0;
+               my $t=$feeds{$feed}->{lastupdate}+$feeds{$feed}->{updateinterval};
+               if (! defined $timestamp || $timestamp > $t) {
+                       $timestamp=$t;
                }
        }
        $newfile=~s/\.new$/time/;
@@ -647,7 +643,14 @@ sub add_page (@) {
        $guid->{md5}=$digest;
 
        # Create the page.
-       my $template=template($feed->{template}, blind_cache => 1);
+       my $template;
+       eval {
+               $template=template($feed->{template}, blind_cache => 1);
+       };
+       if ($@) {
+               print STDERR gettext("failed to process template:")." $@";
+               return;
+       }
        $template->param(title => $params{title})
                if defined $params{title} && length($params{title});
        $template->param(content => wikiescape(htmlabs($params{content},
@@ -656,7 +659,7 @@ sub add_page (@) {
        $template->param(url => $feed->{url});
        $template->param(copyright => $params{copyright})
                if defined $params{copyright} && length $params{copyright};
-       $template->param(permalink => urlabs($params{link}, $feed->{feedurl}))
+       $template->param(permalink => IkiWiki::urlabs($params{link}, $feed->{feedurl}))
                if defined $params{link};
        if (ref $feed->{tags}) {
                $template->param(tags => [map { tag => $_ }, @{$feed->{tags}}]);
@@ -684,13 +687,6 @@ sub wikiescape ($) {
        return encode_entities(shift, '\[\]');
 }
 
-sub urlabs ($$) {
-       my $url=shift;
-       my $urlbase=shift;
-
-       URI->new_abs($url, $urlbase)->as_string;
-}
-
 sub htmlabs ($$) {
        # Convert links in html from relative to absolute.
        # Note that this is a heuristic, which is not specified by the rss
@@ -716,7 +712,7 @@ sub htmlabs ($$) {
                                next unless $v_offset; # 0 v_offset means no value
                                my $v = substr($text, $v_offset, $v_len);
                                $v =~ s/^([\'\"])(.*)\1$/$2/;
-                               my $new_v=urlabs($v, $urlbase);
+                               my $new_v=IkiWiki::urlabs($v, $urlbase);
                                $new_v =~ s/\"/"/g; # since we quote with ""
                                substr($text, $v_offset, $v_len) = qq("$new_v");
                        }