]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Merge branch 'dependency-types' into transitive-dependencies
authorJoey Hess <joey@gnu.kitenet.net>
Sun, 4 Oct 2009 20:33:58 +0000 (16:33 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Sun, 4 Oct 2009 20:33:58 +0000 (16:33 -0400)
Conflicts:
IkiWiki/Render.pm

18 files changed:
IkiWiki.pm
IkiWiki/Plugin/brokenlinks.pm
IkiWiki/Plugin/calendar.pm
IkiWiki/Plugin/edittemplate.pm
IkiWiki/Plugin/inline.pm
IkiWiki/Plugin/linkmap.pm
IkiWiki/Plugin/listdirectives.pm
IkiWiki/Plugin/map.pm
IkiWiki/Plugin/meta.pm
IkiWiki/Plugin/orphans.pm
IkiWiki/Plugin/pagecount.pm
IkiWiki/Plugin/postsparkline.pm
IkiWiki/Plugin/progress.pm
IkiWiki/Render.pm
debian/changelog
doc/plugins/sidebar.mdwn
doc/plugins/write.mdwn
ikiwiki-transition

index 2637f60179c2732506158a495cdebbc46b4b8889..5e5dc739d2696cce58374c2717b453d104521f11 100644 (file)
@@ -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;
index eb698b0bef9f7b2c9df90b342dcfac56c79a1795..b8ed2b8de58e05d985a7e45985cbf2e628714b3a 100644 (file)
@@ -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;
index 5d16dff75ba7a98a68c3fc8c94d9d9378cb11732..a5cc208821691d6574d77a985b09673b0fd7f70a 100644 (file)
@@ -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);
        }
index 0bafc95d06d854b860e566a8c14134119d51db17..89d45072540bb78fcf40eb9a2171138bcfb70fb0 100644 (file)
@@ -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});
index ccfadfd699929a8be1764546118d89ee9f958f56..5133c4ba66726ee715e8b927db9441389322692b 100644 (file)
@@ -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}) {
index 941ed5f3672145bb6111c5a6650fb14431641297..d0671ae0e93b7877aef75b314158145ce61770db 100644 (file)
@@ -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
index bd73f1a04e728638c19994c0d64a4f288a120150..96150f986dabd8c1e25b0fd708b18a9d44e5e6fd 100644 (file)
@@ -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>';
        }
index 54146dc467bdcb513e426257a6fd0879005cd35a..6829607770332188e08e963be3b935e546e78a85 100644 (file)
@@ -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.
index 514b0936907ce58edabcbafcb44d5559a154eec9..eef3013a0caf7a1f9008772b7c5ef46ee27ce20b 100644 (file)
@@ -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;
index 71122677273275d3e2f160bde3c8b44a8f333e49..d981670e78d22d5f85a86429cdcda9bc60f78d44 100644 (file)
@@ -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;
index 5a2301af49232943d4f0889c0f3b9ba28f05396f..17eda06181ac19fe00ee2de2b2f52fb336980d49 100644 (file)
@@ -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 "*") {
index d2e5c23788678efb7819e10c59964bd852663e06..694d3957562e2d69d017a16470aa08bd028f62ce 100644 (file)
@@ -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(
index 76d994acc7ad0f9d49c63c32d3d5d8dd54db5554..3b664f4cb29ecc4df553db0cf6722de7d00ce585 100644 (file)
@@ -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;
index 09b646f75f0c1be520355b6beacc409ad119c086..3fc750925defe4cd67c26a0a053a73cee0eb4827 100644 (file)
@@ -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,14 +454,17 @@ sub refresh () {
                }
        }
 
-       if (%rendered || @del || @internal) {
+       if (%rendered || @del || @internal || @internal_change) {
                my @changed;
                my $changes;
                do {
                        $changes=0;
                        @changed=(keys %rendered, @del);
-                       my %lcchanged = map { lc(pagename($_)) => 1 } @changed;
-
+                       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};
@@ -470,7 +473,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;
                                                }
@@ -482,10 +491,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)) {
index ca5409af7949f7a7e6eb900ab697892c57134e25..0e9bf512b411619326f667ef2c2b0268ad252dcf 100644 (file)
@@ -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
 
index 36982eff386a31e91eaa3fade012795bb9fd61c1..4e356d65a8984885a256788f82f1f2173ffeaa67 100644 (file)
@@ -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.
index 668f8d8b69dff65acc0727fa5fa3233e516b132a..c244c1f2fd68a92eb325d3b209594b3b35f85768 100644 (file)
@@ -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
index 8a20cf655f021b328eef5afe509a75908f202d2a..c50a748e87410da8c40f6e905f07d87db059033f 100755 (executable)
@@ -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;