From 4af4d26582f0c2b915d7102fb4a604b176385748 Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Sat, 30 Jan 2010 10:25:10 +0100 Subject: [PATCH 01/14] Make srcfile() return undef, if the file isn't there. This has the advantage that it's now possible to check for the existence of a sourcefile with that function. --- IkiWiki.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index b8e599928..cb1c46a68 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -743,7 +743,10 @@ sub srcfile_stat { } sub srcfile ($;$) { - return (srcfile_stat(@_))[0]; + if (my @stat=srcfile_stat(@_)) { + return $stat[0]; + } + return undef } sub add_underlay ($) { From f3abeac919c4736429bd3362af6edf51ede8e7fe Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Sat, 30 Jan 2010 18:12:01 +0100 Subject: [PATCH 02/14] Code deduplication fin find_src_files() This also has the advantage that I can use the resulting new function elsewhere. --- IkiWiki/Render.pm | 59 ++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 3ebb1a324..44b2fb9c2 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -280,6 +280,27 @@ sub srcdir_check () { } +sub verify_src_file ($$) { + my $file=decode_utf8(shift); + my $dir=shift; + + return if -l $file || -d $file; + $file=~s/^\Q$dir\E\/?//; + return if ! length $file; + my $page = pagename($file); + if (! exists $pagesources{$page} && + file_pruned($file)) { + $File::Find::prune=1; + return; + } + + my ($f) = $file =~ /$config{wiki_file_regexp}/; # untaint + if (! defined $f) { + warn(sprintf(gettext("skipping bad filename %s"), $file)."\n"); + } + return ($file,$page,$f); +} + sub find_src_files () { my @files; my %pages; @@ -288,22 +309,9 @@ sub find_src_files () { find({ no_chdir => 1, wanted => sub { - my $file=decode_utf8($_); - $file=~s/^\Q$config{srcdir}\E\/?//; - return if -l $_ || -d _ || ! length $file; - my $page = pagename($file); - if (! exists $pagesources{$page} && - file_pruned($file)) { - $File::Find::prune=1; - return; - } - - my ($f) = $file =~ /$config{wiki_file_regexp}/; # untaint - if (! defined $f) { - warn(sprintf(gettext("skipping bad filename %s"), $file)."\n"); - } - else { - push @files, $f; + my ($file,$page,$f) = verify_src_file($_,$config{srcdir}); + if ($file) { + push @files, $file; if ($pages{$page}) { debug(sprintf(gettext("%s has multiple possible source pages"), $page)); } @@ -315,24 +323,11 @@ sub find_src_files () { find({ no_chdir => 1, wanted => sub { - my $file=decode_utf8($_); - $file=~s/^\Q$dir\E\/?//; - return if -l $_ || -d _ || ! length $file; - my $page=pagename($file); - if (! exists $pagesources{$page} && - file_pruned($file)) { - $File::Find::prune=1; - return; - } - - my ($f) = $file =~ /$config{wiki_file_regexp}/; # untaint - if (! defined $f) { - warn(sprintf(gettext("skipping bad filename %s"), $file)."\n"); - } - else { + my ($file,$page,$f) = verify_src_file($_,$dir); + if ($f) { # avoid underlaydir override # attacks; see security.mdwn - if (! -l "$config{srcdir}/$f" && + if (! -l "$config{srcdir}/$f" && ! -e _) { if (! $pages{$page}) { push @files, $f; From f35d35abe36166893f68061a1fcb2a26bc056fbc Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Sat, 30 Jan 2010 18:22:32 +0100 Subject: [PATCH 03/14] Automatically create tag pages, if "tag_autocreate=1" is set in the configuration. The pages will be created in tagbase, if and only if they do not exist in the srcdir yet. Tag pages will be create from "autotag.tmpl". At this stage a second refresh is needed for the tag pages to be rendered. Add autotag.tmpl template. --- IkiWiki/Plugin/tag.pm | 26 ++++++++++++++++++++++++++ templates/autotag.tmpl | 3 +++ 2 files changed, 29 insertions(+) create mode 100644 templates/autotag.tmpl diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm index cdcfaf536..6c43a053d 100644 --- a/IkiWiki/Plugin/tag.pm +++ b/IkiWiki/Plugin/tag.pm @@ -36,6 +36,13 @@ sub getsetup () { safe => 1, rebuild => 1, }, + tag_autocreate => { + type => "boolean", + example => 0, + description => "Autocreate new tag pages", + safe => 1, + rebuild => 1, + }, } sub tagpage ($) { @@ -59,6 +66,21 @@ sub taglink ($$$;@) { return htmllink($page, $destpage, tagpage($tag), %opts); } +sub gentag ($) { + my $tag=shift; + if (defined $config{tag_autocreate} && $config{tag_autocreate}) { + my $tagfile = newpagefile(tagpage($tag), $config{default_pageext}); + $tagfile=~s/^\///; + return if (srcfile($tagfile,1)); + + debug(sprintf(gettext("creating tag page %s"), $tag)); + + my $template=template("autotag.tmpl"); + $template->param(tag => $tag); + writefile($tagfile, $config{srcdir}, $template->output); + } +} + sub preprocess_tag (@) { if (! @_) { return ""; @@ -72,6 +94,10 @@ sub preprocess_tag (@) { foreach my $tag (keys %params) { $tag=linkpage($tag); $tags{$page}{$tag}=1; + + # add tagpage if necessary + gentag($tag); + # hidden WikiLink add_link($page, tagpage($tag)); } diff --git a/templates/autotag.tmpl b/templates/autotag.tmpl new file mode 100644 index 000000000..754e0b35b --- /dev/null +++ b/templates/autotag.tmpl @@ -0,0 +1,3 @@ +## Pagest tagged ## + +[[!inline pages="tagged()" actions="no" archive="yes"]] From b18fde2bde0c7d445fd4aab3cd35add8c211aab4 Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Sun, 31 Jan 2010 02:31:12 +0100 Subject: [PATCH 04/14] Add a function add_autofiles(). The objective is to provide a sensible way to let plugins add files during the "scan stage" of the build. Currently does a little verification and adds the file to the global array @add_autofiles. --- IkiWiki.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index cb1c46a68..115c512d3 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -14,7 +14,7 @@ use open qw{:utf8 :std}; use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase %pagestate %wikistate %renderedfiles %oldrenderedfiles %pagesources %destsources %depends %depends_simple %hooks - %forcerebuild %loaded_plugins}; + %forcerebuild %loaded_plugins @autofiles}; use Exporter q{import}; our @EXPORT = qw(hook debug error template htmlpage deptype @@ -1898,6 +1898,14 @@ sub add_link ($$) { unless grep { $_ eq $link } @{$links{$page}}; } +sub add_autofile ($) { + my $addfile=shift; + my ($file,$page) = verify_src_file($addfile,$config{srcdir}); + if ($page) { + push @autofiles, $file; + } +} + sub pagespec_translate ($) { my $spec=shift; From f3c59ed3e52f6e68e73338f6e7799a4de7b6f9d6 Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Sun, 31 Jan 2010 02:23:11 +0100 Subject: [PATCH 05/14] Process files from @autofiles in refresh(). To make automatically added files render they have to be added to the $files, $pages, $new, and $changed variables. After that scan() is called on them. --- IkiWiki/Render.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 44b2fb9c2..dd4d9ca0c 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -642,6 +642,20 @@ sub refresh () { scan($file); } + while (my $autofile = shift (@autofiles)) { + my $page=pagename($autofile); + if ($pages->{$page}) { + debug(sprintf(gettext("%s has multiple possible source pages"), $page)); + } + $pages->{$page}=1; + + push @{$files}, $autofile; + push @{$new}, $autofile if find_new_files([$autofile]); + push @{$changed}, $autofile if find_changed([$autofile]); + + scan($autofile); + } + calculate_links(); remove_del(@$del, @$internal_del); From a8d313aba1094fc6d976c9ba3d09f58b768435c5 Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Sun, 31 Jan 2010 01:12:20 +0100 Subject: [PATCH 06/14] Use add_autofile() in tag.pm to make the automatically created tagpages render. --- IkiWiki/Plugin/tag.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm index 6c43a053d..90833fd9c 100644 --- a/IkiWiki/Plugin/tag.pm +++ b/IkiWiki/Plugin/tag.pm @@ -78,6 +78,8 @@ sub gentag ($) { my $template=template("autotag.tmpl"); $template->param(tag => $tag); writefile($tagfile, $config{srcdir}, $template->output); + + IkiWiki::add_autofile("$config{srcdir}/$tagfile"); } } From f58f3e1bec41ccf9316f37b014ce0b373c8e49e1 Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Tue, 2 Feb 2010 11:01:24 +0100 Subject: [PATCH 07/14] Revert the effects of find_del_files() for (re)autoadded files. This also means that if autoadded files are deleted they will just be recreated. --- IkiWiki.pm | 3 ++- IkiWiki/Render.pm | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 115c512d3..ad9fb7c79 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -14,7 +14,8 @@ use open qw{:utf8 :std}; use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase %pagestate %wikistate %renderedfiles %oldrenderedfiles %pagesources %destsources %depends %depends_simple %hooks - %forcerebuild %loaded_plugins @autofiles}; + %forcerebuild %loaded_plugins @autofiles %dellinks + %delrenderedfiles}; use Exporter q{import}; our @EXPORT = qw(hook debug error template htmlpage deptype diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index dd4d9ca0c..d2fa80fbb 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -392,7 +392,9 @@ sub find_del_files ($) { else { push @del, $pagesources{$page}; } + $dellinks{$page}= $links{$page}; $links{$page}=[]; + $delrenderedfiles{$page}= $renderedfiles{$page}; $renderedfiles{$page}=[]; $pagemtime{$page}=0; } @@ -642,8 +644,14 @@ sub refresh () { scan($file); } + my %del_hash = map {$_, 1} @$del; while (my $autofile = shift (@autofiles)) { my $page=pagename($autofile); + if (exists $del_hash{$page}) { + $links{$page}= $dellinks{$page}; + $renderedfiles{$page}= $delrenderedfiles{$page}; + delete $del_hash{$page}; + } if ($pages->{$page}) { debug(sprintf(gettext("%s has multiple possible source pages"), $page)); } @@ -655,6 +663,7 @@ sub refresh () { scan($autofile); } + $del = [keys %del_hash]; calculate_links(); From 25741100b0a0d81ae5113dfabe5a1ed84cdf8746 Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Tue, 2 Feb 2010 12:12:23 +0100 Subject: [PATCH 08/14] Export add_autofile() for use in Plugins. --- IkiWiki.pm | 2 +- IkiWiki/Plugin/tag.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index ad9fb7c79..7d7f430b3 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -23,7 +23,7 @@ our @EXPORT = qw(hook debug error template htmlpage deptype htmllink readfile writefile pagetype srcfile pagename displaytime will_render gettext urlto targetpage add_underlay pagetitle titlepage linkpage newpagefile - inject add_link + inject add_link add_autofile %config %links %pagestate %wikistate %renderedfiles %pagesources %destsources); our $VERSION = 3.00; # plugin interface version, next is ikiwiki version diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm index 90833fd9c..c0b7feb23 100644 --- a/IkiWiki/Plugin/tag.pm +++ b/IkiWiki/Plugin/tag.pm @@ -79,7 +79,7 @@ sub gentag ($) { $template->param(tag => $tag); writefile($tagfile, $config{srcdir}, $template->output); - IkiWiki::add_autofile("$config{srcdir}/$tagfile"); + add_autofile("$config{srcdir}/$tagfile"); } } From 9330b91703ba245ceb9c36e0682b8cfc0d225eaa Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Tue, 2 Feb 2010 16:29:27 +0100 Subject: [PATCH 09/14] fix typo in autotag.tmpl --- templates/autotag.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/autotag.tmpl b/templates/autotag.tmpl index 754e0b35b..a8824171b 100644 --- a/templates/autotag.tmpl +++ b/templates/autotag.tmpl @@ -1,3 +1,3 @@ -## Pagest tagged ## +## Pages tagged ## [[!inline pages="tagged()" actions="no" archive="yes"]] From bd1e29b8c4d2c2e0329789d1baf0a879617aeee4 Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Wed, 3 Feb 2010 02:35:19 +0100 Subject: [PATCH 10/14] Revert "Make srcfile() return undef, if the file isn't there." This reverts commit 1bde208ec9b915db0187030c33450b5accb4892c. --- IkiWiki.pm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 7d7f430b3..90e623330 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -744,10 +744,7 @@ sub srcfile_stat { } sub srcfile ($;$) { - if (my @stat=srcfile_stat(@_)) { - return $stat[0]; - } - return undef + return (srcfile_stat(@_))[0]; } sub add_underlay ($) { From da5d29f95f6e693e8c14be1b896cf25cf4fdb3c0 Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Wed, 3 Feb 2010 06:57:20 +0100 Subject: [PATCH 11/14] fix bugs in `find_src_files()`. Use `_` to avoid superfluous stat. Check for `defined $file`, instead of just `$file`. Add spaces after commas. Change return values of `verify_src_file()` to not return the tainted filename. Rename `$f` to `$file_untainted in `verify_src_file()`. $f changes to `$file` in `find_src_files()`. This attempts to fix commit f3abeac919c4736429bd3362af6edf51ede8e7fe. For discussion see --- IkiWiki/Render.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index d2fa80fbb..5b72b6de1 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -284,7 +284,7 @@ sub verify_src_file ($$) { my $file=decode_utf8(shift); my $dir=shift; - return if -l $file || -d $file; + return if -l $file || -d _; $file=~s/^\Q$dir\E\/?//; return if ! length $file; my $page = pagename($file); @@ -294,11 +294,11 @@ sub verify_src_file ($$) { return; } - my ($f) = $file =~ /$config{wiki_file_regexp}/; # untaint - if (! defined $f) { + my ($file_untainted) = $file =~ /$config{wiki_file_regexp}/; # untaint + if (! defined $file_untainted) { warn(sprintf(gettext("skipping bad filename %s"), $file)."\n"); } - return ($file,$page,$f); + return ($file_untainted, $page); } sub find_src_files () { @@ -309,8 +309,8 @@ sub find_src_files () { find({ no_chdir => 1, wanted => sub { - my ($file,$page,$f) = verify_src_file($_,$config{srcdir}); - if ($file) { + my ($file, $page) = verify_src_file($_, $config{srcdir}); + if (defined $file) { push @files, $file; if ($pages{$page}) { debug(sprintf(gettext("%s has multiple possible source pages"), $page)); @@ -323,14 +323,14 @@ sub find_src_files () { find({ no_chdir => 1, wanted => sub { - my ($file,$page,$f) = verify_src_file($_,$dir); - if ($f) { + my ($file, $page) = verify_src_file($_, $dir); + if (defined $file) { # avoid underlaydir override # attacks; see security.mdwn - if (! -l "$config{srcdir}/$f" && + if (! -l "$config{srcdir}/$file" && ! -e _) { if (! $pages{$page}) { - push @files, $f; + push @files, $file; $pages{$page}=1; } } From a358d74bef51dae31332ff27e897fe04834571e6 Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Wed, 3 Feb 2010 04:29:10 +0100 Subject: [PATCH 12/14] Check for existence off srcfile in add_autofile add_autofile has to have checks, whether to create the file, anyway, so this will make things more consistent. Correcter check for the result of verify_src_file(). Cosmetic rename of a variable $addfile to $autofile. --- IkiWiki.pm | 11 ++++++++--- IkiWiki/Plugin/tag.pm | 5 ++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 90e623330..56c491339 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1897,9 +1897,14 @@ sub add_link ($$) { } sub add_autofile ($) { - my $addfile=shift; - my ($file,$page) = verify_src_file($addfile,$config{srcdir}); - if ($page) { + my $autofile=shift; + + if (srcfile($autofile, 1)) { + return 0; + } + + my ($file, $page) = verify_src_file("$config{srcdir}/$autofile", $config{srcdir}); + if (defined $file) { push @autofiles, $file; } } diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm index c0b7feb23..c6c99ae45 100644 --- a/IkiWiki/Plugin/tag.pm +++ b/IkiWiki/Plugin/tag.pm @@ -71,15 +71,14 @@ sub gentag ($) { if (defined $config{tag_autocreate} && $config{tag_autocreate}) { my $tagfile = newpagefile(tagpage($tag), $config{default_pageext}); $tagfile=~s/^\///; - return if (srcfile($tagfile,1)); + + return if (! add_autofile($tagfile)); debug(sprintf(gettext("creating tag page %s"), $tag)); my $template=template("autotag.tmpl"); $template->param(tag => $tag); writefile($tagfile, $config{srcdir}, $template->output); - - add_autofile("$config{srcdir}/$tagfile"); } } From 628a52a6c49f5d2fc5af251f2d718c8dff5e8ed5 Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Sat, 3 Apr 2010 21:17:20 +0200 Subject: [PATCH 13/14] Revert "Revert the effects of find_del_files() for (re)autoadded files." This reverts commit 31680111f0062f07727d14fcf291c98978ad5a2f. --- IkiWiki.pm | 3 +-- IkiWiki/Render.pm | 9 --------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 56c491339..1770703a5 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -14,8 +14,7 @@ use open qw{:utf8 :std}; use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase %pagestate %wikistate %renderedfiles %oldrenderedfiles %pagesources %destsources %depends %depends_simple %hooks - %forcerebuild %loaded_plugins @autofiles %dellinks - %delrenderedfiles}; + %forcerebuild %loaded_plugins @autofiles}; use Exporter q{import}; our @EXPORT = qw(hook debug error template htmlpage deptype diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 5b72b6de1..fc71c8919 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -392,9 +392,7 @@ sub find_del_files ($) { else { push @del, $pagesources{$page}; } - $dellinks{$page}= $links{$page}; $links{$page}=[]; - $delrenderedfiles{$page}= $renderedfiles{$page}; $renderedfiles{$page}=[]; $pagemtime{$page}=0; } @@ -644,14 +642,8 @@ sub refresh () { scan($file); } - my %del_hash = map {$_, 1} @$del; while (my $autofile = shift (@autofiles)) { my $page=pagename($autofile); - if (exists $del_hash{$page}) { - $links{$page}= $dellinks{$page}; - $renderedfiles{$page}= $delrenderedfiles{$page}; - delete $del_hash{$page}; - } if ($pages->{$page}) { debug(sprintf(gettext("%s has multiple possible source pages"), $page)); } @@ -663,7 +655,6 @@ sub refresh () { scan($autofile); } - $del = [keys %del_hash]; calculate_links(); From 981400177d68a279f485727be3f013e68f0bf691 Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Sat, 3 Apr 2010 21:10:16 +0200 Subject: [PATCH 14/14] Make sure deleted tag pages don't get recreated. The reason to do this is basically a user interaction design decision. It is achieved by adding an entry, associated to the creating plugin, to %pagestate. To find out if files were deleted a new global hash %del_hash is %introduced. --- IkiWiki.pm | 19 +++++++++++++++---- IkiWiki/Plugin/tag.pm | 2 +- IkiWiki/Render.pm | 5 ++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 1770703a5..966a3bbc6 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -14,7 +14,7 @@ use open qw{:utf8 :std}; use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase %pagestate %wikistate %renderedfiles %oldrenderedfiles %pagesources %destsources %depends %depends_simple %hooks - %forcerebuild %loaded_plugins @autofiles}; + %forcerebuild %loaded_plugins %autofiles %del_hash}; use Exporter q{import}; our @EXPORT = qw(hook debug error template htmlpage deptype @@ -1895,17 +1895,28 @@ sub add_link ($$) { unless grep { $_ eq $link } @{$links{$page}}; } -sub add_autofile ($) { +sub add_autofile ($$) { my $autofile=shift; + my $plugin=shift; if (srcfile($autofile, 1)) { return 0; } my ($file, $page) = verify_src_file("$config{srcdir}/$autofile", $config{srcdir}); - if (defined $file) { - push @autofiles, $file; + + if ((!defined $file) || + (exists $pagestate{$page}{$plugin}{autofile_deleted})) { + return 0; } + + if (exists $del_hash{$file}) { + $pagestate{$page}{$plugin}{autofile_deleted}=1; + return 0; + } + + $autofiles{$file}=$plugin; + return 1; } sub pagespec_translate ($) { diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm index c6c99ae45..fdd63d637 100644 --- a/IkiWiki/Plugin/tag.pm +++ b/IkiWiki/Plugin/tag.pm @@ -72,7 +72,7 @@ sub gentag ($) { my $tagfile = newpagefile(tagpage($tag), $config{default_pageext}); $tagfile=~s/^\///; - return if (! add_autofile($tagfile)); + return if (! add_autofile($tagfile, "tag")); debug(sprintf(gettext("creating tag page %s"), $tag)); diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index fc71c8919..0c21455fb 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -637,12 +637,14 @@ sub refresh () { my ($changed, $internal_changed)=find_changed($files); run_hooks(needsbuild => sub { shift->($changed) }); my $oldlink_targets=calculate_old_links($changed, $del); + %del_hash = map { $_ => 1 } @{$del}; foreach my $file (@$changed) { scan($file); } - while (my $autofile = shift (@autofiles)) { + while (my $autofile = shift @{[keys %autofiles]}) { + my $plugin=$autofiles{$autofile}; my $page=pagename($autofile); if ($pages->{$page}) { debug(sprintf(gettext("%s has multiple possible source pages"), $page)); @@ -654,6 +656,7 @@ sub refresh () { push @{$changed}, $autofile if find_changed([$autofile]); scan($autofile); + delete $autofiles{$autofile}; } calculate_links();