From ad247de723cc540aaaae584cdceefaeb06f62284 Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 2 Jun 2006 01:17:26 +0000 Subject: * Patch from Dr. Zini to add link() and backlink() to globlists. This allows for some handy stuff like: - Using links as a kind of tag; creating blog pages that list all pages containing a given tag/link or not containing some other tag. - Subscribing to mail notifications whenever a change is made to a page that is a backlink of page foo. Ie, "Please notify me of changes in all pages that link to my home page in the wiki" - Locking any pages that are linked to from a particular page, so that lists of locks can be exposed in the wiki. --- IkiWiki.pm | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'IkiWiki.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index ce9542f62..357c1cd2d 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -401,13 +401,27 @@ sub glob_match ($$) { #{{{ my $page=shift; my $glob=shift; - # turn glob into safe regexp - $glob=quotemeta($glob); - $glob=~s/\\\*/.*/g; - $glob=~s/\\\?/./g; - $glob=~s!\\/!/!g; - - $page=~/^$glob$/i; + if ($glob =~ /^link\((.+)\)$/) { + my $rev = $links{$page} or return undef; + foreach my $p (@$rev) { + return 1 if lc $p eq $1; + } + return 0; + } elsif ($glob =~ /^backlink\((.+)\)$/) { + my $rev = $links{$1} or return undef; + foreach my $p (@$rev) { + return 1 if lc $p eq $page; + } + return 0; + } else { + # turn glob into safe regexp + $glob=quotemeta($glob); + $glob=~s/\\\*/.*/g; + $glob=~s/\\\?/./g; + $glob=~s!\\/!/!g; + + return $page=~/^$glob$/i; + } } #}}} sub globlist_match ($$) { #{{{ -- cgit v1.2.3