]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/backlink__40__.__41___doesn__39__t_work.mdwn
clarify which case fails
[ikiwiki.git] / doc / bugs / backlink__40__.__41___doesn__39__t_work.mdwn
1 It seems `backlink(.)` doesn't work, that is, it doesn't match pages linked
2 to from the current page.
3
4 If I have two test pages, `foo`, which links to `bar`, then (on the `foo`
5 page):
6
7  * backlink(foo) lists 'bar'
8  * backlink(.) lists nothing
9
10 tested with 3.20120109.
11
12 — [[Jon]]
13
14 > The attached patch should fix it:
15
16 >> [[applied|done]] thanks --[[Joey]] 
17
18     From 30512ac5f6a724bafb1095ab246e0648999f7b6c Mon Sep 17 00:00:00 2001
19     From: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
20     Date: Fri, 13 Jan 2012 11:02:11 +0100
21     Subject: [PATCH] backlink(.) should behave like backlink(<current page>)
22     
23     Since commit c4d4cad3befbbd444d094cbeb0b6ebba3910a025, the single dot in
24     a pagespec can be used to mean the current page. While this worked
25     correctly in link() it didn't work in backlink(). Fix this by explicitly
26     checking the testpage in backlink against . and replacing it with the
27     current location if necessary.
28     ---
29      IkiWiki.pm |   10 ++++++++--
30      1 files changed, 8 insertions(+), 2 deletions(-)
31     
32     diff --git a/IkiWiki.pm b/IkiWiki.pm
33     index 08e242a..bc56501 100644
34     --- a/IkiWiki.pm
35     +++ b/IkiWiki.pm
36     @@ -2647,8 +2647,14 @@ sub match_link ($$;@) {
37      }
38      
39      sub match_backlink ($$;@) {
40     -   my $ret=match_link($_[1], $_[0], @_);
41     -   $ret->influences($_[1] => $IkiWiki::DEPEND_LINKS);
42     +   my $page=shift;
43     +   my $testpage=shift;
44     +   my %params=@_;
45     +   if ($testpage eq '.') {
46     +           $testpage = $params{'location'}
47     +   }
48     +   my $ret=match_link($testpage, $page, @_);
49     +   $ret->influences($testpage => $IkiWiki::DEPEND_LINKS);
50         return $ret;
51      }
52      
53     -- 
54     1.7.8.rc2.253.gdbf3
55
56
57 > (you need to re-make IkiWiki for it to work)