From 4ce73f2d88e9a177ad84e19b48a17b2d604a808b Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@gnu.kitenet.net>
Date: Tue, 6 Jan 2009 15:35:53 -0500
Subject: [PATCH] table: Find links in external files in scan pass.

---
 IkiWiki/Plugin/table.pm                 | 22 ++++++++++++++++++++--
 debian/changelog                        |  1 +
 doc/bugs/table_external_file_links.mdwn |  2 ++
 docwiki.setup                           |  2 ++
 po/ikiwiki.pot                          |  2 +-
 5 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/IkiWiki/Plugin/table.pm b/IkiWiki/Plugin/table.pm
index dd124929d..96d63f455 100644
--- a/IkiWiki/Plugin/table.pm
+++ b/IkiWiki/Plugin/table.pm
@@ -8,7 +8,7 @@ use IkiWiki 3.00;
 
 sub import {
 	hook(type => "getsetup", id => "table", call => \&getsetup);
-	hook(type => "preprocess", id => "table", call => \&preprocess);
+	hook(type => "preprocess", id => "table", call => \&preprocess, scan => 1);
 }
 
 sub getsetup () {
@@ -27,13 +27,31 @@ sub preprocess (@) {
 	);
 
 	if (exists $params{file}) {
-		if (! $pagesources{$params{file}}) {
+		if (! exists $pagesources{$params{file}}) {
 			error gettext("cannot find file");
 		}
 		$params{data} = readfile(srcfile($params{file}));
 		add_depends($params{page}, $params{file});
 	}
 
+	if (! defined wantarray) {
+		# scan mode --	if the table uses an external file, need to
+		# scan that file too.
+		return unless exists $params{file};
+
+		IkiWiki::run_hooks(scan => sub {
+			shift->(
+				page => $params{page},
+				content => $params{data},
+			);
+		});
+
+		# Preprocess in scan-only mode.
+		IkiWiki::preprocess($params{page}, $params{page}, $params{data}, 1);
+
+		return;
+	}
+
 	if (lc $params{format} eq 'auto') {
 		# first try the more simple format
 		if (is_dsv_data($params{data})) {
diff --git a/debian/changelog b/debian/changelog
index bf47fda04..e79ad04cc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 ikiwiki (3.02) UNRELEASED; urgency=low
 
   * table: Fix misparsed links in external files.
+  * table: Find links in external files in scan pass.
 
  -- Joey Hess <joeyh@debian.org>  Tue, 06 Jan 2009 15:02:52 -0500
 
diff --git a/doc/bugs/table_external_file_links.mdwn b/doc/bugs/table_external_file_links.mdwn
index f86808c77..7b35383c5 100644
--- a/doc/bugs/table_external_file_links.mdwn
+++ b/doc/bugs/table_external_file_links.mdwn
@@ -5,3 +5,5 @@ table when the pages the links point to change (are added, removed, etc).
 There seem only two solutions to that bug -- either really make wikilinks
 in an external table file not work (probably by escaping them), 
 or run the preprocess code also in scan (expensive!). --[[Joey]]
+
+[[done]]
diff --git a/docwiki.setup b/docwiki.setup
index 6d732fd6b..ffb4a7c16 100644
--- a/docwiki.setup
+++ b/docwiki.setup
@@ -15,5 +15,7 @@ use IkiWiki::Setup::Standard {
 	userdir => "users",
 	usedirs => 0,
 	prefix_directives => 1,
+	cgiurl => "http://me",
+	url => "http://me",
 	add_plugins => [qw{goodstuff version haiku polygen fortune}],
 }
diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot
index 560a5b2a1..957c9eea3 100644
--- a/po/ikiwiki.pot
+++ b/po/ikiwiki.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-01-05 18:53-0500\n"
+"POT-Creation-Date: 2009-01-06 14:31-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
-- 
2.39.5