]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/postsparkline.pm
pagespec_match_list added and used in most appropriate places
[ikiwiki.git] / IkiWiki / Plugin / postsparkline.pm
index 6fc96f8b343cbca8eeeb893c41e2569a962d915c..c2ebbc5eb1da5f9e6daf6fcb704f48ebd2fe6dbf 100644 (file)
@@ -3,14 +3,23 @@ package IkiWiki::Plugin::postsparkline;
 
 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);
-} # }}}
+}
+
+sub getsetup () {
+       return 
+               plugin => {
+                       safe => 1,
+                       rebuild => undef,
+               },
+}
 
-sub preprocess (@) { #{{{
+sub preprocess (@) {
        my %params=@_;
 
        if (! exists $params{max}) {
@@ -41,13 +50,9 @@ sub preprocess (@) { #{{{
 
        add_depends($params{page}, $params{pages});
 
-       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;
-               }
-       }
+       my @list=pagespec_match_list(
+               [ grep { $_ ne $params{page} } keys %pagesources],
+               $params{pages}, location => $params{page});
        
        @list = sort { $params{timehash}->{$b} <=> $params{timehash}->{$a} } @list;
 
@@ -69,7 +74,7 @@ sub preprocess (@) { #{{{
        delete $params{color};
        return IkiWiki::Plugin::sparkline::preprocess(%params, 
                map { $_.$color => "" } reverse @data);
-} # }}}
+}
 
 sub perfoo ($@) {
        my $sub=shift;