summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorhttp://www.cse.unsw.edu.au/~willu/ <http://www.cse.unsw.edu.au/~willu/@web>2008-08-24 02:17:42 -0400
committerJoey Hess <joey@kitenet.net>2008-08-24 02:17:42 -0400
commitbf3deab7b07716b232f5be113cfa312e8263af6c (patch)
treec7ef2544356f54ebda9afe38ae5cd6d64f55fa67 /doc
parentcbd7b8a1f22d09895fe0ad4de0e4358c02f82aef (diff)
New patch taking comments into account
Diffstat (limited to 'doc')
-rw-r--r--doc/todo/Add_a_plugin_to_list_available_pre-processor_commands.mdwn79
1 files changed, 79 insertions, 0 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 8c22f07a4..fd2961c21 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
@@ -105,6 +105,85 @@ I've found myself wanting to know which [[plugins]] are switched on so I know wh
>>>>>> you wanted.
>>>>>> --[[Joey]]
+>>>>>>> I kinda agree about the page generation. I don't like mixing an
+>>>>>>> inlined and a list though. Besides which, that ends
+>>>>>>> up keeping much of complexity of the page generation because
+>>>>>>> the code still has to detect which pages are missing. I've added
+>>>>>>> a patch that uses a list of wikilinks instead. This way available
+>>>>>>> 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;
+
+ use warnings;
+ use strict;
+ use IkiWiki 2.00;
+
+ sub import { #{{{
+ hook(type => "getsetup", id => "listpreprocessors", call => \&getsetup);
+ hook(type => "preprocess", id => "listpreprocessors", call => \&preprocess);
+ hook(type => "checkconfig", id => "listpreprocessors", call => \&checkconfig);
+ } # }}}
+
+ sub getsetup () { #{{{
+ return
+ plugin => {
+ safe => 1,
+ rebuild => undef,
+ },
+ preprocessor_description_dir => {
+ type => "string",
+ description => "The ikiwiki directory that contains plugin descriptions.",
+ safe => 1,
+ rebuild => 1,
+ },
+ } #}}}
+
+ my @earlyPluginList;
+
+ sub checkconfig () { #{{{
+
+ if (!defined $config{plugin_description_dir}) {
+ $config{plugin_description_dir} = "ikiwiki/plugin/";
+ }
+
+ @earlyPluginList = sort( keys %{ $IkiWiki::hooks{preprocess} } );
+ } #}}}
+
+ sub preprocess (@) { #{{{
+ my %params=@_;
+
+ my @pluginlist;
+
+ if (! defined $params{generated}) {
+ @pluginlist = sort( keys %{ $IkiWiki::hooks{preprocess} } );
+ } 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;
+
+ return IkiWiki::preprocess($params{page}, $params{destpage},
+ IkiWiki::filter($params{page}, $params{destpage}, $result));
+ } # }}}
+
+ 1
+
+----
+
Here is the main listpreprocessors plugin. (Note, because this has double
square brackets in the source, it isn't quite displaying correctly - look
at the page source for details.) New template files follow: