]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/support_multiple_perl_libraries.mdwn
Create new TODO for minor makefile patches
[ikiwiki.git] / doc / todo / support_multiple_perl_libraries.mdwn
1 It would be useful to have 
2
3     libdir=>[ qw{libdir1 libdir2 libdir3} ]
4
5 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.
6
7 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.
8
9 [[DavidBremner]]
10
11 > I would like this feature too, for the very same reasons.
12 >
13 > 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; if `libdir` is an array of strings, it is a list of libdirs. The ideal place to put it in would be in subroutine [checkconfig](http://source.ikiwiki.branchable.com/?p=source.git;a=blob;f=IkiWiki.pm;hb=56f8223f9594ae687099dada0c138d669a6f931f#l569). However, plugins are loaded (and option `libdir` is used) in subroutine [loadplugins](http://source.ikiwiki.branchable.com/?p=source.git;a=blob;f=IkiWiki.pm;hb=56f8223f9594ae687099dada0c138d669a6f931f#l713), which is called [just before `checkconfig`](http://source.ikiwiki.branchable.com/?p=source.git;a=blob;f=ikiwiki.in;hb=729991564ec7e1116fc023c51e73b47af8b6fce7#l143).
14 >
15 > A solution would be to check `libdir` (and turn it into a list if necessary) somewhere in subroutine [getconfig](http://source.ikiwiki.branchable.com/?p=source.git;a=blob;f=ikiwiki.in;hb=729991564ec7e1116fc023c51e73b47af8b6fce7#l26), but I do not know where to put it not to make it look like a bad hackā€¦
16 >
17 > Any idea about the best place to preprocess `libdir`? Or any better idea to implement this?
18 >
19 > [[Louis|spalax]]
20
21 >> Modifying `getconfig` is not a valid solution, because IkiWiki.pm is also imported by
22 >> [[ikiwiki-transition]], [[ikiwiki-calendar]], the regression tests, etc.
23 >>
24 >> The way I would personally do it is to have a new non-exported function `getlibdirs`
25 >> or something, have it do something like this:
26 >>
27 >>     if (! ref $config{libdir}) {
28 >>             if (length $config{libdir}) {
29 >>                     $config{libdir} = [$config{libdir}];
30 >>             } else {
31 >>                     $config{libdir} = [];
32 >>             }
33 >>     }
34 >>     return @{$config{libdir}};
35 >>
36 >> and replace all uses of $config{libdir} with it.
37 >>
38 >> --[[smcv]]
39 >>>
40 >>> I implemented it (see branch ``paternal/libdirs``). I used [[smcv]]'s idea, but
41 >>> avoiding side effects. I edited documentation as well. As usual, as neither
42 >>> English nor Perl are my first languages (damn! I would be so much more
43 >>> efficient in Python) feel free to improve my [[!taglink patch]].
44 >>> [[!template  id=gitbranch branch=spalax/paternal/libdirs browse="https://github.com/paternal/ikiwiki/tree/paternal/libdirs" author="[[Louis|spalax]]"]]
45
46 >>>> While reviewing and applying your patch I decided the new
47 >>>> "sometimes a list, sometimes not" behaviour of `libdir` was
48 >>>> too confusing in documentation, so I made it work like underlaydir(s)
49 >>>> instead: ikiwiki will now search each item of `$config{libdirs}`, then
50 >>>> `$config{libdir}`. [[done]] --[[smcv]]
51
52 >>>>> Good. I cannot see any justification apart from historical reasons, but I
53 >>>>> agree with your choice.
54 >>>>> -- [[Louis|spalax]]
55
56 [[!taglink wishlist]]