X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/8decfc845598f08bb7a212a57b9d44761ca08a6a..fc1cc57cdca9a7bdab41f0d63e34a98a2d7c78e5:/doc/todo/Bestdir_along_with_bestlink_in_IkiWiki.pm.mdwn diff --git a/doc/todo/Bestdir_along_with_bestlink_in_IkiWiki.pm.mdwn b/doc/todo/Bestdir_along_with_bestlink_in_IkiWiki.pm.mdwn index 1c0914336..bf8de16cd 100644 --- a/doc/todo/Bestdir_along_with_bestlink_in_IkiWiki.pm.mdwn +++ b/doc/todo/Bestdir_along_with_bestlink_in_IkiWiki.pm.mdwn @@ -1,44 +1,51 @@ 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; +> Um, what is this for? :-) It would probably be a lot easier to review if it +> had documentation, and/or a plugin that used it. --[[smcv]] + +------- + 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]] \ No newline at end of file +-[[users/arpitjain]] + +[[!tag patch patch/core]]