diff --git a/IkiWiki/Plugin/fortune.pm b/IkiWiki/Plugin/fortune.pm new file mode 100644 index 000000000..8e96bdbbd --- /dev/null +++ b/IkiWiki/Plugin/fortune.pm @@ -0,0 +1,25 @@ +#!/usr/bin/perl +# Include a fortune in a page +package IkiWiki::Plugin::fortune; + +use warnings; +use strict; + +sub import { #{{{ + IkiWiki::hook(type => "preprocess", id => "fortune", + call => \&preprocess); +} # }}} + +sub preprocess (@) { #{{{ + $ENV{PATH}="$ENV{PATH}:/usr/games:/usr/local/games"; + my $f = `fortune`; + + if ($?) { + return "[[fortune failed]]"; + } + else { + return "
$f\n"; + } +} # }}} + +1 diff --git a/Makefile.PL b/Makefile.PL index 58a6b29c3..641964853 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -17,7 +17,8 @@ extra_build: --exclude=/discussion --no-discussion \ --plugin=brokenlinks --plugin=pagecount \ --plugin=orphans --plugin=haiku --plugin=meta \ - --plugin=tag --plugin=polygen --plugin=pagestats + --plugin=tag --plugin=polygen --plugin=pagestats \ + --plugin=fortune ./mdwn2man ikiwiki 1 doc/usage.mdwn > ikiwiki.man ./mdwn2man ikiwiki-mass-rebuild 8 doc/ikiwiki-mass-rebuild.mdwn > ikiwiki-mass-rebuild.man diff --git a/debian/changelog b/debian/changelog index 7685f9603..15fc13483 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,7 @@ ikiwiki (1.12) unstable; urgency=low * Allow preprocessor directives to be expanded in inlined blog pages. However, to avoid inlining loops etc, don't expand inline directives in inlined pages. + * fortune plugin (trivial) -- Joey Hess