It would be useful to have
libdir=>[ qw{libdir1 libdir2 libdir3} ]
as a setup option. I have a couple of different directories that e.g. come from different git repos, so merging them is a bit messy.
I think the change is a one-liner, but I put this here for discussion before attempting a patch. If some more confident person wants to have a go, feel free.
I would like this feature too, for the very same reasons.
To preserve backward compatibility, I tried to implement it in the following way: if
libdir
is a string, it is (as it is right now), a directory in which plugins can be searched; iflibdir
is an array of strings, it is a list of libdirs. The ideal place to put it in would be in subroutine checkconfig. However, plugins are loaded (and optionlibdir
is used) in subroutine loadplugins, which is called just beforecheckconfig
.A solution would be to check
libdir
(and turn it into a list if necessary) somewhere in subroutine getconfig, but I do not know where to put it not to make it look like a bad hackā¦Any idea about the best place to preprocess
libdir
? Or any better idea to implement this?Modifying
getconfig
is not a valid solution, because IkiWiki.pm is also imported by ikiwiki-transition, ikiwiki-calendar, the regression tests, etc.The way I would personally do it is to have a new non-exported function
getlibdirs
or something, have it do something like this:if (! ref $config{libdir}) { if (length $config{libdir}) { $config{libdir} = [$config{libdir}]; } else { $config{libdir} = []; } } return @{$config{libdir}};
and replace all uses of $config{libdir} with it.
--smcv
I implemented it (see branch
paternal/libdirs
). I used smcv's idea, but avoiding side effects. I edited documentation as well. As usual, as neither English nor Perl are my first languages (damn! I would be so much more efficient in Python) feel free to improve my patch.While reviewing and applying your patch I decided the new "sometimes a list, sometimes not" behaviour of
libdir
was too confusing in documentation, so I made it work like underlaydir(s) instead: ikiwiki will now search each item of$config{libdirs}
, then$config{libdir}
. done --smcvGood. I cannot see any justification apart from historical reasons, but I agree with your choice. -- Louis