2 # Ikiwiki listdirectives plugin.
3 package IkiWiki::Plugin::listdirectives;
10 hook(type => "getsetup", id => "listdirectives", call => \&getsetup);
11 hook(type => "checkconfig", id => "listdirectives", call => \&checkconfig);
12 hook(type => "needsbuild", id => "listdirectives", call => \&needsbuild);
13 hook(type => "preprocess", id => "listdirectives", call => \&preprocess);
16 sub getsetup () { #{{{
22 directive_description_dir => {
24 description => "directory in srcdir that contains directive descriptions",
25 example => "ikiwiki/directive",
35 sub checkconfig () { #{{{
36 if (! defined $config{directive_description_dir}) {
37 $config{directive_description_dir} = "ikiwiki/directive";
40 $config{directive_description_dir} =~ s/\/+$//;
43 @earlylist = sort keys %{$IkiWiki::hooks{preprocess}};
46 sub needsbuild (@) { #{{{
49 @fulllist = sort keys %{$IkiWiki::hooks{preprocess}};
50 $pluginstring = join(' ', @earlylist) . " : " . join(' ', @fulllist);
52 foreach my $page (keys %pagestate) {
53 if (exists $pagestate{$page}{listdirectives}{shown}) {
54 if ($pagestate{$page}{listdirectives}{shown} ne $pluginstring) {
55 push @$needsbuild, $pagesources{$page};
57 if (exists $pagesources{$page} &&
58 grep { $_ eq $pagesources{$page} } @$needsbuild) {
59 # remove state, will be re-added if
60 # the [[!listdirectives]] is still there during the
62 delete $pagestate{$page}{listdirectives}{shown};
68 sub preprocess (@) { #{{{
71 $pagestate{$params{destpage}}{listdirectives}{shown}=$pluginstring;
75 if (defined $params{generated}) {
76 @pluginlist = @fulllist;
79 @pluginlist = @earlylist;
82 my $result = '<ul class="listdirectives">';
84 foreach my $plugin (@pluginlist) {
85 $result .= '<li class="listdirectives">';
86 my $link=IkiWiki::linkpage($config{directive_description_dir}."/".$plugin);
87 add_depends($params{page}, $link);
88 $result .= htmllink($params{page}, $params{destpage}, $link);