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]]
3 > Yes, a known bug. As noted in the code: --[[Joey]]
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);
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]]
15 --- sidebar.pm.orig 2009-11-21 17:40:02.000000000 +0800
16 +++ sidebar_bugfix.pm 2009-11-21 18:16:11.000000000 +0800
20 hook(type => "getsetup", id => "sidebar", call => \&getsetup);
21 + hook(type => "needsbuild", id => "sidebar", call => \&needsbuild);
22 hook(type => "pagetemplate", id => "sidebar", call => \&pagetemplate);
30 + my $needsbuild=shift;
32 + # Determine every pages' sidebar page
33 + foreach my $page (keys %pagesources) {
34 + my $sidebar_page='';
35 + $sidebar_page=bestlink($page, "sidebar");
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};
45 sub sidebar_content ($) {
49 my $sidebar_type=pagetype($sidebar_file);
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);
60 my $content=readfile(srcfile($sidebar_file));