summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/fortune.pm25
1 files changed, 25 insertions, 0 deletions
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 "<pre>$f</pre>\n";
+ }
+} # }}}
+
+1