aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/fortune.pm25
-rwxr-xr-xMakefile.PL3
-rw-r--r--debian/changelog1
-rw-r--r--doc/plugins/fortune.mdwn12
4 files changed, 40 insertions, 1 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
diff --git a/Makefile.PL b/Makefile.PL
index 58a6b29c3..641964853 100755
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -17,7 +17,8 @@ extra_build:
--exclude=/discussion --no-discussion \
--plugin=brokenlinks --plugin=pagecount \
--plugin=orphans --plugin=haiku --plugin=meta \
- --plugin=tag --plugin=polygen --plugin=pagestats
+ --plugin=tag --plugin=polygen --plugin=pagestats \
+ --plugin=fortune
./mdwn2man ikiwiki 1 doc/usage.mdwn > ikiwiki.man
./mdwn2man ikiwiki-mass-rebuild 8 doc/ikiwiki-mass-rebuild.mdwn > ikiwiki-mass-rebuild.man
diff --git a/debian/changelog b/debian/changelog
index 7685f9603..15fc13483 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -24,6 +24,7 @@ ikiwiki (1.12) unstable; urgency=low
* Allow preprocessor directives to be expanded in inlined blog pages.
However, to avoid inlining loops etc, don't expand inline directives in
inlined pages.
+ * fortune plugin (trivial)
-- Joey Hess <joeyh@debian.org> Sat, 29 Jul 2006 17:12:56 -0400
diff --git a/doc/plugins/fortune.mdwn b/doc/plugins/fortune.mdwn
new file mode 100644
index 000000000..3f740e47a
--- /dev/null
+++ b/doc/plugins/fortune.mdwn
@@ -0,0 +1,12 @@
+This just uses the `fortune` program to insert a fortune into the page.
+Usage:
+
+ \[[fortune ]]
+
+This plugin is included in ikiwiki, but not enabled by default.
+
+If this plugin is enabled, here's a fortune for you:
+
+----
+
+[[fortune ]]