]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - ikiwiki
web commit by joey
[git.ikiwiki.info.git] / ikiwiki
diff --git a/ikiwiki b/ikiwiki
index 2087b1bafec4f6d2020d11f15e0414a02d31c022..8367e9118df42901e0f18e3c0ecf4adccc24eff3 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 %inlinepages};
+            %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}}) {
+               my $mod="IkiWiki::Plugin::".possibly_foolish_untaint($plugin);
+               eval qq{use $mod};
+               if ($@) {
+                       error("Failed to load plugin $mod: $@");
+               }
+       }
 } #}}}
 
 sub error ($) { #{{{
@@ -399,8 +411,8 @@ sub loadindex () { #{{{
                        $oldpagemtime{$page}=$items{mtime}[0];
                        $oldlinks{$page}=[@{$items{link}}];
                        $links{$page}=[@{$items{link}}];
-                       $inlinepages{$page}=join(" ", @{$items{inlinepage}})
-                               if exists $items{inlinepage};
+                       $depends{$page}=join(" ", @{$items{depends}})
+                               if exists $items{depends};
                        $renderedfiles{$page}=$items{dest}[0];
                }
                $pagectime{$page}=$items{ctime}[0];
@@ -421,8 +433,8 @@ sub saveindex () { #{{{
                        "src=$pagesources{$page} ".
                        "dest=$renderedfiles{$page}";
                $line.=" link=$_" foreach @{$links{$page}};
-               if (exists $inlinepages{$page}) {
-                       $line.=" inlinepage=$_" foreach split " ", $inlinepages{$page};
+               if (exists $depends{$page}) {
+                       $line.=" depends=$_" foreach split " ", $depends{$page};
                }
                print OUT $line."\n";
        }
@@ -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();
        
@@ -499,9 +519,9 @@ sub main () { #{{{
                loadindex();
                require IkiWiki::Render;
                rcs_update();
-               rcs_notify() if $config{notify};
                rcs_getctime() if $config{getctime};
                refresh();
+               rcs_notify() if $config{notify};
                saveindex();
        }
 } #}}}