aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/autoindex.pm2
-rwxr-xr-xt/autoindex.t36
2 files changed, 25 insertions, 13 deletions
diff --git a/IkiWiki/Plugin/autoindex.pm b/IkiWiki/Plugin/autoindex.pm
index 04d501461..d5ee4b58f 100644
--- a/IkiWiki/Plugin/autoindex.pm
+++ b/IkiWiki/Plugin/autoindex.pm
@@ -89,7 +89,7 @@ sub refresh () {
if (! -d _) {
$pages{pagename($f)}=1;
}
- elsif ($dir eq $config{srcdir}) {
+ elsif ($dir eq $config{srcdir} || ! $config{autoindex_commit}) {
$dirs{$f}=1;
}
}
diff --git a/t/autoindex.t b/t/autoindex.t
index 2c7a286f8..e25b61733 100755
--- a/t/autoindex.t
+++ b/t/autoindex.t
@@ -3,7 +3,7 @@ package IkiWiki;
use warnings;
use strict;
-use Test::More tests => 44;
+use Test::More tests => 50;
BEGIN { use_ok("IkiWiki"); }
BEGIN { use_ok("IkiWiki::Render"); }
@@ -54,15 +54,15 @@ $pagemtime{"has_internal/internal"} = 123456789;
$pagectime{"has_internal/internal"} = 123456789;
writefile("has_internal/internal._aggregated", "t/tmp/in", "this page is internal");
-# a directory containing only a page in an underlay shouldn't be indexed
-# (arguably; see [[transient autocreated tagbase is not transient autoindexed]])
+# a directory containing only a page in an underlay is now indexed
+# (see [[transient autocreated tagbase is not transient autoindexed]])
$pagesources{"has_underlay/underlay"} = "has_underlay/underlay.mdwn";
$pagemtime{"has_underlay/underlay"} = 123456789;
$pagectime{"has_underlay/underlay"} = 123456789;
writefile("has_underlay/underlay.mdwn", "t/tmp/underlay", "this page is in an underlay");
-# a directory containing only a transient page shouldn't be indexed
-# (arguably; see [[transient autocreated tagbase is not transient autoindexed]])
+# a directory containing only a transient page is now indexed
+# (see [[transient autocreated tagbase is not transient autoindexed]])
$pagesources{"has_transient/transient"} = "has_transient/transient.mdwn";
$pagemtime{"has_transient/transient"} = 123456789;
$pagectime{"has_transient/transient"} = 123456789;
@@ -117,24 +117,36 @@ ok(! exists $wikistate{autoindex}{autofile}{"has_internal.mdwn"});
ok(! exists $autofiles{"has_internal.mdwn"});
ok(! -f "t/tmp/in/has_internal.mdwn");
-# a directory containing only a page in an underlay shouldn't be indexed
-# (arguably; see [[transient autocreated tagbase is not transient autoindexed]])
+# a directory containing only a page in an underlay is now indexed
+# (see [[transient autocreated tagbase is not transient autoindexed]])
ok(! exists $wikistate{autoindex}{autofile}{"has_underlay.mdwn"});
-ok(! exists $autofiles{"has_underlay.mdwn"});
+is($autofiles{"has_underlay.mdwn"}{plugin}, "autoindex");
+%pages = ();
+@del = ();
+IkiWiki::gen_autofile("has_underlay.mdwn", \%pages, \@del);
+is_deeply(\%pages, {"t/tmp/in/has_underlay" => 1});
+is_deeply(\@del, []);
ok(! -f "t/tmp/in/has_underlay.mdwn");
+ok(-s "t/tmp/in/.ikiwiki/transient/has_underlay.mdwn");
-# a directory containing only a transient page shouldn't be indexed
-# (arguably; see [[transient autocreated tagbase is not transient autoindexed]])
+# a directory containing only a transient page is now indexed
+# (see [[transient autocreated tagbase is not transient autoindexed]])
ok(! exists $wikistate{autoindex}{autofile}{"has_transient.mdwn"});
-ok(! exists $autofiles{"has_transient.mdwn"});
+is($autofiles{"has_transient.mdwn"}{plugin}, "autoindex");
+%pages = ();
+@del = ();
+IkiWiki::gen_autofile("has_transient.mdwn", \%pages, \@del);
+is_deeply(\%pages, {"t/tmp/in/has_transient" => 1});
+is_deeply(\@del, []);
ok(! -f "t/tmp/in/has_transient.mdwn");
+ok(-s "t/tmp/in/.ikiwiki/transient/has_transient.mdwn");
# this page was re-created, but that no longer gets a special case
# (see [[todo/autoindex_should_use_add__95__autofile]]) so it's the same as
# deleted
is($wikistate{autoindex}{autofile}{"reinstated.mdwn"}, 1);
ok(! exists $autofiles{"reinstated.mdwn"});
-ok(! -f "t/tmp/in/reinstated.mdwn");
+ok(! -f "t/tmp/in/.ikiwiki/transient/reinstated.mdwn");
# needs creating (deferred; part of the autofile mechanism now)
ok(! exists $wikistate{autoindex}{autofile}{"tags.mdwn"});