From b7d50abc0f3dbe99d2a3664c12ea95d24bfcf04b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 17 Apr 2010 13:35:15 -0400 Subject: refactor autofiles Made add_autofile take a generator function, and just register the autofile, for later possible creation. The testing is moved into Render, which allows cleaning up some stuff. --- IkiWiki.pm | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) (limited to 'IkiWiki.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 3812961dc..c22c75df8 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -15,7 +15,7 @@ use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase %pagestate %wikistate %renderedfiles %oldrenderedfiles %pagesources %destsources %depends %depends_simple %hooks %forcerebuild %loaded_plugins %typedlinks %oldtypedlinks - %autofiles %del_hash}; + %autofiles}; use Exporter q{import}; our @EXPORT = qw(hook debug error template htmlpage deptype @@ -1956,6 +1956,15 @@ sub add_link ($$;$) { } } +sub add_autofile ($$$) { + my $file=shift; + my $plugin=shift; + my $generator=shift; + + $autofiles{$file}{plugin}=$plugin; + $autofiles{$file}{generator}=$generator; +} + sub sortspec_translate ($$) { my $spec = shift; my $reverse = shift; @@ -2021,30 +2030,6 @@ sub sortspec_translate ($$) { return eval 'sub { '.$code.' }'; } -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) || - (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 ($) { my $spec=shift; -- cgit v1.2.3