]> git.donarmstrong.com Git - ikiwiki_plugins.git/commitdiff
add getsetup hook
authorDon Armstrong <don@donarmstrong.com>
Wed, 21 Mar 2012 17:31:35 +0000 (10:31 -0700)
committerDon Armstrong <don@donarmstrong.com>
Wed, 21 Mar 2012 17:31:35 +0000 (10:31 -0700)
remove preprocess scan hook; start R during process if needed

sweavealike.pm

index 2989c83e2bc131accf5fc748fbfbd4d35a51377c..ec6660c09e77e4d26dbb32b3129b8db073aacbc7 100644 (file)
@@ -32,23 +32,29 @@ use IkiWiki '3.00';
 
 my $id = "sweavealike";
 sub import {
+    hook(type => "getsetup", id => $id, call => \&getsetup);
     hook(type => "preprocess", id => $id, call => \&preprocess);
-    hook(type => "preprocess", id => $id, call => \&preprocess_scan, scan => 1);
     hook(type => "htmlize", id => $id, call => \&htmlize);
     hook(type => "savestate", id => $id, call => \&savestate);
 }
 
-sub preprocess_scan {
-    my %param = @_;
-    # start the R process here for this page
-    if (not defined $pagestate{$param{page}}{$id}{R}) {
-       $pagestate{$param{page}}{$id}{R} = Statistics::R->new(shared => 1) or error("Unable to create an R process");
-    }
+sub getsetup {
+    return(plugin => {safe => 1,
+                     rebuild => 1,
+                     section => "misc",
+                     link => "http://git.donarmstrong.com/?p=ikiwiki_plugins.git;a=blob;f=sweavealike.pm;hb=HEAD",
+                     description => "sweavealike plugin",
+                    },
+         );
 }
 
 sub preprocess {
     my %param = @_;
 
+    if (not defined $pagestate{$param{page}}{$id}{R}) {
+       $pagestate{$param{page}}{$id}{R} = Statistics::R->new(shared => 1)
+           or error("Unable to create an R process");
+    }
     # we currently don't bother to support anything but outputing the
     # entire segment of code and its R output