* fortune plugin (trivial)
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sat, 29 Jul 2006 21:53:57 +0000 (21:53 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sat, 29 Jul 2006 21:53:57 +0000 (21:53 +0000)
IkiWiki/Plugin/fortune.pm [new file with mode: 0644]
Makefile.PL
debian/changelog
doc/plugins/fortune.mdwn [new file with mode: 0644]

diff --git a/IkiWiki/Plugin/fortune.pm b/IkiWiki/Plugin/fortune.pm
new file mode 100644 (file)
index 0000000..8e96bdb
--- /dev/null
@@ -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
index 58a6b29c3831776a8052c72691225925fba70217..641964853ad782a911c8d871fae8ddfefd80748a 100755 (executable)
@@ -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
                
index 7685f9603bfc2d76d5e161fa24cdfc69ea33d53a..15fc13483d5ea0a965f90e99549deb288e0bfbab 100644 (file)
@@ -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 (file)
index 0000000..3f740e4
--- /dev/null
@@ -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 ]]