summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki.pm58
-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.pm38
-rw-r--r--debian/changelog9
-rw-r--r--doc/plugins/sidebar.mdwn8
-rw-r--r--doc/plugins/write.mdwn9
-rwxr-xr-xikiwiki-transition2
18 files changed, 135 insertions, 53 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 2637f6017..5e5dc739d 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_EXISTS=1;
+our $DEPEND_CONTENT=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 | $DEPEND_EXISTS }
+ @{$d->{dependslist}}
};
}
+ elsif (exists $d->{depends} && ! ref $d->{depends}) {
+ # old format
+ $depends{$page}={$d->{depends} => $DEPEND_CONTENT | $DEPEND_EXISTS};
+ }
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,30 @@ 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;
+ my $simple=$pagespec =~ /$config{wiki_file_regexp}/ &&
+ $pagespec !~ /[\s*?()!]/;
+
+ my $deptype=$DEPEND_CONTENT | $DEPEND_EXISTS;
+ if (@_) {
+ my %params=@_;
+ if (defined $params{content} && $params{content} == 0 &&
+ ($simple || pagespec_contentless($pagespec))) {
+ $deptype=$deptype & ~$DEPEND_CONTENT;
+ }
+ }
+
+ 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;
}
@@ -1952,6 +1976,18 @@ sub pagespec_valid ($) {
return ! $@;
}
+sub pagespec_contentless ($) {
+ my $spec=shift;
+
+ while ($spec=~m{
+ (\w+)\([^\)]*\) # only match pagespec functions
+ }igx) {
+ return 0 unless $1=~/^(glob|internal|creation_month|creation_day|creation_year|created_before|created_after)$/;
+ }
+
+ return 1;
+}
+
sub glob2re ($) {
my $re=quotemeta(shift);
$re=~s/\\\*/.*/g;
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..a5cc20882 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),
+ content => 0);
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),
+ content => 0);
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),
+ content => 0);
# 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}, content => 0);
# 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, content => 0);
}
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", content => 0);
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", content => 0);
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", content => 0);
# 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", content => 0);
$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..89d450725 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, content => 0);
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..96150f986 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, content => 0);
$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..eef3013a0 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, content => 0);
$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..17eda0618 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 contentless dependency.
+ add_depends($params{page}, $params{pages}, content => 0);
my @pages;
if ($params{pages} eq "*") {
diff --git a/IkiWiki/Plugin/postsparkline.pm b/IkiWiki/Plugin/postsparkline.pm
index d2e5c2378..694d39575 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}, content => 0);
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..3b664f4cb 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}, content => 0);
+ add_depends($params{page}, $params{donepages}, content => 0);
my @pages=keys %pagesources;
my $totalcount=0;
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 246c2260d..9e00428c2 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,10 +454,12 @@ sub refresh () {
}
}
- if (%rendered || @del || @internal) {
+ if (%rendered || @del || @internal || @internal_change) {
my @changed=(keys %rendered, @del);
+ my @exists_changed=(@add, @del);
- my %lcchanged = map { lc(pagename($_)) => 1 } @changed;
+ 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) {
@@ -467,7 +469,13 @@ sub refresh () {
if (exists $depends_simple{$p}) {
foreach my $d (keys %{$depends_simple{$p}}) {
- if (exists $lcchanged{$d}) {
+ if ($depends_simple{$p}{$d} == $IkiWiki::DEPEND_EXISTS) {
+ if (exists $lc_exists_changed{$d}) {
+ $reason = $d;
+ last;
+ }
+ }
+ elsif (exists $lc_changed{$d}) {
$reason = $d;
last;
}
@@ -479,10 +487,26 @@ sub refresh () {
my $sub=pagespec_translate($d);
next if $@ || ! defined $sub;
+ my @candidates;
+ if ($depends{$p}{$d} == $IkiWiki::DEPEND_EXISTS) {
+ @candidates=@exists_changed;
+ }
+ else {
+ @candidates=@changed;
+ }
# only consider internal files
# if the page explicitly depends
# on such files
- foreach my $file (@changed, $d =~ /internal\(/ ? @internal : ()) {
+ if ($d =~ /internal\(/) {
+ if ($depends{$p}{$d} == $IkiWiki::DEPEND_EXISTS) {
+ push @candidates, @internal;
+ }
+ else {
+ push @candidates, @internal, @internal_change;
+ }
+ }
+
+ foreach my $file (@candidates) {
next if $file eq $f;
my $page=pagename($file);
if ($sub->($page, location => $p)) {
diff --git a/debian/changelog b/debian/changelog
index ca5409af7..0e9bf512b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,15 @@ 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 does not encompass the content of a
+ page. (By passing content => 0 to add_depends.)
+ * pagecount, calendar, postsparkline, progress: Use a contentless dependency,
+ which makes these directives much less expensive to use, since page
+ edits will no longer trigger an unnecessary update.
+ * map: Use a contentless dependency unless show= is specified.
+ This makes simple maps efficient enough that they can be used on sidebars!
+ * inline: Use a contentless dependency in quick mode.
-- 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..c244c1f2f 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -609,10 +609,17 @@ 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]].
+Additional named parameters can be passed, to indicate what type of
+dependency this is.
+
+Currently, only a "content" parameter is specified. If set to 0, the
+dependency does not involve the content of pages matching the PageSpec, but
+only their existence.
+
#### `pagespec_match($$;@)`
Passed a page name, and [[ikiwiki/PageSpec]], returns true if the
diff --git a/ikiwiki-transition b/ikiwiki-transition
index 8a20cf655..c50a748e8 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 | $IkiWiki::DEPEND_EXISTS } if exists $items{depends};
$destsources{$_}=$page foreach @{$items{dest}};
$renderedfiles{$page}=[@{$items{dest}}];
$pagecase{lc $page}=$page;