X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/18b3e970ffcc0f74d68538b7094f76442a294609..60111384a9c178b03cd778c298e28953ca80177b:/IkiWiki/Plugin/postsparkline.pm diff --git a/IkiWiki/Plugin/postsparkline.pm b/IkiWiki/Plugin/postsparkline.pm index 6fc96f8b3..d2e5c2378 100644 --- a/IkiWiki/Plugin/postsparkline.pm +++ b/IkiWiki/Plugin/postsparkline.pm @@ -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,15 +50,10 @@ 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; - } - } - - @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 ($@) { @@ -69,7 +73,7 @@ sub preprocess (@) { #{{{ delete $params{color}; return IkiWiki::Plugin::sparkline::preprocess(%params, map { $_.$color => "" } reverse @data); -} # }}} +} sub perfoo ($@) { my $sub=shift;