ikiwiki/doc/todo/Bestdir_along_with_bestlink...

52 lines
1.4 KiB
Plaintext
Raw Normal View History

2007-07-27 17:14:20 +02:00
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
2007-07-27 17:27:41 +02:00
2009-07-17 21:36:08 +02:00
> 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]]
2007-07-27 17:14:20 +02:00
-------
2007-07-27 17:27:41 +02:00
2007-07-27 18:44:13 +02:00
Index: IkiWiki.pm
===================================================================
--- IkiWiki.pm (revision 9)
+++ IkiWiki.pm (working copy)
@@ -391,6 +391,35 @@
return "";
}
2007-07-27 18:44:13 +02:00
+sub bestdir ($$) {
2007-07-27 18:44:13 +02:00
+ 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 "";
+}
2007-07-27 18:44:13 +02:00
+
sub isinlinableimage ($) {
2007-07-27 18:44:13 +02:00
my $file=shift;
2007-07-27 17:14:20 +02:00
----
2007-08-12 00:46:15 +02:00
-[[users/arpitjain]]
[[!tag patch patch/core]]