From d9633de2ce0fe0624348486d453f278aaf9ca61f Mon Sep 17 00:00:00 2001 From: joey Date: Sat, 29 Jul 2006 21:53:57 +0000 Subject: * fortune plugin (trivial) --- IkiWiki/Plugin/fortune.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 IkiWiki/Plugin/fortune.pm (limited to 'IkiWiki/Plugin') 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 -- cgit v1.2.3