something like this:
<pre>
-[[missingparents pages="posts/* and !posts/*/*" generate="""[[template id=year text="$page"]]"""]]
-[[missingparents pages="posts/*/* and !posts/*/*/*" generate="""[[template id=month text="$page"]]"""]]
-[[missingparents pages="posts/*/*/* and !posts/*/*/*/*" generate="""[[template id=day text="$page"]]"""]]
+[[!missingparents pages="posts/* and !posts/*/*" generate="""[[!template id=year text="$page"]]"""]]
+[[!missingparents pages="posts/*/* and !posts/*/*/*" generate="""[[!template id=month text="$page"]]"""]]
+[[!missingparents pages="posts/*/*/* and !posts/*/*/*/*" generate="""[[!template id=day text="$page"]]"""]]
</pre>
And it scans the whole wiki for pages that match the pagespecs but are missing
the ability to hierarchically organize blog posts and automatically generate
structural pages for year, month, or day. Please apply. --Ethan
+> This looks a lot like [[plugins/autoindex]], except limited to a subset
+> of pages, and with different templates according to the page it's used
+> on. Perhaps it could become several enhancements for autoindex? --[[smcv]]
+
+----
+
<pre>
Index: IkiWiki/Render.pm
===================================================================
===================================================================
--- IkiWiki/Plugin/missingparents.pm (revision 0)
+++ IkiWiki/Plugin/missingparents.pm (revision 0)
-@@ -0,0 +1,136 @@
+@@ -0,0 +1,142 @@
+#!/usr/bin/perl
+# missingparents plugin: detect missing parents of pages and create them
+package IkiWiki::Plugin::missingparents;
+my %ownfiles;
+my @pagespecs;
+
-+sub import { #{{{
++sub import {
+ hook(type => "checkconfig", id => "missingparents", call => \&checkconfig);
+ hook(type => "needsdelete", id => "missingparents", call => \&needsdelete);
+ hook(type => "needsbuild", id => "missingparents", call => \&needsbuild);
+ hook(type => "savestate", id => "missingparents", call => \&savestate);
+ hook(type => "preprocess", id => "missingparents", call => \&preprocess_missingparents);
-+} # }}}
++}
+
-+sub checkconfig () { #{{{
++sub checkconfig () {
+ IkiWiki::preprocess("missingparents", "missingparents",
+ readfile(srcfile("missingparents.mdwn")));
+ loadstate();
+ unlink $config{srcdir}.'/'.$file;
+ }
+ }
-+} #}}}
++}
+
-+sub preprocess_missingparents (@) { #{{{
++sub preprocess_missingparents (@) {
+ my %params=@_;
+
+ if (! defined $params{pages} || ! defined $params{generate}) {
-+ return "[[missingparents ".gettext("missing pages or generate parameter")."]]";
++ return "[[!missingparents ".gettext("missing pages or generate parameter")."]]";
+ }
+
+ push @pagespecs, \%params;
+ #translators: is text for pages that match that pagespec.
+ return sprintf(gettext("missingparents in %s will be %s"),
+ '`'.$params{pages}.'`', '`\\'.$params{generate}.'`');
-+} # }}}
++}
+
+my $state_loaded=0;
-+sub loadstate() { #{{{
++sub loadstate() {
+ my $filename = "$config{wikistatedir}/missingparents";
+ if (-e $filename) {
+ open (IN, $filename) ||
+
+ $state_loaded=1;
+ }
-+} #}}}
++}
+
-+sub savestate() { #{{{
++sub savestate() {
+ my $filename = "$config{wikistatedir}/missingparents.new";
+ my $cleanup = sub { unlink ($filename) };
+ open (OUT, ">$filename") || error("open $filename: $!", $cleanup);
+ }
+ rename($filename, "$config{wikistatedir}/missingparents") ||
+ error("rename $filename: $!", $cleanup);
-+} #}}}
++}
+
-+sub needsdelete (@) { #{{{
++sub needsdelete (@) {
+ my $files=shift;
+
+ my @mydel;
+ foreach my $page (@mydel){
+ push @{$files}, $page;
+ }
-+} #}}}
++}
+
-+sub check_matches($) { #{{{
++sub check_matches($) {
+ my $page = shift;
+ return if $IkiWiki::pagesources{$page};
+
+ return $output;
+ }
+ return "";
-+} #}}}
++}
+
-+sub needsbuild ($) { #{{{
++sub needsbuild ($) {
+ my $files=shift;
+ my @new;
+
+ foreach my $file (@{$files}) {
++ if ($ownfiles{$file}) {
++ # someone edited our file, making it the
++ # user's problem
++ delete $ownfiles{$file};
++ next;
++ }
+ my $page = pagename $file;
+ my $newfile = "";
+ foreach my $parent (split '/', $page) {
+ $ownfiles{$file} = 1;
+ push @{$files}, $file;
+ }
-+} #}}}
++}
+
+1
-Index: IkiWiki/Plugin/rst.pm
-===================================================================
---- IkiWiki/Plugin/rst.pm (revision 3926)
-+++ IkiWiki/Plugin/rst.pm (working copy)
-@@ -25,7 +25,7 @@
- html = publish_string(stdin.read(), writer_name='html',
- settings_overrides = { 'halt_level': 6,
- 'file_insertion_enabled': 0,
-- 'raw_enabled': 0 }
-+ 'raw_enabled': 1 }
- );
- print html[html.find('<body>')+6:html.find('</body>')].strip();
- ";
Index: IkiWiki.pm
===================================================================
--- IkiWiki.pm (revision 3926)
our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
@@ -330,6 +336,30 @@
error("failed renaming $newfile to $destdir/$file: $!", $cleanup);
- } #}}}
+ }
-+sub newpage($$) { #{{{
++sub newpage($$) {
+ my $file=shift;
+ my $page=shift;
+
+ $pagemtime{$page} = $pagectime{$page} = time;
+ $pagesources{$page} = $file;
+ $pagecase{lc $page} = $page;
-+} #}}}
++}
+
-+sub delpage($) { #{{{
++sub delpage($) {
+ my $page=shift;
+ $links{$page}=[];
+ $renderedfiles{$page}=[];
+ delete $destsources{$_};
+ }
+ }
-+} #}}}
++}
+
my %cleared;
- sub will_render ($$;$) { #{{{
+ sub will_render ($$;$) {
my $page=shift;
-</pre>
\ No newline at end of file
+</pre>
+
+[[!tag patch patch/core]]