2 # Ikiwiki listpreprocessors plugin.
3 package IkiWiki::Plugin::listpreprocessors;
10 hook(type => "getsetup", id => "listpreprocessors", call => \&getsetup);
11 hook(type => "checkconfig", id => "listpreprocessors", call => \&checkconfig);
12 hook(type => "needsbuild", id => "listpreprocessors", call => \&needsbuild);
13 hook(type => "preprocess", id => "listpreprocessors", call => \&preprocess);
16 sub getsetup () { #{{{
22 preprocessor_description_dir => {
24 description => "The ikiwiki directory that contains plugin descriptions.",
34 sub checkconfig () { #{{{
35 if (!defined $config{plugin_description_dir}) {
36 $config{plugin_description_dir} = "ikiwiki/plugin/";
39 @earlyPluginList = sort( keys %{ $IkiWiki::hooks{preprocess} } );
42 sub needsbuild (@) { #{{{
45 @fullPluginList = sort( keys %{ $IkiWiki::hooks{preprocess} } );
46 $pluginString = join (' ', @earlyPluginList) . " : ". join (' ', @fullPluginList);
48 foreach my $page (keys %pagestate) {
49 if (exists $pagestate{$page}{listpreprocessors}{shown}) {
50 if ($pagestate{$page}{listpreprocessors}{shown} ne $pluginString) {
51 push @$needsbuild, $pagesources{$page};
53 if (exists $pagesources{$page} &&
54 grep { $_ eq $pagesources{$page} } @$needsbuild) {
55 # remove state, will be re-added if
56 # the [[!listpreprocessors]] is still there during the
58 delete $pagestate{$page}{listpreprocessors}{shown};
64 sub preprocess (@) { #{{{
67 $pagestate{$params{destpage}}{listpreprocessors}{shown}=$pluginString;
71 if (defined $params{generated}) {
72 @pluginlist = @fullPluginList;
74 @pluginlist = @earlyPluginList;
77 my $result = '<ul class="listpreprocessors">';
79 foreach my $plugin (@pluginlist) {
80 $result .= '<li class="listpreprocessors">';
81 $result .= htmllink($params{page}, $params{destpage}, IkiWiki::linkpage($config{plugin_description_dir} . $plugin));