X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/1f7175e891f87c350decc1ec821bebb5adc22c2a..c037714b77535c849c8d8ef4807af2b59737a5c5:/IkiWiki/Plugin/sidebar.pm diff --git a/IkiWiki/Plugin/sidebar.pm b/IkiWiki/Plugin/sidebar.pm index 1b302dcf9..c1146b7b4 100644 --- a/IkiWiki/Plugin/sidebar.pm +++ b/IkiWiki/Plugin/sidebar.pm @@ -22,8 +22,8 @@ sub getsetup () { }, global_sidebars => { type => "boolean", - examples => 1, - description => "show sidebar page on all pages?" + example => 1, + description => "show sidebar page on all pages?", safe => 1, rebuild => 1, }, @@ -33,23 +33,22 @@ my %pagesidebar; sub preprocess (@) { my %params=@_; - my $content=shift; - shift; - - if (! defined $content) { - error(gettext("sidebar content not specified")); - } my $page=$params{page}; return "" unless $page eq $params{destpage}; - my $file = $pagesources{$page}; - my $type = pagetype($file); - - $pagesidebar{$page}= - IkiWiki::htmlize($page, $page, $type, - IkiWiki::linkify($page, $page, - IkiWiki::preprocess($page, $page, - IkiWiki::filter($page, $page, $content)))); + + if (! defined $params{content}) { + $pagesidebar{$page}=undef; + } + else { + my $file = $pagesources{$page}; + my $type = pagetype($file); + + $pagesidebar{$page}= + IkiWiki::htmlize($page, $page, $type, + IkiWiki::linkify($page, $page, + IkiWiki::preprocess($page, $page, $params{content}))); + } return ""; } @@ -60,9 +59,10 @@ my $oldcontent; sub sidebar_content ($) { my $page=shift; - return $pagesidebar{$page} if exists $pagesidebar{$page}; + return delete $pagesidebar{$page} if defined $pagesidebar{$page}; - return if defined $config{global_sidebars} && !$config{global_sidebars}; + return if ! exists $pagesidebar{$page} && + defined $config{global_sidebars} && ! $config{global_sidebars}; my $sidebar_page=bestlink($page, "sidebar") || return; my $sidebar_file=$pagesources{$sidebar_page} || return; @@ -96,11 +96,10 @@ sub sidebar_content ($) { sub pagetemplate (@) { my %params=@_; - my $page=$params{page}; my $template=$params{template}; - - if ($template->query(name => "sidebar")) { - my $content=sidebar_content($page); + if ($params{destpage} eq $params{page} && + $template->query(name => "sidebar")) { + my $content=sidebar_content($params{destpage}); if (defined $content && length $content) { $template->param(sidebar => $content); }