X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/fe4f176f725b069ac74561600bba982c2d9ad607..275dd5c4ea748261741236a62ad763c775a651c5:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index 3e94c8a25..8a8695768 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -661,9 +661,15 @@ sub pagetype ($) { return; } +my %pagename_cache; + sub pagename ($) { my $file=shift; + if (exists $pagename_cache{$file}) { + return $pagename_cache{$file}; + } + my $type=pagetype($file); my $page=$file; $page=~s/\Q.$type\E*$// @@ -672,6 +678,8 @@ sub pagename ($) { if ($config{indexpages} && $page=~/(.*)\/index$/) { $page=$1; } + + $pagename_cache{$file} = $page; return $page; } @@ -1508,10 +1516,12 @@ sub loadindex () { $oldlinks{$page}=[@{$d->{links}}]; } if (exists $d->{dependslist}) { - $depends{$page}=$d->{dependslist}; + $depends{$page}={ + map { $_ => 1 } @{$d->{dependslist}} + }; } elsif (exists $d->{depends}) { - $depends{$page}=[$d->{depends}]; + $depends{$page}={$d->{depends} => 1}; } if (exists $d->{state}) { $pagestate{$page}=$d->{state}; @@ -1557,8 +1567,7 @@ sub saveindex () { }; if (exists $depends{$page}) { - $index{page}{$src}{depends} = join(" or ", @{$depends{$page}}); - $index{page}{$src}{dependslist} = $depends{$page}; + $index{page}{$src}{dependslist} = [ keys %{$depends{$page}} ]; } if (exists $pagestate{$page}) { @@ -1729,18 +1738,18 @@ sub add_depends ($$) { my $page=shift; my $pagespec=shift; - return unless pagespec_valid($pagespec); - - if (! exists $depends{$page}) { - $depends{$page}=[$pagespec]; - } - else { - foreach my $p (@{$depends{$page}}) { - return 1 if $p eq $pagespec; + if (ref $pagespec eq 'ARRAY') { + foreach my $ps (@$pagespec) { + if (pagespec_valid($ps)) { + $depends{$page}{$ps} = 1; + } } - push @{$depends{$page}}, $pagespec; + return; } + return unless pagespec_valid($pagespec); + + $depends{$page}{$pagespec} = 1; return 1; }