X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/de5eb4996bbc8ab7d4263e70913de63e146d808d..864bc2d9d0507a3b3f67ab785e347e37a8eaf9fa:/IkiWiki/Plugin/postsparkline.pm?ds=inline

diff --git a/IkiWiki/Plugin/postsparkline.pm b/IkiWiki/Plugin/postsparkline.pm
index dc996ae32..1f4c065c1 100644
--- a/IkiWiki/Plugin/postsparkline.pm
+++ b/IkiWiki/Plugin/postsparkline.pm
@@ -7,9 +7,18 @@ use IkiWiki 2.00;
 
 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 (@) { #{{{
 	my %params=@_;
 
@@ -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,12 +62,12 @@ sub preprocess (@) { #{{{
 
 	my @data=eval qq{IkiWiki::Plugin::postsparkline::formula::$formula(\\\%params, \@list)};
 	if ($@) {
-		return "[[postsparkline error $@]]";
+		error $@;
 	}
 
 	if (! @data) {
 		# generate an empty graph
-		push @data, 0 foreach 1..$params{max};
+		push @data, 0 foreach 1..($params{max} / 2);
 	}
 
 	my $color=exists $params{color} ? "($params{color})" : "";