]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/Building_a_sidebar_does_not_regenerate_the_subpages.mdwn
Merge branch 'master' of ssh://git.ikiwiki.info/srv/git/ikiwiki.info
[ikiwiki.git] / doc / bugs / Building_a_sidebar_does_not_regenerate_the_subpages.mdwn
1 If sandbox/page.mdwn has been generated and sandbox/sidebar.mdwn is created, the sidebar is only added to sandbox and none of the subpages. --[[TaylorKillian]]
2
3 > Yes, a known bug. As noted in the code: --[[Joey]]
4
5         # FIXME: This isn't quite right; it won't take into account
6         # adding a new sidebar page. So adding such a page
7         # currently requires a wiki rebuild.
8         add_depends($page, $sidebar_page);
9
10 ----
11 Below is a patch for the bug. It's inspired by trying to solve [[todo/Post-compilation inclusion of the sidebar]].
12 What do you think about it? I have a concern though. If a sidebar is removed, it takes two refreshes to update 
13 the affected pages. Is this a feature or a bug? --[[harishcm]]
14
15     --- sidebar.pm.orig 2009-11-21 17:40:02.000000000 +0800
16     +++ sidebar_bugfix.pm       2009-11-21 18:16:11.000000000 +0800
17     @@ -10,6 +10,7 @@
18      
19      sub import {
20         hook(type => "getsetup", id => "sidebar", call => \&getsetup);
21     +   hook(type => "needsbuild", id => "sidebar", call => \&needsbuild);
22         hook(type => "pagetemplate", id => "sidebar", call => \&pagetemplate);
23      }
24      
25     @@ -21,6 +22,22 @@
26                 },
27      }
28      
29     +sub needsbuild (@) {
30     +   my $needsbuild=shift;
31     +
32     +   # Determine every pages' sidebar page
33     +   foreach my $page (keys %pagesources) {
34     +           my $sidebar_page='';
35     +           $sidebar_page=bestlink($page, "sidebar");
36     +           
37     +           # If a page's sidebar has changed, force rebuild
38     +           if (!exists $pagestate{$page}{sidebar}{sidebar_page} || $pagestate{$page}{sidebar}{sidebar_page} ne $sidebar_page) {
39     +                   $pagestate{$page}{sidebar}{sidebar_page} = $sidebar_page;
40     +                   push @$needsbuild, $pagesources{$page};
41     +           }
42     +   }
43     +}
44     +
45      sub sidebar_content ($) {
46         my $page=shift;
47         
48     @@ -29,9 +46,9 @@
49         my $sidebar_type=pagetype($sidebar_file);
50         
51         if (defined $sidebar_type) {
52     -           # FIXME: This isn't quite right; it won't take into account
53     -           # adding a new sidebar page. So adding such a page
54     -           # currently requires a wiki rebuild.
55     +           # Record current sidebar page for rechecking bestlink 
56     +           # during wiki refresh. Also add depends on the sidebar page.
57     +           $pagestate{$page}{sidebar}{sidebar_page}=$sidebar_page;
58                 add_depends($page, $sidebar_page);
59      
60                 my $content=readfile(srcfile($sidebar_file));