Fix aggregateinternal migration so it skips expired entries, and deletes output

master
Simon McVittie 2008-07-15 03:24:05 +01:00
parent d3008b626e
commit b29d11b3c6
5 changed files with 17 additions and 11 deletions

View File

@ -132,9 +132,11 @@ sub migrate_to_internal { #{{{
foreach my $data (values %guids) { foreach my $data (values %guids) {
next unless $data->{page}; next unless $data->{page};
next if $data->{expired};
$config{aggregateinternal} = 0; $config{aggregateinternal} = 0;
my $oldname = pagefile($data->{page}); my $oldname = pagefile($data->{page});
my $oldoutput = $config{destdir}."/".IkiWiki::htmlpage($data->{page});
$config{aggregateinternal} = 1; $config{aggregateinternal} = 1;
my $newname = pagefile($data->{page}); my $newname = pagefile($data->{page});
@ -154,6 +156,10 @@ sub migrate_to_internal { #{{{
else { else {
debug("$oldname not found"); debug("$oldname not found");
} }
if (-e $oldoutput) {
debug("removing output file $oldoutput");
unlink($oldoutput) || error ("$!");
}
} }
savestate(); savestate();

View File

@ -28,7 +28,7 @@ treat these as preprocessor directives and convert them.
# aggregateinternal # aggregateinternal
The `aggregateinternal` mode moves pages aggregated by the aggregate plugin The `aggregateinternal` mode moves pages aggregated by the aggregate plugin
so that the `aggregateinternal` option can be endabled so that the `aggregateinternal` option can be enabled.
# indexdb # indexdb

View File

@ -100,8 +100,8 @@ you should follow this process:
in those PageSpecs. For example, if the PageSpec was `foo/*`, it should in those PageSpecs. For example, if the PageSpec was `foo/*`, it should
be changed to `internal(foo/*)`. This has to be done because internal be changed to `internal(foo/*)`. This has to be done because internal
pages are not matched by regular globs. pages are not matched by regular globs.
2. Use [[ikiwiki-transition]] to move all existing aggregated `.html` 2. Use [[ikiwiki-transition]] to rename all existing aggregated `.html`
files. The command to run is `ikiwiki-transition aggregateinternal $srcdir`, files in the input directory, and delete the corresponding files from
or if you have changed the `htmlext` option to something other than "html", the output directory. The command to run is
`ikiwiki-transition aggregateinternal $srcdir $htmlext` `ikiwiki-transition aggregateinternal $setupfile`
3. Turn on `aggregateinternal` in the setup file and rebuild the wiki. 3. Turn on `aggregateinternal` in the setup file and rebuild the wiki.

View File

@ -53,7 +53,7 @@ change their pagespecs to use `internal()`.
> I've patched ikiwiki-transition to have an aggregateinternal mode. > I've patched ikiwiki-transition to have an aggregateinternal mode.
> See my aggregateinternal branch, again. > See my aggregateinternal branch, again.
> "ikiwiki-transition aggregateinternal $srcdir $htmlext" moves the pages around, > "ikiwiki-transition aggregateinternal $setupfile" moves the pages around,
> although it doesn't update the pagespecs (I wouldn't know how...) --[[smcv]] > although it doesn't update the pagespecs (I wouldn't know how...) --[[smcv]]
[[patch]] [[patch]]

View File

@ -100,12 +100,12 @@ sub hashpassword {
} }
sub aggregateinternal { sub aggregateinternal {
$config{srcdir} = shift; require IkiWiki::Setup;
$config{wikistatedir} = $config{srcdir}."/.ikiwiki";
$config{htmlext} = (shift or "html");
require IkiWiki::Plugin::aggregate; require IkiWiki::Plugin::aggregate;
%config = (IkiWiki::defaultconfig(), IkiWiki::Setup::load(shift));
IkiWiki::checkconfig();
IkiWiki::Plugin::aggregate::migrate_to_internal(); IkiWiki::Plugin::aggregate::migrate_to_internal();
print "... now add aggregateinternal => 1 to your .setup file\n"; print "... now add aggregateinternal => 1 to your .setup file\n";
@ -117,7 +117,7 @@ sub usage {
print STDERR " prefix_directives file\n"; print STDERR " prefix_directives file\n";
print STDERR " indexdb srcdir\n"; print STDERR " indexdb srcdir\n";
print STDERR " hashpassword srcdir\n"; print STDERR " hashpassword srcdir\n";
print STDERR " aggregateinternal srcdir [htmlext]\n"; print STDERR " aggregateinternal setupfile\n";
exit 1; exit 1;
} }