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.master
parent
628a52a6c4
commit
981400177d
19
IkiWiki.pm
19
IkiWiki.pm
|
@ -14,7 +14,7 @@ use open qw{:utf8 :std};
|
||||||
use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase
|
use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase
|
||||||
%pagestate %wikistate %renderedfiles %oldrenderedfiles
|
%pagestate %wikistate %renderedfiles %oldrenderedfiles
|
||||||
%pagesources %destsources %depends %depends_simple %hooks
|
%pagesources %destsources %depends %depends_simple %hooks
|
||||||
%forcerebuild %loaded_plugins @autofiles};
|
%forcerebuild %loaded_plugins %autofiles %del_hash};
|
||||||
|
|
||||||
use Exporter q{import};
|
use Exporter q{import};
|
||||||
our @EXPORT = qw(hook debug error template htmlpage deptype
|
our @EXPORT = qw(hook debug error template htmlpage deptype
|
||||||
|
@ -1895,17 +1895,28 @@ sub add_link ($$) {
|
||||||
unless grep { $_ eq $link } @{$links{$page}};
|
unless grep { $_ eq $link } @{$links{$page}};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_autofile ($) {
|
sub add_autofile ($$) {
|
||||||
my $autofile=shift;
|
my $autofile=shift;
|
||||||
|
my $plugin=shift;
|
||||||
|
|
||||||
if (srcfile($autofile, 1)) {
|
if (srcfile($autofile, 1)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
my ($file, $page) = verify_src_file("$config{srcdir}/$autofile", $config{srcdir});
|
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 ($) {
|
sub pagespec_translate ($) {
|
||||||
|
|
|
@ -72,7 +72,7 @@ sub gentag ($) {
|
||||||
my $tagfile = newpagefile(tagpage($tag), $config{default_pageext});
|
my $tagfile = newpagefile(tagpage($tag), $config{default_pageext});
|
||||||
$tagfile=~s/^\///;
|
$tagfile=~s/^\///;
|
||||||
|
|
||||||
return if (! add_autofile($tagfile));
|
return if (! add_autofile($tagfile, "tag"));
|
||||||
|
|
||||||
debug(sprintf(gettext("creating tag page %s"), $tag));
|
debug(sprintf(gettext("creating tag page %s"), $tag));
|
||||||
|
|
||||||
|
|
|
@ -637,12 +637,14 @@ sub refresh () {
|
||||||
my ($changed, $internal_changed)=find_changed($files);
|
my ($changed, $internal_changed)=find_changed($files);
|
||||||
run_hooks(needsbuild => sub { shift->($changed) });
|
run_hooks(needsbuild => sub { shift->($changed) });
|
||||||
my $oldlink_targets=calculate_old_links($changed, $del);
|
my $oldlink_targets=calculate_old_links($changed, $del);
|
||||||
|
%del_hash = map { $_ => 1 } @{$del};
|
||||||
|
|
||||||
foreach my $file (@$changed) {
|
foreach my $file (@$changed) {
|
||||||
scan($file);
|
scan($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (my $autofile = shift (@autofiles)) {
|
while (my $autofile = shift @{[keys %autofiles]}) {
|
||||||
|
my $plugin=$autofiles{$autofile};
|
||||||
my $page=pagename($autofile);
|
my $page=pagename($autofile);
|
||||||
if ($pages->{$page}) {
|
if ($pages->{$page}) {
|
||||||
debug(sprintf(gettext("%s has multiple possible source 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]);
|
push @{$changed}, $autofile if find_changed([$autofile]);
|
||||||
|
|
||||||
scan($autofile);
|
scan($autofile);
|
||||||
|
delete $autofiles{$autofile};
|
||||||
}
|
}
|
||||||
|
|
||||||
calculate_links();
|
calculate_links();
|
||||||
|
|
Loading…
Reference in New Issue