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