diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2007-05-30 19:54:08 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2007-05-30 19:54:08 +0000 |
commit | 66cb6baf4e205886bfbac8d90d1adc2b791102a2 (patch) | |
tree | 6e31c5bb419eb56c487fa89839835f94860e2625 | |
parent | 866cdd7c4a4e268f9e4528a8df80b44950c7adb3 (diff) |
* Apply a patch from Carl Worth adding support for using globs in link()
in a PageSpec.
-rw-r--r-- | IkiWiki.pm | 19 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | doc/pagespec.mdwn | 2 | ||||
-rw-r--r-- | doc/todo/Support_wildcard_inside_of_link__40____41___within_a_pagespec.mdwn | 2 | ||||
-rw-r--r-- | po/ikiwiki.pot | 2 | ||||
-rwxr-xr-x | t/pagespec_match.t | 4 |
6 files changed, 21 insertions, 10 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index 761160eca..8143f5256 100644 --- a/IkiWiki.pm +++ b/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"); } #}}} diff --git a/debian/changelog b/debian/changelog index b50da4a40..0589f5687 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 diff --git a/doc/pagespec.mdwn b/doc/pagespec.mdwn index b26a42e28..e004de4af 100644 --- a/doc/pagespec.mdwn +++ b/doc/pagespec.mdwn @@ -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 diff --git a/doc/todo/Support_wildcard_inside_of_link__40____41___within_a_pagespec.mdwn b/doc/todo/Support_wildcard_inside_of_link__40____41___within_a_pagespec.mdwn index 4197cece7..24f9054f7 100644 --- a/doc/todo/Support_wildcard_inside_of_link__40____41___within_a_pagespec.mdwn +++ b/doc/todo/Support_wildcard_inside_of_link__40____41___within_a_pagespec.mdwn @@ -41,3 +41,5 @@ That doesn't work in ikiwiki 2.1, but I have it } #}}} -- 1.5.1.1.g6aead + +Thanks! [[done]] --[[Joey]] diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot index 55e8429d8..e63ead2fb 100644 --- a/po/ikiwiki.pot +++ b/po/ikiwiki.pot @@ -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" diff --git a/t/pagespec_match.t b/t/pagespec_match.t index 635381e2b..3a641c6a8 100755 --- a/t/pagespec_match.t +++ b/t/pagespec_match.t @@ -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"); |