aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-10-04 20:30:21 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-10-04 20:30:21 -0400
commitbe032a7b87d1080f1a54327346cb5b40432a056c (patch)
treed945e47c53ca110840491d8fe2cd96515ae5dfe3 /IkiWiki
parentb4c8cc90726cb953898b14f378881bddd224a22c (diff)
downloadikiwiki-be032a7b87d1080f1a54327346cb5b40432a056c.tar
ikiwiki-be032a7b87d1080f1a54327346cb5b40432a056c.tar.gz
rework dependency types code
Simplify, change default content depends number to 1, change interface to make more sense.
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/calendar.pm18
-rw-r--r--IkiWiki/Plugin/edittemplate.pm2
-rw-r--r--IkiWiki/Plugin/listdirectives.pm2
-rw-r--r--IkiWiki/Plugin/meta.pm2
-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.pm28
8 files changed, 30 insertions, 32 deletions
diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm
index a5cc20882..a1117992a 100644
--- a/IkiWiki/Plugin/calendar.pm
+++ b/IkiWiki/Plugin/calendar.pm
@@ -105,21 +105,21 @@ sub format_month (@) {
linktext => " $monthname ");
}
add_depends($params{page}, "$archivebase/$year/".sprintf("%02d", $month),
- content => 0);
+ 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),
- content => 0);
+ 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),
- content => 0);
+ presence => 1);
# Start producing the month calendar
$calendar=<<EOF;
@@ -212,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}, content => 0);
+ 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, content => 0);
+ add_depends($params{page}, $p, presence => 1);
}
return $calendar;
@@ -249,19 +249,19 @@ sub format_year (@) {
"$archivebase/$year",
linktext => "$year");
}
- add_depends($params{page}, "$archivebase/$year", content => 0);
+ 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", content => 0);
+ 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", content => 0);
+ add_depends($params{page}, "$archivebase/$nyear", presence => 1);
# Start producing the year calendar
$calendar=<<EOF;
@@ -313,7 +313,7 @@ EOF
else {
$calendar.=qq{\t<td class="$tag">$monthabbr</td>\n};
}
- add_depends($params{page}, "$archivebase/$year/$mtag", content => 0);
+ 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 89d450725..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, content => 0);
+ 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/listdirectives.pm b/IkiWiki/Plugin/listdirectives.pm
index 96150f986..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, content => 0);
+ add_depends($params{page}, $link, presence => 1);
$result .= htmllink($params{page}, $params{destpage}, $link);
$result .= '</li>';
}
diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
index eef3013a0..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, content => 0);
+ add_depends($page, $link, presence => 1);
$value=urlto($link, $page);
$value.='#'.$redir_anchor if defined $redir_anchor;
diff --git a/IkiWiki/Plugin/pagecount.pm b/IkiWiki/Plugin/pagecount.pm
index 17eda0618..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 contentless dependency.
- add_depends($params{page}, $params{pages}, content => 0);
+ # 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 694d39575..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}, content => 0);
+ 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 3b664f4cb..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}, content => 0);
- add_depends($params{page}, $params{donepages}, content => 0);
+ 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 3fc750925..cf0c3fe08 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -473,13 +473,11 @@ sub refresh () {
if (exists $depends_simple{$p}) {
foreach my $d (keys %{$depends_simple{$p}}) {
- if ($depends_simple{$p}{$d} == $IkiWiki::DEPEND_EXISTS) {
- if (exists $lc_exists_changed{$d}) {
- $reason = $d;
- last;
- }
- }
- elsif (exists $lc_changed{$d}) {
+ 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;
}
@@ -492,22 +490,22 @@ sub refresh () {
next if $@ || ! defined $sub;
my @candidates;
- if ($depends{$p}{$d} == $IkiWiki::DEPEND_EXISTS) {
- @candidates=@exists_changed;
- }
- else {
+ 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{$p}{$d} == $IkiWiki::DEPEND_EXISTS) {
- push @candidates, @internal;
- }
- else {
+ 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) {