fix removal form display
[ikiwiki] / 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 use IkiWiki 3.00;
8
9 sub import {
10         hook(type => "getsetup", id => "fortune", call => \&getsetup);
11         hook(type => "preprocess", id => "fortune", call => \&preprocess);
12 }
13
14 sub getsetup () {
15         return
16                 plugin => {
17                         safe => 1,
18                         rebuild => undef,
19                 },
20 }
21
22 sub preprocess (@) {
23         $ENV{PATH}="$ENV{PATH}:/usr/games:/usr/local/games";
24         my $f = `fortune 2>/dev/null`;
25
26         if ($?) {
27                 error gettext("fortune failed");
28         }
29         else {
30                 return "<pre>$f</pre>\n";
31         }
32 }
33
34 1