aboutsummaryrefslogtreecommitdiff
path: root/doc/todo/Add_a_plugin_to_list_available_pre-processor_commands.mdwn
diff options
context:
space:
mode:
authorhttp://www.cse.unsw.edu.au/~willu/ <http://www.cse.unsw.edu.au/~willu/@web>2008-08-24 03:19:39 -0400
committerJoey Hess <joey@kitenet.net>2008-08-24 03:19:39 -0400
commitcd5afe22a22c4d018c579abc768726005477158a (patch)
tree9b6fa04a7c6df3ec2eb651c2ad161d8ade42b1fc /doc/todo/Add_a_plugin_to_list_available_pre-processor_commands.mdwn
parentbf3deab7b07716b232f5be113cfa312e8263af6c (diff)
downloadikiwiki-cd5afe22a22c4d018c579abc768726005477158a.tar
ikiwiki-cd5afe22a22c4d018c579abc768726005477158a.tar.gz
Might help to put the right version in...
Diffstat (limited to 'doc/todo/Add_a_plugin_to_list_available_pre-processor_commands.mdwn')
-rw-r--r--doc/todo/Add_a_plugin_to_list_available_pre-processor_commands.mdwn49
1 files changed, 35 insertions, 14 deletions
diff --git a/doc/todo/Add_a_plugin_to_list_available_pre-processor_commands.mdwn b/doc/todo/Add_a_plugin_to_list_available_pre-processor_commands.mdwn
index fd2961c21..765f2c622 100644
--- a/doc/todo/Add_a_plugin_to_list_available_pre-processor_commands.mdwn
+++ b/doc/todo/Add_a_plugin_to_list_available_pre-processor_commands.mdwn
@@ -113,9 +113,6 @@ I've found myself wanting to know which [[plugins]] are switched on so I know wh
>>>>>>> pages get linked correctly, and missing pages get normal creation
>>>>>>> links. The old patch is still here if you decide you prefer that. -- [[Will]]
-Note that because there are double square brackets in the source, this might not
-display quite right.
-
#!/usr/bin/perl
# Ikiwiki listpreprocessors plugin.
package IkiWiki::Plugin::listpreprocessors;
@@ -126,8 +123,9 @@ display quite right.
sub import { #{{{
hook(type => "getsetup", id => "listpreprocessors", call => \&getsetup);
- hook(type => "preprocess", id => "listpreprocessors", call => \&preprocess);
hook(type => "checkconfig", id => "listpreprocessors", call => \&checkconfig);
+ hook(type => "needsbuild", id => "listpreprocessors", call => \&needsbuild);
+ hook(type => "preprocess", id => "listpreprocessors", call => \&preprocess);
} # }}}
sub getsetup () { #{{{
@@ -144,37 +142,60 @@ display quite right.
},
} #}}}
+ my @fullPluginList;
my @earlyPluginList;
+ my $pluginString;
sub checkconfig () { #{{{
+ if (!defined $config{plugin_description_dir}) {
+ $config{plugin_description_dir} = "ikiwiki/plugin/";
+ }
- if (!defined $config{plugin_description_dir}) {
- $config{plugin_description_dir} = "ikiwiki/plugin/";
- }
-
- @earlyPluginList = sort( keys %{ $IkiWiki::hooks{preprocess} } );
+ @earlyPluginList = sort( keys %{ $IkiWiki::hooks{preprocess} } );
} #}}}
+ sub needsbuild (@) { #{{{
+ my $needsbuild=shift;
+
+ @fullPluginList = sort( keys %{ $IkiWiki::hooks{preprocess} } );
+ $pluginString = join (' ', @earlyPluginList) . " : ". join (' ', @fullPluginList);
+
+ foreach my $page (keys %pagestate) {
+ if (exists $pagestate{$page}{listpreprocessors}{shown}) {
+ if ($pagestate{$page}{listpreprocessors}{shown} ne $pluginString) {
+ push @$needsbuild, $pagesources{$page};
+ }
+ if (exists $pagesources{$page} &&
+ grep { $_ eq $pagesources{$page} } @$needsbuild) {
+ # remove state, will be re-added if
+ # the [[!listpreprocessors]] is still there during the
+ # rebuild
+ delete $pagestate{$page}{listpreprocessors}{shown};
+ }
+ }
+ }
+ } # }}}
+
sub preprocess (@) { #{{{
my %params=@_;
+ $pagestate{$params{destpage}}{listpreprocessors}{shown}=$pluginString;
+
my @pluginlist;
if (! defined $params{generated}) {
- @pluginlist = sort( keys %{ $IkiWiki::hooks{preprocess} } );
+ @pluginlist = @fullPluginList;
} else {
@pluginlist = @earlyPluginList;
}
my $result = '<ul class="listpreprocessors">';
-
+
foreach my $plugin (@pluginlist) {
$result .= '<li class="listpreprocessors">[[' . $config{plugin_description_dir} . $plugin . ']]</li>';
}
-
- $result .= "</ul>";
- print $result;
+ $result .= "</ul>";
return IkiWiki::preprocess($params{page}, $params{destpage},
IkiWiki::filter($params{page}, $params{destpage}, $result));