]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/Inline_doesn__39__t_wikilink_to_pages.mdwn
168c1b2c46856395cd9214bf607a7371ed79ec13
[ikiwiki.git] / doc / bugs / Inline_doesn__39__t_wikilink_to_pages.mdwn
1 It seems that the [[ikiwiki/directive/inline]] directive doesn't generate wikilinks to the pages it includes.  For example I would expect the following to inline all bugs inside this bug report:
2
3 \[[!inline pages="bugs/* and !*/discussion and backlink(bugs)" feeds=no postform=no archive=yes show="10"]]
4
5 But here it is:
6
7 [[!inline pages="bugs/* and !*/discussion and backlink(bugs)" feeds=no postform=no archive=yes show="10"]]
8
9 and note that it only included the 'normal' wikilinks (and also note that this page is not marked done even though the done page is inlined).
10 One might also wonder if inline would make this page link to any internal links on those inlined pages too, but I think
11 that would be overkill.
12
13 I'm not even really sure if this is a bug or defined behaviour, but I thought it might work and it didn't.  Regardless,
14 the correct behaviour, whichever is decided, should be documented.  -- [[Will]]
15
16 It appears that [[ikiwiki/directive/map]] also doesn't wikilink to the pages it links.  Perhaps in each of these
17 cases there should be another parameter to the directive that allows linking to switched on.  Just switching
18 it on universally at this point might break a number of people's pagespecs.  -- [[Will]]
19
20 > There's a simple reason why these directives don't generate a record of a
21 > wikilink between them and the pages they include: Semantically, inlining
22 > a page is not the same as writing a link to it. Nor is generating a map that
23 > lists a page the same as linking to it. I don't think this is a bug.
24 > --[[Joey]] 
25
26 Here is a patch to make map link to its linked pages (when passed `link="yes"`).  It is a bit problematic in that it uses a pagespec
27 to decide what to link to (which is why I wanted it).  However, at the time the pagespec is used the links
28 for each page haven't finished being calculated (we're using the pagespec to figure out those links,
29 remember).  This means that some pagespec match functions may not work correctly.  Sigh.  
30 It would be nice to find a topological ordering of the pages and scan them in that order
31 so that everything we need is found before we need it, but this patch doesn't do that (it would be
32 complex).
33
34 If you just use simple pagespecs you'll be fine.  Unfortunately I really wanted this for more complex
35 pagespecs.  -- [[Will]]
36
37     diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm
38     index 3284931..57c0a7a 100644
39     --- a/IkiWiki/Plugin/map.pm
40     +++ b/IkiWiki/Plugin/map.pm
41     @@ -13,7 +13,7 @@ use IkiWiki 3.00;
42      
43      sub import {
44         hook(type => "getsetup", id => "map", call => \&getsetup);
45     -   hook(type => "preprocess", id => "map", call => \&preprocess);
46     +   hook(type => "preprocess", id => "map", call => \&preprocess, scan => 1);
47      }
48      
49      sub getsetup () {
50     @@ -27,7 +27,9 @@ sub getsetup () {
51      sub preprocess (@) {
52         my %params=@_;
53         $params{pages}="*" unless defined $params{pages};
54     -   
55     +
56     +   return if (!defined wantarray && !IkiWiki::yesno($params{link}));
57     +
58         my $common_prefix;
59      
60         # Get all the items to map.
61     @@ -42,6 +44,9 @@ sub preprocess (@) {
62                         else {
63                                 $mapitems{$page}='';
64                         }
65     +                   if (!defined wantarray && IkiWiki::yesno($params{link})) {
66     +                           push @{$links{$params{page}}}, $page;
67     +                   }
68                         # Check for a common prefix.
69                         if (! defined $common_prefix) {
70                                 $common_prefix=$page;
71     @@ -62,6 +67,8 @@ sub preprocess (@) {
72                 }
73         }
74         
75     +   return if ! defined wantarray;
76     +   
77         # Common prefix should not be a page in the map.
78         while (defined $common_prefix && length $common_prefix &&
79                exists $mapitems{$common_prefix}) {