]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Allow several extra library and plugin directories (libdir option)
authorLouis <spalax@gresille.org>
Sat, 6 Dec 2014 17:32:02 +0000 (18:32 +0100)
committerLouis <spalax@gresille.org>
Sat, 6 Dec 2014 17:32:02 +0000 (18:32 +0100)
IkiWiki.pm
doc/plugins/install.mdwn

index 1043ef4024ba5994d773b524103c46baad50b084..73fedb0a64598de0cd922117a3ac6ab7b0be16bb 100644 (file)
@@ -361,7 +361,7 @@ sub getsetup () {
                type => "string",
                default => "",
                example => "$ENV{HOME}/.ikiwiki/",
                type => "string",
                default => "",
                example => "$ENV{HOME}/.ikiwiki/",
-               description => "extra library and plugin directory",
+               description => "extra library and plugin directorys. Can be either a string (for backward compatibility) or a list of strings.",
                advanced => 1,
                safe => 0, # directory
                rebuild => 0,
                advanced => 1,
                safe => 0, # directory
                rebuild => 0,
@@ -551,6 +551,17 @@ sub getsetup () {
        },
 }
 
        },
 }
 
+sub getlibdirs () {
+       if (! ref $config{libdir}) {
+               if (length $config{libdir}) {
+                       return [$config{libdir}];
+               } else {
+                       return [];
+               }
+       }
+       return $config{libdir};
+}
+
 sub defaultconfig () {
        my %s=getsetup();
        my @ret;
 sub defaultconfig () {
        my %s=getsetup();
        my @ret;
@@ -693,14 +704,14 @@ sub checkconfig () {
 sub listplugins () {
        my %ret;
 
 sub listplugins () {
        my %ret;
 
-       foreach my $dir (@INC, $config{libdir}) {
+       foreach my $dir (@INC, @{getlibdirs()}) {
                next unless defined $dir && length $dir;
                foreach my $file (glob("$dir/IkiWiki/Plugin/*.pm")) {
                        my ($plugin)=$file=~/.*\/(.*)\.pm$/;
                        $ret{$plugin}=1;
                }
        }
                next unless defined $dir && length $dir;
                foreach my $file (glob("$dir/IkiWiki/Plugin/*.pm")) {
                        my ($plugin)=$file=~/.*\/(.*)\.pm$/;
                        $ret{$plugin}=1;
                }
        }
-       foreach my $dir ($config{libdir}, "$installdir/lib/ikiwiki") {
+       foreach my $dir (@{getlibdirs()}, "$installdir/lib/ikiwiki") {
                next unless defined $dir && length $dir;
                foreach my $file (glob("$dir/plugins/*")) {
                        $ret{basename($file)}=1 if -x $file;
                next unless defined $dir && length $dir;
                foreach my $file (glob("$dir/plugins/*")) {
                        $ret{basename($file)}=1 if -x $file;
@@ -712,7 +723,9 @@ sub listplugins () {
 
 sub loadplugins () {
        if (defined $config{libdir} && length $config{libdir}) {
 
 sub loadplugins () {
        if (defined $config{libdir} && length $config{libdir}) {
-               unshift @INC, possibly_foolish_untaint($config{libdir});
+               foreach my $dir (@{getlibdirs()}) {
+                       unshift @INC, possibly_foolish_untaint($dir);
+               }
        }
 
        foreach my $plugin (@{$config{default_plugins}}, @{$config{add_plugins}}) {
        }
 
        foreach my $plugin (@{$config{default_plugins}}, @{$config{add_plugins}}) {
@@ -745,8 +758,8 @@ sub loadplugin ($;$) {
 
        return if ! $force && grep { $_ eq $plugin} @{$config{disable_plugins}};
 
 
        return if ! $force && grep { $_ eq $plugin} @{$config{disable_plugins}};
 
-       foreach my $dir (defined $config{libdir} ? possibly_foolish_untaint($config{libdir}) : undef,
-                        "$installdir/lib/ikiwiki") {
+       foreach my $possiblytainteddir (@{getlibdirs()}, "$installdir/lib/ikiwiki") {
+               my $dir = defined $possiblytainteddir ? possibly_foolish_untaint($possiblytainteddir) : undef;
                if (defined $dir && -x "$dir/plugins/$plugin") {
                        eval { require IkiWiki::Plugin::external };
                        if ($@) {
                if (defined $dir && -x "$dir/plugins/$plugin") {
                        eval { require IkiWiki::Plugin::external };
                        if ($@) {
index 900662eecc425ba60a9b84990ab0a726c7a017c9..8ae1c8bde45ffad5eb56985f2b2e204f2dad7b7c 100644 (file)
@@ -8,9 +8,11 @@ inside the perl search path. For example, if your perl looks in
 `/usr/local/lib/site_perl` for modules, you can locally install ikiwiki
 plugins to `/usr/local/lib/site_perl/IkiWiki/Plugin`
 
 `/usr/local/lib/site_perl` for modules, you can locally install ikiwiki
 plugins to `/usr/local/lib/site_perl/IkiWiki/Plugin`
 
-You can use the `libdir` configuration option to add a directory to the
+You can use the `libdir` configuration option to add directories to the
 search path. For example, if you set `libdir` to `/home/you/.ikiwiki/`,
 search path. For example, if you set `libdir` to `/home/you/.ikiwiki/`,
-then ikiwiki will look for plugins in `/home/you/.ikiwiki/IkiWiki/Plugin`.
+then ikiwiki will look for plugins in `/home/you/.ikiwiki/IkiWiki/Plugin`. This
+configuration option can be either a string (for backward compatibility) or a
+list of strings (to add several directories to the search path).
 
 Ikiwiki also supports plugins that are external programs. These are
 typically written in some other language than perl. Ikiwiki searches for
 
 Ikiwiki also supports plugins that are external programs. These are
 typically written in some other language than perl. Ikiwiki searches for