From b18fde2bde0c7d445fd4aab3cd35add8c211aab4 Mon Sep 17 00:00:00 2001
From: David Riebenbauer <davrieb@liegesta.at>
Date: Sun, 31 Jan 2010 02:31:12 +0100
Subject: 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;
 
-- 
cgit v1.2.3