From: Joey Hess <joey@kitenet.net>
Date: Sun, 25 Apr 2010 00:22:20 +0000 (-0400)
Subject: add support for mass dependencies
X-Git-Tag: 3.20100427~18
X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/ca9c6cc254d934837406ef9bb0dc5d021983661b?hp=--cc

add support for mass dependencies

Registered by passing "" as page name to add_depends.
---

ca9c6cc254d934837406ef9bb0dc5d021983661b
diff --git a/IkiWiki.pm b/IkiWiki.pm
index c2cadd35f..0ac49ade9 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -13,8 +13,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 %typedlinks %oldtypedlinks
+	%pagesources %destsources %depends %depends_simple @mass_depends 
+	%hooks %forcerebuild %loaded_plugins %typedlinks %oldtypedlinks
 	%autofiles};
 
 use Exporter q{import};
diff --git a/IkiWiki/Plugin/google.pm b/IkiWiki/Plugin/google.pm
index 68cb16513..529a2c801 100644
--- a/IkiWiki/Plugin/google.pm
+++ b/IkiWiki/Plugin/google.pm
@@ -25,6 +25,10 @@ sub checkconfig () {
 	if (! length $config{url}) {
 		error(sprintf(gettext("Must specify %s when using the %s plugin"), "url", 'google'));
 	}
+	
+	# This is a mass dependency, so if the search form template
+	# changes, every page is rebuilt.
+	add_depends("", "googleform.tmpl");
 }
 
 my $form;
@@ -36,7 +40,7 @@ sub pagetemplate (@) {
 	# Add search box to page header.
 	if ($template->query(name => "searchform")) {
 		if (! defined $form) {
-			my $searchform = template_depends("googleform.tmpl", $page, blind_cache => 1);
+			my $searchform = template("googleform.tmpl", blind_cache => 1);
 			$searchform->param(url => $config{url});
 			$form=$searchform->output;
 		}
diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm
index 55edf8752..c9a69f443 100644
--- a/IkiWiki/Plugin/search.pm
+++ b/IkiWiki/Plugin/search.pm
@@ -41,6 +41,10 @@ sub checkconfig () {
 	if (! defined $config{omega_cgi}) {
 		$config{omega_cgi}="/usr/lib/cgi-bin/omega/omega";
 	}
+
+	# This is a mass dependency, so if the search form template
+	# changes, every page is rebuilt.
+	add_depends("", "searchform.tmpl");
 }
 
 my $form;
@@ -52,7 +56,7 @@ sub pagetemplate (@) {
 	# Add search box to page header.
 	if ($template->query(name => "searchform")) {
 		if (! defined $form) {
-			my $searchform = template_depends("searchform.tmpl", $page, blind_cache => 1);
+			my $searchform = template("searchform.tmpl", blind_cache => 1);
 			$searchform->param(searchaction => $config{cgiurl});
 			$form=$searchform->output;
 		}
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 8ae0cbd4f..50af2bdec 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -591,13 +591,18 @@ sub render_dependent ($$$$$$$) {
 	
 	my %lc_changed = map { lc(pagename($_)) => 1 } @changed;
 	my %lc_exists_changed = map { lc(pagename($_)) => 1 } @exists_changed;
+
+	my $mass_reason;
+	foreach my $p ("page.tmpl", keys %{$depends_simple{""}}) {
+		$mass_reason=$p if $rendered{$p};
+	}
 	 
 	foreach my $f (@$files) {
 		next if $rendered{$f};
 		my $p=pagename($f);
-		my $reason = undef;
-	
-		if (exists $depends_simple{$p}) {
+		my $reason = $mass_reason;
+
+		if (exists $depends_simple{$p} && ! defined $reason) {
 			foreach my $d (keys %{$depends_simple{$p}}) {
 				if (($depends_simple{$p}{$d} & $IkiWiki::DEPEND_CONTENT &&
 				     $lc_changed{$d})
@@ -771,13 +776,7 @@ sub refresh () {
 		render_linkers($file);
 	}
 
-	if ($rendered{"templates/page.tmpl"}) {
-		foreach my $f (@$files) {
-			next if $f eq "templates/page.tmpl";
-			render($f, sprintf(gettext("building %s, which depends on %s"), $f, "templates/page.tmpl"));
-		}
-	}
-	elsif (@$changed || @$internal_changed ||
+	if (@$changed || @$internal_changed ||
 	    @$del || @$internal_del || @$internal_new) {
 		1 while render_dependent($files, $new, $internal_new,
 			$del, $internal_del, $internal_changed,