]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/postsparkline.pm
rework dependency types code
[ikiwiki.git] / IkiWiki / Plugin / postsparkline.pm
index 1f4c065c1e1f09ad6ba9d395ecd3c002a1bb0a25..3205958d40dcb5f8b0a510b58d14fba95423c1ff 100644 (file)
@@ -3,23 +3,23 @@ package IkiWiki::Plugin::postsparkline;
 
 use warnings;
 use strict;
 
 use warnings;
 use strict;
-use IkiWiki 2.00;
+use IkiWiki 3.00;
 
 
-sub import { #{{{
+sub import {
        IkiWiki::loadplugin('sparkline');
        hook(type => "getsetup", id => "postsparkline", call => \&getsetup);
        hook(type => "preprocess", id => "postsparkline", call => \&preprocess);
        IkiWiki::loadplugin('sparkline');
        hook(type => "getsetup", id => "postsparkline", call => \&getsetup);
        hook(type => "preprocess", id => "postsparkline", call => \&preprocess);
-} # }}}
+}
 
 
-sub getsetup () { #{{{
+sub getsetup () {
        return 
                plugin => {
                        safe => 1,
                        rebuild => undef,
                },
        return 
                plugin => {
                        safe => 1,
                        rebuild => undef,
                },
-} #}}}
+}
 
 
-sub preprocess (@) { #{{{
+sub preprocess (@) {
        my %params=@_;
 
        if (! exists $params{max}) {
        my %params=@_;
 
        if (! exists $params{max}) {
@@ -48,17 +48,12 @@ sub preprocess (@) { #{{{
                error gettext("unknown formula");
        }
 
                error gettext("unknown formula");
        }
 
-       add_depends($params{page}, $params{pages});
+       add_depends($params{page}, $params{pages}, presence => 1);
 
 
-       my @list;
-       foreach my $page (keys %pagesources) {
-               next if $page eq $params{page};
-               if (pagespec_match($page, $params{pages}, location => $params{page})) {
-                       push @list, $page;
-               }
-       }
-       
-       @list = sort { $params{timehash}->{$b} <=> $params{timehash}->{$a} } @list;
+       my @list=sort { $params{timehash}->{$b} <=> $params{timehash}->{$a} } 
+               pagespec_match_list(
+                       [ grep { $_ ne $params{page} } keys %pagesources],
+                       $params{pages}, location => $params{page});
 
        my @data=eval qq{IkiWiki::Plugin::postsparkline::formula::$formula(\\\%params, \@list)};
        if ($@) {
 
        my @data=eval qq{IkiWiki::Plugin::postsparkline::formula::$formula(\\\%params, \@list)};
        if ($@) {
@@ -78,7 +73,7 @@ sub preprocess (@) { #{{{
        delete $params{color};
        return IkiWiki::Plugin::sparkline::preprocess(%params, 
                map { $_.$color => "" } reverse @data);
        delete $params{color};
        return IkiWiki::Plugin::sparkline::preprocess(%params, 
                map { $_.$color => "" } reverse @data);
-} # }}}
+}
 
 sub perfoo ($@) {
        my $sub=shift;
 
 sub perfoo ($@) {
        my $sub=shift;