diff options
author | Joey Hess <joey@gnu.kitenet.net> | 2009-04-23 15:45:30 -0400 |
---|---|---|
committer | Joey Hess <joey@gnu.kitenet.net> | 2009-04-23 15:45:30 -0400 |
commit | aa306957bac11477b914ac19b93890184ffe4062 (patch) | |
tree | c9b05bf73cb4d19e55297ad3b335bb1fc3ce67e5 /IkiWiki/Plugin/map.pm | |
parent | 527d178c12141d2467dfa86492e249d021b88997 (diff) | |
download | ikiwiki-aa306957bac11477b914ac19b93890184ffe4062.tar ikiwiki-aa306957bac11477b914ac19b93890184ffe4062.tar.gz |
pagespec_match_list added and used in most appropriate places
* pagespec_match_list: New API function, matches pages in a list
and throws an error if the pagespec is bad.
* inline, brokenlinks, calendar, linkmap, map, orphans, pagecount,
pagestate, postsparkline: Display a handy error message if the pagespec
is erronious.
Diffstat (limited to 'IkiWiki/Plugin/map.pm')
-rw-r--r-- | IkiWiki/Plugin/map.pm | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index 328493116..120451b5d 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -32,32 +32,31 @@ sub preprocess (@) { # Get all the items to map. my %mapitems; - foreach my $page (keys %pagesources) { - if (pagespec_match($page, $params{pages}, location => $params{page})) { - if (exists $params{show} && - exists $pagestate{$page} && - exists $pagestate{$page}{meta}{$params{show}}) { - $mapitems{$page}=$pagestate{$page}{meta}{$params{show}}; - } - else { - $mapitems{$page}=''; - } - # Check for a common prefix. - if (! defined $common_prefix) { - $common_prefix=$page; - } - elsif (length $common_prefix && - $page !~ /^\Q$common_prefix\E(\/|$)/) { - my @a=split(/\//, $page); - my @b=split(/\//, $common_prefix); - $common_prefix=""; - while (@a && @b && $a[0] eq $b[0]) { - if (length $common_prefix) { - $common_prefix.="/"; - } - $common_prefix.=shift(@a); - shift @b; + foreach my $page (pagespec_match_list([keys %pagesources], + $params{pages}, location => $params{page})) { + if (exists $params{show} && + exists $pagestate{$page} && + exists $pagestate{$page}{meta}{$params{show}}) { + $mapitems{$page}=$pagestate{$page}{meta}{$params{show}}; + } + else { + $mapitems{$page}=''; + } + # Check for a common prefix. + if (! defined $common_prefix) { + $common_prefix=$page; + } + elsif (length $common_prefix && + $page !~ /^\Q$common_prefix\E(\/|$)/) { + my @a=split(/\//, $page); + my @b=split(/\//, $common_prefix); + $common_prefix=""; + while (@a && @b && $a[0] eq $b[0]) { + if (length $common_prefix) { + $common_prefix.="/"; } + $common_prefix.=shift(@a); + shift @b; } } } |