summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki.pm53
-rw-r--r--IkiWiki/Plugin/brokenlinks.pm4
-rw-r--r--IkiWiki/Plugin/calendar.pm21
-rw-r--r--IkiWiki/Plugin/edittemplate.pm2
-rw-r--r--IkiWiki/Plugin/inline.pm7
-rw-r--r--IkiWiki/Plugin/linkmap.pm4
-rw-r--r--IkiWiki/Plugin/listdirectives.pm2
-rw-r--r--IkiWiki/Plugin/map.pm8
-rw-r--r--IkiWiki/Plugin/meta.pm2
-rw-r--r--IkiWiki/Plugin/orphans.pm4
-rw-r--r--IkiWiki/Plugin/pagecount.pm4
-rw-r--r--IkiWiki/Plugin/postsparkline.pm2
-rw-r--r--IkiWiki/Plugin/progress.pm4
-rw-r--r--IkiWiki/Render.pm113
-rw-r--r--debian/changelog10
-rw-r--r--doc/plugins/sidebar.mdwn8
-rw-r--r--doc/plugins/write.mdwn12
-rwxr-xr-xikiwiki-transition2
18 files changed, 174 insertions, 88 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 97d84c9de..9591a8160 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -28,6 +28,10 @@ our $VERSION = 3.00; # plugin interface version, next is ikiwiki version
our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
our $installdir='/usr'; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE
+# Page dependency types.
+our $DEPEND_CONTENT=1;
+our $DEPEND_PRESENCE=2;
+
# Optimisation.
use Memoize;
memoize("abs2rel");
@@ -1524,18 +1528,28 @@ sub loadindex () {
$links{$page}=$d->{links};
$oldlinks{$page}=[@{$d->{links}}];
}
- if (exists $d->{depends_simple}) {
+ if (ref $d->{depends_simple} eq 'ARRAY') {
+ # old format
$depends_simple{$page}={
map { $_ => 1 } @{$d->{depends_simple}}
};
}
+ elsif (exists $d->{depends_simple}) {
+ $depends{$page}=$d->{depends_simple};
+ }
if (exists $d->{dependslist}) {
+ # old format
$depends{$page}={
- map { $_ => 1 } @{$d->{dependslist}}
+ map { $_ => $DEPEND_CONTENT }
+ @{$d->{dependslist}}
};
}
+ elsif (exists $d->{depends} && ! ref $d->{depends}) {
+ # old format
+ $depends{$page}={$d->{depends} => $DEPEND_CONTENT };
+ }
elsif (exists $d->{depends}) {
- $depends{$page}={$d->{depends} => 1};
+ $depends{$page}=$d->{depends};
}
if (exists $d->{state}) {
$pagestate{$page}=$d->{state};
@@ -1581,11 +1595,11 @@ sub saveindex () {
};
if (exists $depends{$page}) {
- $index{page}{$src}{dependslist} = [ keys %{$depends{$page}} ];
+ $index{page}{$src}{depends} = $depends{$page};
}
if (exists $depends_simple{$page}) {
- $index{page}{$src}{depends_simple} = [ keys %{$depends_simple{$page}} ];
+ $index{page}{$src}{depends_simple} = $depends_simple{$page};
}
if (exists $pagestate{$page}) {
@@ -1753,20 +1767,37 @@ sub rcs_receive () {
$hooks{rcs}{rcs_receive}{call}->();
}
-sub add_depends ($$) {
+sub add_depends ($$;@) {
my $page=shift;
my $pagespec=shift;
- if ($pagespec =~ /$config{wiki_file_regexp}/ &&
- $pagespec !~ /[\s*?()!]/) {
- # a simple dependency, which can be matched by string eq
- $depends_simple{$page}{lc $pagespec} = 1;
+ # Is the pagespec a simple page name?
+ my $simple=$pagespec =~ /$config{wiki_file_regexp}/ &&
+ $pagespec !~ /[\s*?()!]/;
+
+ my $deptype=$DEPEND_CONTENT;
+ if (@_) {
+ my %params=@_;
+
+ # Is the pagespec limited to terms that will continue
+ # to match pages as long as those pages exist?
+ my $limited=1;
+ while ($limited && $pagespec=~m/(\w+)\([^\)]*\)/g) {
+ $limited = $1 =~ /^(glob|internal|creation_month|creation_day|creation_year|created_before|created_after)$/;
+ }
+
+ $deptype=$deptype & ~$DEPEND_CONTENT & $DEPEND_PRESENCE
+ if $params{presence} && $limited;
+ }
+
+ if ($simple) {
+ $depends_simple{$page}{lc $pagespec} |= $deptype;
return 1;
}
return unless pagespec_valid($pagespec);
- $depends{$page}{$pagespec} = 1;
+ $depends{$page}{$pagespec} |= $deptype;
return 1;
}
diff --git a/IkiWiki/Plugin/brokenlinks.pm b/IkiWiki/Plugin/brokenlinks.pm
index eb698b0be..b8ed2b8de 100644
--- a/IkiWiki/Plugin/brokenlinks.pm
+++ b/IkiWiki/Plugin/brokenlinks.pm
@@ -23,8 +23,8 @@ sub preprocess (@) {
my %params=@_;
$params{pages}="*" unless defined $params{pages};
- # Needs to update whenever a page is added or removed, so
- # register a dependency.
+ # Needs to update whenever a page is changed,
+ # added or removed, in order to see the link changes.
add_depends($params{page}, $params{pages});
my @broken;
diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm
index 5d16dff75..a1117992a 100644
--- a/IkiWiki/Plugin/calendar.pm
+++ b/IkiWiki/Plugin/calendar.pm
@@ -104,19 +104,22 @@ sub format_month (@) {
"$archivebase/$year/".sprintf("%02d", $month),
linktext => " $monthname ");
}
- add_depends($params{page}, "$archivebase/$year/".sprintf("%02d", $month));
+ add_depends($params{page}, "$archivebase/$year/".sprintf("%02d", $month),
+ presence => 1);
if (exists $cache{$pagespec}{"$pyear/$pmonth"}) {
$purl = htmllink($params{page}, $params{destpage},
"$archivebase/$pyear/" . sprintf("%02d", $pmonth),
linktext => " $pmonthname ");
}
- add_depends($params{page}, "$archivebase/$pyear/".sprintf("%02d", $pmonth));
+ add_depends($params{page}, "$archivebase/$pyear/".sprintf("%02d", $pmonth),
+ presence => 1);
if (exists $cache{$pagespec}{"$nyear/$nmonth"}) {
$nurl = htmllink($params{page}, $params{destpage},
"$archivebase/$nyear/" . sprintf("%02d", $nmonth),
linktext => " $nmonthname ");
}
- add_depends($params{page}, "$archivebase/$nyear/".sprintf("%02d", $nmonth));
+ add_depends($params{page}, "$archivebase/$nyear/".sprintf("%02d", $nmonth),
+ presence => 1);
# Start producing the month calendar
$calendar=<<EOF;
@@ -209,11 +212,11 @@ EOF
# Add dependencies to update the calendar whenever pages
# matching the pagespec are added or removed.
- add_depends($params{page}, $params{pages});
+ add_depends($params{page}, $params{pages}, presence => 1);
# Explicitly add all currently linked pages as dependencies, so
# that if they are removed, the calendar will be sure to be updated.
foreach my $p (@list) {
- add_depends($params{page}, $p);
+ add_depends($params{page}, $p, presence => 1);
}
return $calendar;
@@ -246,19 +249,19 @@ sub format_year (@) {
"$archivebase/$year",
linktext => "$year");
}
- add_depends($params{page}, "$archivebase/$year");
+ add_depends($params{page}, "$archivebase/$year", presence => 1);
if (exists $cache{$pagespec}{"$pyear"}) {
$purl = htmllink($params{page}, $params{destpage},
"$archivebase/$pyear",
linktext => "\&larr;");
}
- add_depends($params{page}, "$archivebase/$pyear");
+ add_depends($params{page}, "$archivebase/$pyear", presence => 1);
if (exists $cache{$pagespec}{"$nyear"}) {
$nurl = htmllink($params{page}, $params{destpage},
"$archivebase/$nyear",
linktext => "\&rarr;");
}
- add_depends($params{page}, "$archivebase/$nyear");
+ add_depends($params{page}, "$archivebase/$nyear", presence => 1);
# Start producing the year calendar
$calendar=<<EOF;
@@ -310,7 +313,7 @@ EOF
else {
$calendar.=qq{\t<td class="$tag">$monthabbr</td>\n};
}
- add_depends($params{page}, "$archivebase/$year/$mtag");
+ add_depends($params{page}, "$archivebase/$year/$mtag", presence => 1);
$calendar.=qq{\t</tr>\n} if ($month % $params{months_per_row} == 0);
}
diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm
index 0bafc95d0..2dd1dbe68 100644
--- a/IkiWiki/Plugin/edittemplate.pm
+++ b/IkiWiki/Plugin/edittemplate.pm
@@ -58,7 +58,7 @@ sub preprocess (@) {
$pagestate{$params{page}}{edittemplate}{$params{match}}=$link;
return "" if ($params{silent} && IkiWiki::yesno($params{silent}));
- add_depends($params{page}, $link);
+ add_depends($params{page}, $link, presence => 1);
return sprintf(gettext("edittemplate %s registered for %s"),
htmllink($params{page}, $params{destpage}, $link),
$params{match});
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index ccfadfd69..5133c4ba6 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -197,7 +197,7 @@ sub preprocess_inline (@) {
split ' ', $params{pagenames};
}
else {
- add_depends($params{page}, $params{pages});
+ add_depends($params{page}, $params{pages}, content => ! $quick);
@list = pagespec_match_list(
[ grep { $_ ne $params{page} } keys %pagesources ],
@@ -248,10 +248,9 @@ sub preprocess_inline (@) {
}
# Explicitly add all currently displayed pages as dependencies, so
- # that if they are removed or otherwise changed, the inline will be
- # sure to be updated.
+ # that if they are removed, the inline will be sure to be updated.
foreach my $p ($#list >= $#feedlist ? @list : @feedlist) {
- add_depends($params{page}, $p);
+ add_depends($params{page}, $p, content => ! $quick);
}
if ($feeds && exists $params{feedpages}) {
diff --git a/IkiWiki/Plugin/linkmap.pm b/IkiWiki/Plugin/linkmap.pm
index 941ed5f36..d0671ae0e 100644
--- a/IkiWiki/Plugin/linkmap.pm
+++ b/IkiWiki/Plugin/linkmap.pm
@@ -28,8 +28,8 @@ sub preprocess (@) {
$params{pages}="*" unless defined $params{pages};
- # Needs to update whenever a page is added or removed, so
- # register a dependency.
+ # Needs to update whenever a page is added, removed, or
+ # its links change, so register a dependency.
add_depends($params{page}, $params{pages});
# Can't just return the linkmap here, since the htmlscrubber
diff --git a/IkiWiki/Plugin/listdirectives.pm b/IkiWiki/Plugin/listdirectives.pm
index bd73f1a04..4023ed7d7 100644
--- a/IkiWiki/Plugin/listdirectives.pm
+++ b/IkiWiki/Plugin/listdirectives.pm
@@ -84,7 +84,7 @@ sub preprocess (@) {
foreach my $plugin (@pluginlist) {
$result .= '<li class="listdirectives">';
my $link=linkpage($config{directive_description_dir}."/".$plugin);
- add_depends($params{page}, $link);
+ add_depends($params{page}, $link, presence => 1);
$result .= htmllink($params{page}, $params{destpage}, $link);
$result .= '</li>';
}
diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm
index 54146dc46..682960777 100644
--- a/IkiWiki/Plugin/map.pm
+++ b/IkiWiki/Plugin/map.pm
@@ -68,13 +68,13 @@ sub preprocess (@) {
}
# Needs to update whenever a page is added or removed (or in some
- # cases, when its content changes, if show=title), so register a
- # dependency.
- add_depends($params{page}, $params{pages});
+ # cases, when its content changes, if show= is specified), so
+ # register a dependency.
+ add_depends($params{page}, $params{pages}, content => exists $params{show});
# Explicitly add all currently shown pages, to detect when pages
# are removed.
foreach my $item (keys %mapitems) {
- add_depends($params{page}, $item);
+ add_depends($params{page}, $item, content => exists $params{show});
}
# Create the map.
diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
index 514b09369..9b041a748 100644
--- a/IkiWiki/Plugin/meta.pm
+++ b/IkiWiki/Plugin/meta.pm
@@ -195,7 +195,7 @@ sub preprocess (@) {
if (! length $link) {
error gettext("redir page not found")
}
- add_depends($page, $link);
+ add_depends($page, $link, presence => 1);
$value=urlto($link, $page);
$value.='#'.$redir_anchor if defined $redir_anchor;
diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm
index 711226772..d981670e7 100644
--- a/IkiWiki/Plugin/orphans.pm
+++ b/IkiWiki/Plugin/orphans.pm
@@ -23,8 +23,8 @@ sub preprocess (@) {
my %params=@_;
$params{pages}="*" unless defined $params{pages};
- # Needs to update whenever a page is added or removed, so
- # register a dependency.
+ # Needs to update whenever a page is changed, added, or removed,
+ # in order to see the link changes.
add_depends($params{page}, $params{pages});
my @orphans;
diff --git a/IkiWiki/Plugin/pagecount.pm b/IkiWiki/Plugin/pagecount.pm
index 5a2301af4..80561350b 100644
--- a/IkiWiki/Plugin/pagecount.pm
+++ b/IkiWiki/Plugin/pagecount.pm
@@ -23,8 +23,8 @@ sub preprocess (@) {
$params{pages}="*" unless defined $params{pages};
# Needs to update count whenever a page is added or removed, so
- # register a dependency.
- add_depends($params{page}, $params{pages});
+ # register a presence dependency.
+ add_depends($params{page}, $params{pages}, presence => 1);
my @pages;
if ($params{pages} eq "*") {
diff --git a/IkiWiki/Plugin/postsparkline.pm b/IkiWiki/Plugin/postsparkline.pm
index d2e5c2378..3205958d4 100644
--- a/IkiWiki/Plugin/postsparkline.pm
+++ b/IkiWiki/Plugin/postsparkline.pm
@@ -48,7 +48,7 @@ sub preprocess (@) {
error gettext("unknown formula");
}
- add_depends($params{page}, $params{pages});
+ add_depends($params{page}, $params{pages}, presence => 1);
my @list=sort { $params{timehash}->{$b} <=> $params{timehash}->{$a} }
pagespec_match_list(
diff --git a/IkiWiki/Plugin/progress.pm b/IkiWiki/Plugin/progress.pm
index 76d994acc..26c537a84 100644
--- a/IkiWiki/Plugin/progress.pm
+++ b/IkiWiki/Plugin/progress.pm
@@ -36,8 +36,8 @@ sub preprocess (@) {
$fill.="%";
}
elsif (defined $params{totalpages} and defined $params{donepages}) {
- add_depends($params{page}, $params{totalpages});
- add_depends($params{page}, $params{donepages});
+ add_depends($params{page}, $params{totalpages}, presence => 1);
+ add_depends($params{page}, $params{donepages}, presence => 1);
my @pages=keys %pagesources;
my $totalcount=0;
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 246c2260d..cf0c3fe08 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -342,7 +342,7 @@ sub refresh () {
run_hooks(refresh => sub { shift->() });
my ($files, $exists)=find_src_files();
- my (%rendered, @add, @del, @internal);
+ my (%rendered, @add, @del, @internal, @internal_change);
# check for added or removed pages
foreach my $file (@$files) {
my $page=pagename($file);
@@ -407,7 +407,7 @@ sub refresh () {
$forcerebuild{$page}) {
$pagemtime{$page}=$stat[9];
if (isinternal($page)) {
- push @internal, $file;
+ push @internal_change, $file;
# Preprocess internal page in scan-only mode.
preprocess($page, $page, readfile($srcfile), 1);
}
@@ -429,7 +429,7 @@ sub refresh () {
render($file);
$rendered{$file}=1;
}
- foreach my $file (@internal) {
+ foreach my $file (@internal, @internal_change) {
# internal pages are not rendered
my $page=pagename($file);
delete $depends{$page};
@@ -454,51 +454,80 @@ sub refresh () {
}
}
- if (%rendered || @del || @internal) {
- my @changed=(keys %rendered, @del);
-
- my %lcchanged = map { lc(pagename($_)) => 1 } @changed;
-
- # rebuild dependant pages
- foreach my $f (@$files) {
- next if $rendered{$f};
- my $p=pagename($f);
- my $reason = undef;
-
- if (exists $depends_simple{$p}) {
- foreach my $d (keys %{$depends_simple{$p}}) {
- if (exists $lcchanged{$d}) {
- $reason = $d;
- last;
+ if (%rendered || @del || @internal || @internal_change) {
+ my @changed;
+ my $changes;
+ do {
+ $changes=0;
+ @changed=(keys %rendered, @del);
+ my @exists_changed=(@add, @del);
+
+ my %lc_changed = map { lc(pagename($_)) => 1 } @changed;
+ my %lc_exists_changed = map { lc(pagename($_)) => 1 } @exists_changed;
+
+ # rebuild dependant pages
+ foreach my $f (@$files) {
+ next if $rendered{$f};
+ my $p=pagename($f);
+ my $reason = undef;
+
+ if (exists $depends_simple{$p}) {
+ foreach my $d (keys %{$depends_simple{$p}}) {
+ if (($depends_simple{$p}{$d} & $IkiWiki::DEPEND_CONTENT &&
+ exists $lc_changed{$d})
+ ||
+ ($depends_simple{$p}{$d} & $IkiWiki::DEPEND_PRESENCE &&
+ exists $lc_exists_changed{$d})) {
+ $reason = $d;
+ last;
+ }
}
}
- }
-
- if (exists $depends{$p} && ! defined $reason) {
- D: foreach my $d (keys %{$depends{$p}}) {
- my $sub=pagespec_translate($d);
- next if $@ || ! defined $sub;
-
- # only consider internal files
- # if the page explicitly depends
- # on such files
- foreach my $file (@changed, $d =~ /internal\(/ ? @internal : ()) {
- next if $file eq $f;
- my $page=pagename($file);
- if ($sub->($page, location => $p)) {
- $reason = $page;
- last D;
+
+ if (exists $depends{$p} && ! defined $reason) {
+ D: foreach my $d (keys %{$depends{$p}}) {
+ my $sub=pagespec_translate($d);
+ next if $@ || ! defined $sub;
+
+ my @candidates;
+ if ($depends_simple{$p}{$d} & $IkiWiki::DEPEND_CONTENT) {
+ @candidates=@changed;
+ }
+ elsif ($depends{$p}{$d} & $IkiWiki::DEPEND_PRESENCE) {
+ @candidates=@exists_changed;
+ }
+ # only consider internal files
+ # if the page explicitly depends
+ # on such files
+ if ($d =~ /internal\(/) {
+ if ($depends_simple{$p}{$d} & $IkiWiki::DEPEND_CONTENT) {
+ push @candidates, @internal, @internal_change;
+ }
+ elsif ($depends{$p}{$d} & $IkiWiki::DEPEND_PRESENCE) {
+ push @candidates, @internal;
+ }
+ }
+
+ foreach my $file (@candidates) {
+ next if $file eq $f;
+ my $page=pagename($file);
+ if ($sub->($page, location => $p)) {
+ $reason = $page;
+ last D;
+ }
}
}
}
+
+ if (defined $reason) {
+ debug(sprintf(gettext("building %s, which depends on %s"), $f, $reason));
+ render($f);
+ $rendered{$f}=1;
+ $changes++;
+ last;
+ }
}
-
- if (defined $reason) {
- debug(sprintf(gettext("building %s, which depends on %s"), $f, $reason));
- render($f);
- $rendered{$f}=1;
- }
- }
+ } while $changes;
# handle backlinks; if a page has added/removed links,
# update the pages it links to
diff --git a/debian/changelog b/debian/changelog
index ca5409af7..7ca0d9e42 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,16 @@ ikiwiki (3.14159266) UNRELEASED; urgency=low
* mirrorlist: Display nothing if list is empty.
* Fix a bug that could lead to duplicate links being recorded
for tags.
+ * Added support framework for multiple types of dependencies.
+ * Allow declaring that a dependency is only affected by page presence.
+ (By passing presence => 1 to add_depends.)
+ * pagecount, calendar, postsparkline, progress: Use a presence dependency,
+ which makes these directives much less expensive to use, since page
+ edits will no longer trigger an unnecessary update.
+ * map: Use a presence dependency unless show= is specified.
+ This makes maps efficient enough that they can be used on sidebars!
+ * inline: Use a presence dependency in quick mode.
+ * Transitive dependencies are now correctly supported.
-- Joey Hess <joeyh@debian.org> Sun, 27 Sep 2009 17:40:03 -0400
diff --git a/doc/plugins/sidebar.mdwn b/doc/plugins/sidebar.mdwn
index 36982eff3..4e356d65a 100644
--- a/doc/plugins/sidebar.mdwn
+++ b/doc/plugins/sidebar.mdwn
@@ -16,6 +16,10 @@ will turn off the sidebar altogether.
Warning: Any change to the sidebar will cause a rebuild of the whole wiki,
since every page includes a copy that has to be updated. This can
-especially be a problem if the sidebar includes [[inline]] or [[map]]
-directives, since any changes to pages inlined or mapped onto the sidebar
+especially be a problem if the sidebar includes an [[ikiwiki/directive/inline]]
+directive, since any changes to pages inlined into the sidebar
will change the sidebar and cause a full wiki rebuild.
+
+Instead, if you include a [[ikiwiki/directive/map]] directive on the sidebar,
+and it does not use the `show` parameter, only adding or removing pages
+included in the map will cause a full rebuild. Modifying pages will not.
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn
index 668f8d8b6..73db6f12a 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -609,10 +609,20 @@ page created from it. (Ie, it appends ".html".)
Use this when constructing the filename of a html file. Use `urlto` when
generating a link to a page.
-#### `add_depends($$)`
+#### `add_depends($$;@)`
Makes the specified page depend on the specified [[ikiwiki/PageSpec]].
+By default, dependencies are full content dependencies, meaning that the
+page will be updated whenever anything matching the PageSpec is modified.
+This default can be overridden by additional named parameters, which can be
+used to indicate weaker types of dependencies:
+
+* `presence` if set to true, only the presence of a matching page triggers
+ the dependency.
+* `links` if set to true, any change in the text of links on a matching page
+ triggers the dependency
+
#### `pagespec_match($$;@)`
Passed a page name, and [[ikiwiki/PageSpec]], returns true if the
diff --git a/ikiwiki-transition b/ikiwiki-transition
index 8a20cf655..1bebb1176 100755
--- a/ikiwiki-transition
+++ b/ikiwiki-transition
@@ -299,7 +299,7 @@ sub oldloadindex {
$pagemtime{$page}=$items{mtime}[0];
$oldlinks{$page}=[@{$items{link}}];
$links{$page}=[@{$items{link}}];
- $depends{$page}={ $items{depends}[0] => 1 } if exists $items{depends};
+ $depends{$page}={ $items{depends}[0] => $IkiWiki::DEPEND_CONTENT } if exists $items{depends};
$destsources{$_}=$page foreach @{$items{dest}};
$renderedfiles{$page}=[@{$items{dest}}];
$pagecase{lc $page}=$page;