X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/30bfe76eac0b4ee01e593a27a9fd4578d58124f6..b9f3c6d7c968f1583870d8b7afc999500bbfb605:/IkiWiki/Plugin/postsparkline.pm diff --git a/IkiWiki/Plugin/postsparkline.pm b/IkiWiki/Plugin/postsparkline.pm index 9e885741e..ba43561fb 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}) { @@ -29,14 +38,14 @@ sub preprocess (@) { #{{{ } if (! exists $params{formula}) { - return "[[postsparkline ".gettext("missing formula")."]]"; + error gettext("missing formula") } my $formula=$params{formula}; $formula=~s/[^a-zA-Z0-9]*//g; $formula=IkiWiki::possibly_foolish_untaint($formula); if (! length $formula || ! IkiWiki::Plugin::postsparkline::formula->can($formula)) { - return "[[postsparkline ".gettext("unknown formula")."]]"; + error gettext("unknown formula"); } add_depends($params{page}, $params{pages}); @@ -53,7 +62,7 @@ sub preprocess (@) { #{{{ my @data=eval qq{IkiWiki::Plugin::postsparkline::formula::$formula(\\\%params, \@list)}; if ($@) { - return "[[postsparkline error $@]]"; + error $@; } if (! @data) { @@ -69,7 +78,7 @@ sub preprocess (@) { #{{{ delete $params{color}; return IkiWiki::Plugin::sparkline::preprocess(%params, map { $_.$color => "" } reverse @data); -} # }}} +} sub perfoo ($@) { my $sub=shift;