aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/map.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-04-23 15:45:30 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-04-23 15:45:30 -0400
commitaa306957bac11477b914ac19b93890184ffe4062 (patch)
treec9b05bf73cb4d19e55297ad3b335bb1fc3ce67e5 /IkiWiki/Plugin/map.pm
parent527d178c12141d2467dfa86492e249d021b88997 (diff)
downloadikiwiki-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.pm49
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;
}
}
}