]> sipb.mit.edu Git - ikiwiki.git/blobdiff - doc/todo/Add_a_plugin_to_list_available_pre-processor_commands.mdwn
convert rcs_revert to only stage the reversion
[ikiwiki.git] / doc / todo / Add_a_plugin_to_list_available_pre-processor_commands.mdwn
index fd2961c2122ef1eece76d5bee9c4e8032cecdde7..9ac400cd24d077b6809aa4319218689e45406dec 100644 (file)
@@ -113,256 +113,29 @@ 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.
+>>>>>>>> Can you explain the full/early list (why track both?) and generated parameter?
 
-    #!/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
+>>>>>>>>> If you add in all the shortcuts you get quite a long list.  My original idea
+>>>>>>>>> was to just track the plugin commands.  This is the early list.  But then
+>>>>>>>>> I thought that it might be nice for someone looking at wiki source and
+>>>>>>>>> seeing a shortcut to know where it came from.  So I decided to make
+>>>>>>>>> displaying the full list an option, with the original concept as the default.
 
-----
+>>>>>>>>> Another option here might be to generate the full list every time, but give
+>>>>>>>>> generated pre-processor commands (e.g. shortcuts) a different css class.
+>>>>>>>>> I'm not sure that is better than what I have though. 
 
-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:
+>>>>>>>>> I keep track of both in the page state because if a command moves from
+>>>>>>>>> a shortcut to the early list (or vice versa) it changes what should be
+>>>>>>>>> displayed in the default use of the plugin.  I thought about tracking just what
+>>>>>>>>> was actually used on the page, but I don't know in the needsbuild hook whether the `generated`
+>>>>>>>>> parameter has been supplied (or maybe the plugin is used twice on the page -
+>>>>>>>>> once in each form).  It was just easier to track both.
 
