]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/Bestdir_along_with_bestlink_in_IkiWiki.pm.mdwn
wishlist: ask about using ikiwiki as ML
[ikiwiki.git] / doc / todo / Bestdir_along_with_bestlink_in_IkiWiki.pm.mdwn
1 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 
2
3 > Um, what is this for? :-) It would probably be a lot easier to review if it
4 > had documentation, and/or a plugin that used it. --[[smcv]]
5
6 -------
7
8     Index: IkiWiki.pm
9     ===================================================================
10     --- IkiWiki.pm  (revision 9)
11     +++ IkiWiki.pm  (working copy)
12     @@ -391,6 +391,35 @@
13             return "";
14      }
15     
16     +sub bestdir ($$) {
17     +    my $page=shift;
18     +       my $link=shift;
19     +       my $cwd=$page;
20     +
21     +       if ($link=~s/^\/+//) {
22     +               $cwd="";
23     +       }
24     +
25     +       do {
26     +               my $l=$cwd;
27     +               $l.="/" if length $l;
28     +               $l.=$link;
29     +               if (-d "$config{srcdir}/$l") {
30     +                       return $l;
31     +               }
32     +       } while $cwd=~s!/?[^/]+$!!;
33     +
34     +       if (length $config{userdir}) {
35     +               my $l = "$config{userdir}/".lc($link);
36     +
37     +               if (-d $l) {
38     +                       return $l;
39     +               }
40     +       }
41     +
42     +       return "";
43     +}
44     +
45      sub isinlinableimage ($) {
46             my $file=shift;
47     
48 ---- 
49 -[[users/arpitjain]]
50
51 [[!tag patch patch/core]]