]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/backlink__40__.__41___doesn__39__t_work.mdwn
cb7f156bc0b31b9757d9958247d95be989d0f86a
[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
17     From 30512ac5f6a724bafb1095ab246e0648999f7b6c Mon Sep 17 00:00:00 2001
18     From: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
19     Date: Fri, 13 Jan 2012 11:02:11 +0100
20     Subject: [PATCH] backlink(.) should behave like backlink(<current page>)
21     
22     Since commit c4d4cad3befbbd444d094cbeb0b6ebba3910a025, the single dot in
23     a pagespec can be used to mean the current page. While this worked
24     correctly in link() it didn't work in backlink(). Fix this by explicitly
25     checking the testpage in backlink against . and replacing it with the
26     current location if necessary.
27     ---
28      IkiWiki.pm |   10 ++++++++--
29      1 files changed, 8 insertions(+), 2 deletions(-)
30     
31     diff --git a/IkiWiki.pm b/IkiWiki.pm
32     index 08e242a..bc56501 100644
33     --- a/IkiWiki.pm
34     +++ b/IkiWiki.pm
35     @@ -2647,8 +2647,14 @@ sub match_link ($$;@) {
36      }
37      
38      sub match_backlink ($$;@) {
39     -   my $ret=match_link($_[1], $_[0], @_);
40     -   $ret->influences($_[1] => $IkiWiki::DEPEND_LINKS);
41     +   my $page=shift;
42     +   my $testpage=shift;
43     +   my %params=@_;
44     +   if ($testpage eq '.') {
45     +           $testpage = $params{'location'}
46     +   }
47     +   my $ret=match_link($testpage, $page, @_);
48     +   $ret->influences($testpage => $IkiWiki::DEPEND_LINKS);
49         return $ret;
50      }
51      
52     -- 
53     1.7.8.rc2.253.gdbf3
54
55
56 > (you need to re-make IkiWiki for it to work)