-    #!/usr/bin/perl
-    # Ikiwiki listpreprocessors plugin.
-    package IkiWiki::Plugin::listpreprocessors;
-    
-    use warnings;
-    use strict;
-    use Encode;
-    use IkiWiki 2.00;
-    
-    sub import { #{{{
-       hook(type => "getsetup", id => "listpreprocessors", call => \&getsetup);
-       hook(type => "preprocess", id => "listpreprocessors", call => \&preprocess);
-       hook(type => "refresh", id => "listpreprocessors", call => \&refresh);
-    } # }}}
-    
-    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,
-               },
-               preprocessor_description_autocreate => {
-                       type => "boolean",
-                       description => "Should pre-processor command descriptions be automatically created from a template.",
-                       safe => 1,
-                       rebuild => 1,
-               },
-    } #}}}
-    
-    sub gendescription ($$) { #{{{
-       my $plugin=shift;
-       my $page=shift;
-       my $file=$page.".".$config{default_pageext};
-       my $template=template("preprocessor-description.tmpl");
-       $template->param(page => $page, plugin => $plugin);
-       writefile($file, $config{srcdir}, $template->output);
-       if ($config{rcs}) {
-               IkiWiki::rcs_add($file);
-       }
-    } #}}}
-    
-    sub refresh () { #{{{
-       eval q{use File::Find};
-       error($@) if $@;
-    
-       if (defined $config{preprocessor_description_autocreate} && ! $config{preprocessor_description_autocreate}) {
-               return; # create pages unless they explicitly ask us not to
-       }
-    
-       if (!defined $config{preprocessor_description_dir}) {
-               $config{preprocessor_description_dir} = "ikiwiki/plugin/";
-       }
-       
-       my @pluginlist = sort( keys %{ $IkiWiki::hooks{preprocess} } );
-       my %pluginpages;
-    
-       if (@pluginlist) {
-               my ($plugin,$page);
-               
-               foreach $plugin (@pluginlist) {
-                       $pluginpages{$plugin} = $config{preprocessor_description_dir} . $plugin;
-               }
-    
-               my %pages;
-               foreach my $dir ($config{srcdir}, @{$config{underlaydirs}}, $config{underlaydir}) {
-                       find({
-                               no_chdir => 1,
-                               wanted => sub {
-                                       $_=decode_utf8($_);
-                                       if (IkiWiki::file_pruned($_, $dir)) {
-                                               $File::Find::prune=1;
-                                       }
-                                       elsif (! -l $_) {
-                                               my ($f)=/$config{wiki_file_regexp}/; # untaint
-                                               return unless defined $f;
-                                               $f=~s/^\Q$dir\E\/?//;
-                                               return unless length $f;
-                                               return if $f =~ /\._([^.]+)$/; # skip internal page
-                                               if (! -d _) {
-                                                       $pages{pagename($f)}=$f;
-                                               }
-                                       }
-                               }
-                       }, $dir);
-               }
-    
-               if ($config{rcs}) {
-                       IkiWiki::disable_commit_hook();
-               }
-               
-               my $needcommit = 0;
-               
-               while (($plugin,$page) = each %pluginpages) {
-                       if (! exists $pages{$page}) {
-                               $needcommit = 1;
-                               gendescription($plugin,$page);
-                       }
-               }
-               
-               if ($config{rcs}) {
-                       if ($needcommit) {
-                               IkiWiki::rcs_commit_staged(
-                                       gettext("automatic pre-processor description generation"),
-                                       undef, undef);
-                       }
-                       IkiWiki::enable_commit_hook();
-               }
-       }
-    } #}}}
-    
-    sub preprocess (@) { #{{{
-       my %params=@_;
-       
-       if (!defined $config{plugin_description_dir}) {
-               $config{plugin_description_dir} = "ikiwiki/plugin/";
-       }
-       
-       my @pluginlist = sort( keys %{ $IkiWiki::hooks{preprocess} } );
-       foreach my $plugin (@pluginlist) {
-               $plugin = $config{plugin_description_dir} . $plugin;
-       }
-       my $pluginString = join (' or ', @pluginlist);
-       
-       my $result = "[[!inline pages=\"$pluginString\" feeds=\"no\" show=0 sort=\"title\"";
-       
-       if (defined $params{inline}) {
-               $result .= ' template=\"listpreprocessors-listonly\" archive="yes"';
-       } else {
-               $result .= ' template=\"listpreprocessors-inline\" archive="no"';
-       }
-       
-       $result .= "]]";
-       
-       return IkiWiki::preprocess($params{page}, $params{destpage}, 
-               IkiWiki::filter($params{page}, $params{destpage}, $result));
-    } # }}}
-    
-    1
+>>>>>>>> Only code change I'd suggest is using `htmllink` rather than 
+>>>>>>>> generating a wikilink.
 
---------
+>>>>>>>>> Yeah - that would make sense.  done. -- [[Will]]
 
-This is what I was using for `listpreprocessors-inline.tmpl`:
-
-    <div class="listpreprocessorsinline">
-    
-    <div class="inlineheader">
-    
-    <span class="header">
-    <a href="<TMPL_VAR PAGEURL>"><TMPL_VAR TITLE></a>
-    </span>
-    
-    </div><!--.inlineheader-->
-    
-    <div class="inlinecontent">
-    <TMPL_VAR CONTENT>
-    </div><!--.inlinecontent-->
-    
-    </div><!--.listpreprocessorsinline-->
-
---------
-
-This is what I was using for `listpreprocessors-listonly.tmpl`:
-
-    <p class="listpreprocessors"><a href="<TMPL_VAR PAGEURL>"><TMPL_VAR TITLE></a></p>
-
---------
-
-This is what I was using for `preprocessor-description.tmpl`:
-
-    The <TMPL_VAR plugin> preprocessor command currently has no description.
-    
-    Maybe you should edit this page to add one.
+Patch is applied (along with some changes..). [[done]] (But, see
+[[directive_docs]].