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.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.pm')
-rw-r--r-- | IkiWiki.pm | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index fca8da874..e260fffea 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -18,10 +18,10 @@ use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase use Exporter q{import}; our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match - bestlink htmllink readfile writefile pagetype srcfile pagename - displaytime will_render gettext urlto targetpage - add_underlay pagetitle titlepage linkpage newpagefile - inject + pagespec_match_list bestlink htmllink readfile writefile + pagetype srcfile pagename displaytime will_render gettext urlto + targetpage add_underlay pagetitle titlepage linkpage + newpagefile inject %config %links %pagestate %wikistate %renderedfiles %pagesources %destsources); our $VERSION = 3.00; # plugin interface version, next is ikiwiki version @@ -1832,6 +1832,30 @@ sub pagespec_match ($$;@) { return $sub->($page, @params); } +sub pagespec_match_list ($$;@) { + my $pages=shift; + my $spec=shift; + my @params=@_; + + my $sub=pagespec_translate($spec); + error "syntax error in pagespec \"$spec\"" + if $@ || ! defined $sub; + + my @ret; + my $r; + foreach my $page (@$pages) { + $r=$sub->($page, @params); + push @ret, $page if $r; + } + + if (! @ret && defined $r && $r->isa("IkiWiki::ErrorReason")) { + error(sprintf(gettext("cannot match pages: %s"), $r)); + } + else { + return @ret; + } +} + sub pagespec_valid ($) { my $spec=shift; |