diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-06-02 01:17:26 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-06-02 01:17:26 +0000 |
commit | ad247de723cc540aaaae584cdceefaeb06f62284 (patch) | |
tree | ebd4b49e10861e5f3aee143f11e36d9a75a033e5 /IkiWiki.pm | |
parent | 140658bc51338b8d1c74382bbf374ad77f07c269 (diff) |
* 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.
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r-- | IkiWiki.pm | 28 |
1 files changed, 21 insertions, 7 deletions
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 ($$) { #{{{ |