X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/39195de96e6f705e4a5741254d6d01d14127005c..766311f45b4351488d7dad519a6471094a58da16:/IkiWiki/Plugin/polygen.pm diff --git a/IkiWiki/Plugin/polygen.pm b/IkiWiki/Plugin/polygen.pm index fa564aa86..8ce62b754 100644 --- a/IkiWiki/Plugin/polygen.pm +++ b/IkiWiki/Plugin/polygen.pm @@ -7,26 +7,28 @@ package IkiWiki::Plugin::polygen; use warnings; use strict; -use IkiWiki 2.00; +use IkiWiki 3.00; use File::Find; -sub import { #{{{ +sub import { hook(type => "getsetup", id => "polygen", call => \&getsetup); hook(type => "preprocess", id => "polygen", call => \&preprocess); -} # }}} +} -sub getsetup () { #{{{ +sub getsetup () { return plugin => { safe => 1, rebuild => undef, + section => "widget", }, -} #}}} +} -sub preprocess (@) { #{{{ +sub preprocess (@) { my %params=@_; my $grammar = ($params{grammar} or 'polygen'); my $symbol = ($params{symbol} or undef); + my $options = ($config{deterministic} ? '-seed 42' : ''); # Sanitize parameters $grammar =~ IkiWiki::basename($grammar); @@ -50,10 +52,10 @@ sub preprocess (@) { #{{{ my $res; if (defined $symbol) { - $res = `polygen -S $symbol $grmfile 2>/dev/null`; + $res = `polygen -S $symbol $options $grmfile 2>/dev/null`; } else { - $res = `polygen $grmfile 2>/dev/null`; + $res = `polygen $options $grmfile 2>/dev/null`; } if ($?) { @@ -64,6 +66,6 @@ sub preprocess (@) { #{{{ # markdown text $res =~ s/\s*$//; return $res; -} # }}} +} 1