]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Plugin/fortune.pm
* Fix the htmltidy plugin, which wasn't working due my breaking it when
[ikiwiki.git] / IkiWiki / Plugin / fortune.pm
1 #!/usr/bin/perl
2 # Include a fortune in a page
3 package IkiWiki::Plugin::fortune;
4
5 use warnings;
6 use strict;
7
8 sub import { #{{{
9         IkiWiki::hook(type => "preprocess", id => "fortune",
10                 call => \&preprocess);
11 } # }}}
12
13 sub preprocess (@) { #{{{
14         $ENV{PATH}="$ENV{PATH}:/usr/games:/usr/local/games";
15         my $f = `fortune`;
16
17         if ($?) {
18                 return "[[fortune failed]]";
19         }
20         else {
21                 return "<pre>$f</pre>\n";
22         }
23 } # }}}
24
25 1