]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/map_is_inconsistent_about_bare_directories.mdwn
(no commit message)
[ikiwiki.git] / doc / bugs / map_is_inconsistent_about_bare_directories.mdwn
1 The [[plugins/map]] plugin has inconsistent behaviour.  In particular, I have in my wiki some directory structures holding files without wikitext pointers (I point directly to the files from elsewhere).  For example, imagine the following file structure in the source dir:
2
3     ; ls -R dirA dirB
4     dirA:
5     subA        subB
6     
7     dirA/subA:
8     filea.mdwn  fileb.mdwn
9     
10     dirA/subB:
11     filec.mdwn  filed.mdwn
12     
13     dirB:
14     subA        subC
15     
16     dirB/subA:
17     filea.mdwn
18     
19     dirB/subC:
20     fileb.mdwn  filec.mdwn
21
22 When I use map to make a map of this, the result looks more like this:
23
24 <ul>
25 <li><span class="createlink">? dirA</span>
26 <ul>
27 <li><span class="createlink">? subA</span>
28 <ul>
29 <li>filea
30 </li>
31 </ul>
32 <ul>
33 <li>fileb
34 </li>
35 </ul>
36 <ul>
37 <li>filec
38 </li>
39 <li>filed
40 </li>
41 </ul>
42 </li>
43 </ul>
44 </li>
45 <li><span class="createlink">? dirB</span>
46 <ul>
47 <li><span class="createlink">? subA</span>
48 <ul>
49 <li>filea
50 </li>
51 </ul>
52 </li>
53 </ul>
54 <ul>
55 <li><span class="createlink">? subC</span>
56 <ul>
57 <li>fileb
58 </li>
59 </ul>
60 <ul>
61 <li>filec
62 </li>
63 </ul>
64 </li>
65 </ul>
66 </li>
67 </ul>
68
69 Note that while the dirA/subA directory exists with a create link, the dirA/subB directory is missing from the map.  Interestingly, dirB/subC is shown in the map.  If you add a second file to dirB/subA then dirB/subC disappears as well.
70
71 I could imagine including all 'bare' directories in the map, and I could imagine including no 'bare' directories in the map.  Just including the first bare directory seems a strange intermediate point.
72
73 Attached is a [[patch]] that fixes the issue.  The current map code makes one pass over the sorted list of pages.  This adds an initial pass that goes through and makes sure that all parent directories are included.  With this initial pass added, the following pass could probably be simplified.
74
75 One solution could also use the [[plugins/autoindex]] plugin to make sure that parent pages actually exist.  This is really only a stop-gap solution until the patch is applied - map still needs to be made bug-free.
76
77 Note: This patch adds items to a map while it is in a foreach loop over a sorted list of keys from that same map.  Changing a map while iterating through it is normally problematic.  I'm assuming the sort insulates the code from this - I do not need to iterate over any of the newly added elements.
78
79 -- [[users/Will]]
80
81 > The patch is subtly buggy and just papers over the actual bug with a
82 > lot of extra code. Thanks for trying to come up with a patch for this
83 > annyoingly complicated bug.. I think I've fixed the underlying bug now.
84 > --[[Joey]]
85
86 > [[!tag done]]