summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJogo <Jogo@web>2009-08-06 13:07:22 -0400
committerJoey Hess <joey@kitenet.net>2009-08-06 13:07:22 -0400
commit4a331d8afc75f9c9fbfb1ef8d592fa1bfb4e2874 (patch)
treee899491dd0bf277de6b902b9159ac07b5f885daf
parent0b2100727b3e9288ff9c6587924ff5390c61f19a (diff)
-rw-r--r--doc/plugins/contrib/unixrelpagespec.mdwn42
1 files changed, 42 insertions, 0 deletions
diff --git a/doc/plugins/contrib/unixrelpagespec.mdwn b/doc/plugins/contrib/unixrelpagespec.mdwn
new file mode 100644
index 000000000..a35f76c30
--- /dev/null
+++ b/doc/plugins/contrib/unixrelpagespec.mdwn
@@ -0,0 +1,42 @@
+[[!template id=plugin name=unixrelpagespec core=0 author="[[Jogo]]"]]
+
+I don't understand why `./*` correspond to siblings and not subpages.
+This is probably only meaningfull with [[plugins/autoindex]] turned on.
+
+Here is a small plugin wich follow usual Unix convention :
+
+- `./*` expand to subpages
+- `../*` expand to siblings
+
+---
+ #!/usr/bin/perl
+ # UnixRelPageSpec plugin.
+ # by Joseph Boudou <jogo at matabio dot net>
+
+ package IkiWiki::Plugin::unixrelpagespec;
+
+ use warnings;
+ use strict;
+ use IkiWiki 3.00;
+
+ sub import {
+ inject(
+ name => 'IkiWiki::PageSpec::derel',
+ call => \&unix_derel
+ );
+ }
+
+ sub unix_derel ($$) {
+ my $path = shift;
+ my $from = shift;
+
+ if ($path =~ m!^\.{1,2}/!) {
+ $from =~ s#/?[^/]+$## if (defined $from and $path =~ m/^\.{2}/);
+ $path =~ s#^\.{1,2}/##;
+ $path = "$from/$path" if length $from;
+ }
+
+ return $path;
+ }
+
+ 1;