* Apply a patch from Carl Worth adding support for using globs in link()
in a PageSpec.master
parent
866cdd7c4a
commit
66cb6baf4e
19
IkiWiki.pm
19
IkiWiki.pm
|
@ -1056,8 +1056,8 @@ sub match_glob ($$;@) { #{{{
|
|||
|
||||
# relative matching
|
||||
if ($glob =~ m!^\./!) {
|
||||
$from=~s!/?[^/]+$!!;
|
||||
$glob=~s!^\./!!;
|
||||
$from=~s#/?[^/]+$##;
|
||||
$glob=~s#^\./##;
|
||||
$glob="$from/$glob" if length $from;
|
||||
}
|
||||
|
||||
|
@ -1083,18 +1083,23 @@ sub match_link ($$;@) { #{{{
|
|||
|
||||
# relative matching
|
||||
if ($link =~ m!^\.! && defined $from) {
|
||||
$from=~s!/?[^/]+$!!;
|
||||
$link=~s!^\./!!;
|
||||
$from=~s#/?[^/]+$##;
|
||||
$link=~s#^\./##;
|
||||
$link="$from/$link" if length $from;
|
||||
}
|
||||
|
||||
my $links = $IkiWiki::links{$page} or return undef;
|
||||
return IkiWiki::FailReason->new("$page has no links") unless @$links;
|
||||
my $bestlink = IkiWiki::bestlink($from, $link);
|
||||
return IkiWiki::FailReason->new("no such link") unless length $bestlink;
|
||||
foreach my $p (@$links) {
|
||||
return IkiWiki::SuccessReason->new("$page links to $link")
|
||||
if $bestlink eq IkiWiki::bestlink($page, $p);
|
||||
if (length $bestlink) {
|
||||
return IkiWiki::SuccessReason->new("$page links to $link")
|
||||
if $bestlink eq IkiWiki::bestlink($page, $p);
|
||||
}
|
||||
else {
|
||||
return IkiWiki::SuccessReason->new("$page links to page matching $link")
|
||||
if match_glob($p, $link, %params);
|
||||
}
|
||||
}
|
||||
return IkiWiki::FailReason->new("$page does not link to $link");
|
||||
} #}}}
|
||||
|
|
|
@ -28,6 +28,8 @@ ikiwiki (2.2) UNRELEASED; urgency=low
|
|||
doesn't specify encoding, and variously broken feed consumers, according
|
||||
to <http://www.rssboard.org/rss-profile#data-types-characterdata>.
|
||||
* Correct some issues with display of unhandled preprocessor directives.
|
||||
* Apply a patch from Carl Worth adding support for using globs in link()
|
||||
in a PageSpec.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Mon, 28 May 2007 21:56:11 -0400
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ match all pages except for Discussion pages and the SandBox:
|
|||
Some more elaborate limits can be added to what matches using any of these
|
||||
functions:
|
||||
|
||||
* "`link(page)`" - match only pages that link to a given page
|
||||
* "`link(page)`" - match only pages that link to a given page (or glob)
|
||||
* "`backlink(page)`" - match only pages that a given page links to
|
||||
* "`creation_month(month)`" - match only pages created on the given month
|
||||
* "`creation_day(mday)`" - or day of the month
|
||||
|
|
|
@ -41,3 +41,5 @@ That doesn't work in ikiwiki 2.1, but I have it
|
|||
} #}}}
|
||||
--
|
||||
1.5.1.1.g6aead
|
||||
|
||||
Thanks! [[done]] --[[Joey]]
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2007-05-24 15:47-0400\n"
|
||||
"POT-Creation-Date: 2007-05-30 15:53-0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/perl
|
||||
use warnings;
|
||||
use strict;
|
||||
use Test::More tests => 52;
|
||||
use Test::More tests => 54;
|
||||
|
||||
BEGIN { use_ok("IkiWiki"); }
|
||||
|
||||
|
@ -40,7 +40,9 @@ $links{"examples/softwaresite/bugs/fails_to_frobnicate"}=[qw{done}];
|
|||
$links{"examples/softwaresite/bugs/done"}=[];
|
||||
|
||||
ok(pagespec_match("foo", "link(bar)"), "link");
|
||||
ok(pagespec_match("foo", "link(ba?)"), "glob link");
|
||||
ok(! pagespec_match("foo", "link(quux)"), "failed link");
|
||||
ok(! pagespec_match("foo", "link(qu*)"), "failed glob link");
|
||||
ok(pagespec_match("bugs/foo", "link(done)", location => "bugs/done"), "link match to bestlink");
|
||||
ok(! pagespec_match("examples/softwaresite/bugs/done", "link(done)",
|
||||
location => "bugs/done"), "link match to bestlink");
|
||||
|
|
Loading…
Reference in New Issue