]> sipb.mit.edu Git - ikiwiki.git/blobdiff - ikiwiki
* Added plugin system, currently only supporting for PreProcessorDirectives.
[ikiwiki.git] / ikiwiki
diff --git a/ikiwiki b/ikiwiki
index dfb484f6402cc15fba20f577d6be57e57a9dd7fa..6c42a7e5d8037f173e6a3660e1475f614a29618f 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -9,7 +9,7 @@ use HTML::Template;
 use lib '.'; # For use without installation, removed by Makefile.
 
 use vars qw{%config %links %oldlinks %oldpagemtime %pagectime
-            %renderedfiles %pagesources %depends};
+            %renderedfiles %pagesources %depends %plugins};
 
 sub usage () { #{{{
        die "usage: ikiwiki [options] source dest\n";
@@ -20,7 +20,7 @@ sub getconfig () { #{{{
                %config=(
                        wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$|\.rss$)},
                        wiki_link_regexp => qr/\[\[(?:([^\s\]\|]+)\|)?([^\s\]]+)\]\]/,
-                       wiki_processor_regexp => qr/\[\[(\w+)\s+([^\]]+)\]\]/,
+                       wiki_processor_regexp => qr/\[\[(\w+)\s+([^\]]*)\]\]/,
                        wiki_file_regexp => qr/(^[-[:alnum:]_.:\/+]+$)/,
                        verbose => 0,
                        wikiname => "wiki",
@@ -50,6 +50,7 @@ sub getconfig () { #{{{
                        setup => undef,
                        adminuser => undef,
                        adminemail => undef,
+                       plugin => [qw{inline}],
                );
 
                eval q{use Getopt::Long};
@@ -90,6 +91,9 @@ sub getconfig () { #{{{
                        "wrapper:s" => sub {
                                $config{wrapper}=$_[1] ? $_[1] : "ikiwiki-wrap"
                        },
+                       "plugin=s@" => sub {
+                               push @{$config{plugin}}, $_[1];
+                       }
                ) || usage();
 
                if (! $config{setup}) {
@@ -129,6 +133,14 @@ sub checkconfig () { #{{{
                require IkiWiki::Rcs::Stub;
                $config{rcs}=0;
        }
+
+       foreach my $plugin (@{$config{plugin}}) {
+               $plugin="IkiWiki::Plugin::".possibly_foolish_untaint($plugin);
+               eval qq{use $plugin};
+               if ($@) {
+                       error("Failed to load plugin $plugin: $@");
+               }
+       }
 } #}}}
 
 sub error ($) { #{{{
@@ -476,6 +488,14 @@ sub globlist_match ($$) { #{{{
        return 0;
 } #}}}
 
+sub register_plugin ($$$) { # {{{
+       my $type=shift;
+       my $command=shift;
+       my $function=shift;
+       
+       $plugins{$type}{$command}=$function;
+} # }}}
+
 sub main () { #{{{
        getconfig();