aboutsummaryrefslogtreecommitdiff
path: root/doc/todo/Bestdir_along_with_bestlink_in_IkiWiki.pm.mdwn
blob: 95c38f794a281760dc90fcb87af8d0774fcc20eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
This patch adds function bestdir() which returns best directory from the directory structure. This is in addition to the bestlink() function which is there in IkiWiki.pm 

-------

    Index: IkiWiki.pm
    ===================================================================
    --- IkiWiki.pm  (revision 9)
    +++ IkiWiki.pm  (working copy)
    @@ -391,6 +391,35 @@
            return "";
     }
    
    +sub bestdir ($$) {
    +    my $page=shift;
    +       my $link=shift;
    +       my $cwd=$page;
    +
    +       if ($link=~s/^\/+//) {
    +               $cwd="";
    +       }
    +
    +       do {
    +               my $l=$cwd;
    +               $l.="/" if length $l;
    +               $l.=$link;
    +               if (-d "$config{srcdir}/$l") {
    +                       return $l;
    +               }
    +       } while $cwd=~s!/?[^/]+$!!;
    +
    +       if (length $config{userdir}) {
    +               my $l = "$config{userdir}/".lc($link);
    +
    +               if (-d $l) {
    +                       return $l;
    +               }
    +       }
    +
    +       return "";
    +}
    +
     sub isinlinableimage ($) {
            my $file=shift;
    
---- 
-[[users/arpitjain]]

[[!tag patch]]