2006-07-29 23:53:57 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# Include a fortune in a page
|
|
|
|
package IkiWiki::Plugin::fortune;
|
|
|
|
|
2006-09-10 00:50:27 +02:00
|
|
|
use IkiWiki;
|
2006-07-29 23:53:57 +02:00
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
sub import { #{{{
|
2006-09-10 00:50:27 +02:00
|
|
|
hook(type => "preprocess", id => "fortune", call => \&preprocess);
|
2006-07-29 23:53:57 +02:00
|
|
|
} # }}}
|
|
|
|
|
|
|
|
sub preprocess (@) { #{{{
|
|
|
|
$ENV{PATH}="$ENV{PATH}:/usr/games:/usr/local/games";
|
2006-11-28 19:16:04 +01:00
|
|
|
my $f = `fortune 2>/dev/null`;
|
2006-07-29 23:53:57 +02:00
|
|
|
|
|
|
|
if ($?) {
|
|
|
|
return "[[fortune failed]]";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return "<pre>$f</pre>\n";
|
|
|
|
}
|
|
|
|
} # }}}
|
|
|
|
|
|
|
|
1
|