Add page() PageSpec, which is like glob() but matches only pages, not other files.
parent
194824ce29
commit
3ac2ae1f14
10
IkiWiki.pm
10
IkiWiki.pm
|
@ -2299,7 +2299,11 @@ sub match_glob ($$;@) {
|
|||
|
||||
my $regexp=IkiWiki::glob2re($glob);
|
||||
if ($page=~/^$regexp$/i) {
|
||||
if (! IkiWiki::isinternal($page) || $params{internal}) {
|
||||
if ($params{onlypage} &&
|
||||
! defined IkiWiki::pagetype($IkiWiki::pagesources{$page})) {
|
||||
return IkiWiki::FailReason->new("$page is not a page");
|
||||
}
|
||||
elsif (! IkiWiki::isinternal($page) || $params{internal}) {
|
||||
return IkiWiki::SuccessReason->new("$glob matches $page");
|
||||
}
|
||||
else {
|
||||
|
@ -2315,6 +2319,10 @@ sub match_internal ($$;@) {
|
|||
return match_glob($_[0], $_[1], @_, internal => 1)
|
||||
}
|
||||
|
||||
sub match_page ($$;@) {
|
||||
return match_glob($_[0], $_[1], @_, onlypage => 1)
|
||||
}
|
||||
|
||||
sub match_link ($$;@) {
|
||||
my $page=shift;
|
||||
my $link=lc(shift);
|
||||
|
|
|
@ -75,6 +75,8 @@ ikiwiki (3.20100424) UNRELEASED; urgency=low
|
|||
the top of the web root. This is another things that requires a wiki
|
||||
rebuild on upgrade to this version.
|
||||
* Fix removal of rendered files in rebuild mode.
|
||||
* Add page() PageSpec, which is like glob() but matches only pages,
|
||||
not other files.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Sun, 04 Apr 2010 12:17:11 -0400
|
||||
|
||||
|
|
|
@ -24,19 +24,20 @@ match all pages except for Discussion pages and the SandBox:
|
|||
|
||||
Some more elaborate limits can be added to what matches using these functions:
|
||||
|
||||
* "`glob(someglob)`" - matches pages and other files that match the given glob.
|
||||
Just writing the glob by itself is actually a shorthand for this function.
|
||||
* "`page(glob)`" - like `glob()`, but only matches pages, not other files
|
||||
* "`link(page)`" - matches only pages that link to a given page (or glob)
|
||||
* "`tagged(tag)`" - matches pages that are tagged or link to the given tag (or
|
||||
tags matched by a glob)
|
||||
* "`backlink(page)`" - matches only pages that a given page links to
|
||||
* "`creation_month(month)`" - matches only pages created on the given month
|
||||
* "`creation_month(month)`" - matches only files created on the given month
|
||||
* "`creation_day(mday)`" - or day of the month
|
||||
* "`creation_year(year)`" - or year
|
||||
* "`created_after(page)`" - matches only pages created after the given page
|
||||
* "`created_after(page)`" - matches only files created after the given page
|
||||
was created
|
||||
* "`created_before(page)`" - matches only pages created before the given page
|
||||
* "`created_before(page)`" - matches only files created before the given page
|
||||
was created
|
||||
* "`glob(someglob)`" - matches pages that match the given glob. Just writing
|
||||
the glob by itself is actually a shorthand for this function.
|
||||
* "`internal(glob)`" - like `glob()`, but matches even internal-use
|
||||
pages that globs do not usually match.
|
||||
* "`title(glob)`", "`author(glob)`", "`authorurl(glob)`",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/perl
|
||||
use warnings;
|
||||
use strict;
|
||||
use Test::More tests => 75;
|
||||
use Test::More tests => 85;
|
||||
|
||||
BEGIN { use_ok("IkiWiki"); }
|
||||
|
||||
|
@ -66,7 +66,21 @@ $links{"ook"}=[qw{/blog/tags/foo}];
|
|||
foreach my $p (keys %links) {
|
||||
$pagesources{$p}="$p.mdwn";
|
||||
}
|
||||
$pagesources{"foo.png"}="foo.png";
|
||||
$pagesources{"foo"}="foo.mdwn";
|
||||
$IkiWiki::hooks{htmlize}{mdwn}={};
|
||||
|
||||
ok(pagespec_match("foo", "foo"), "simple");
|
||||
ok(! pagespec_match("foo", "bar"), "simple fail");
|
||||
ok(pagespec_match("foo", "foo"), "simple glob");
|
||||
ok(pagespec_match("foo", "f*"), "simple glob fail");
|
||||
ok(pagespec_match("foo", "page(foo)"), "page()");
|
||||
print pagespec_match("foo", "page(foo)")."\n";
|
||||
ok(! pagespec_match("foo", "page(bar)"), "page() fail");
|
||||
ok(! pagespec_match("foo.png", "page(foo.png)"), "page() fails on non-page");
|
||||
ok(! pagespec_match("foo.png", "page(foo*)"), "page() fails on non-page glob");
|
||||
ok(pagespec_match("foo", "page(foo)"), "page() glob");
|
||||
ok(pagespec_match("foo", "page(f*)"), "page() glob fail");
|
||||
ok(pagespec_match("foo", "link(bar)"), "link");
|
||||
ok(pagespec_match("foo", "link(ba?)"), "glob link");
|
||||
ok(! pagespec_match("foo", "link(quux)"), "failed link");
|
||||
|
|
Loading…
Reference in New Issue