2006-09-11 05:52:55 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2009-02-20 00:38:45 +01:00
|
|
|
use Test::More tests => 19;
|
2006-09-11 05:52:55 +02:00
|
|
|
|
|
|
|
BEGIN { use_ok("IkiWiki"); }
|
|
|
|
|
2009-02-20 00:38:45 +01:00
|
|
|
# define mdwn as an extension
|
2009-02-20 00:31:57 +01:00
|
|
|
$IkiWiki::hooks{htmlize}{mdwn}={};
|
2009-02-20 00:38:45 +01:00
|
|
|
is(pagetype("foo.mdwn"), "mdwn");
|
2006-09-11 05:52:55 +02:00
|
|
|
is(pagename("foo.mdwn"), "foo");
|
2009-02-20 00:38:45 +01:00
|
|
|
is(pagetype("foo/bar.mdwn"), "mdwn");
|
2006-09-11 05:52:55 +02:00
|
|
|
is(pagename("foo/bar.mdwn"), "foo/bar");
|
2009-02-20 00:28:43 +01:00
|
|
|
|
2009-02-20 00:38:45 +01:00
|
|
|
# bare files get the full filename as page name, undef type
|
|
|
|
is(pagetype("foo.png"), undef);
|
2006-09-11 05:52:55 +02:00
|
|
|
is(pagename("foo.png"), "foo.png");
|
2009-02-20 00:38:45 +01:00
|
|
|
is(pagetype("foo/bar.png"), undef);
|
2009-02-20 00:28:43 +01:00
|
|
|
is(pagename("foo/bar.png"), "foo/bar.png");
|
2009-02-20 00:38:45 +01:00
|
|
|
is(pagetype("foo"), undef);
|
2006-09-11 05:52:55 +02:00
|
|
|
is(pagename("foo"), "foo");
|
2009-02-20 00:31:57 +01:00
|
|
|
|
|
|
|
# keepextension preserves the extension in the page name
|
2009-02-20 00:38:45 +01:00
|
|
|
$IkiWiki::hooks{htmlize}{txt}={keepextension => 1};
|
2009-02-20 00:31:57 +01:00
|
|
|
is(pagename("foo.txt"), "foo.txt");
|
2009-02-20 00:38:45 +01:00
|
|
|
is(pagetype("foo.txt"), "txt");
|
2009-02-20 00:31:57 +01:00
|
|
|
is(pagename("foo/bar.txt"), "foo/bar.txt");
|
2009-02-20 00:38:45 +01:00
|
|
|
is(pagetype("foo/bar.txt"), "txt");
|
|
|
|
|
|
|
|
# noextension makes extensionless files be treated as first-class pages
|
|
|
|
$IkiWiki::hooks{htmlize}{Makefile}={noextension =>1};
|
|
|
|
is(pagetype("Makefile"), "Makefile");
|
|
|
|
is(pagename("Makefile"), "Makefile");
|
|
|
|
is(pagetype("foo/Makefile"), "Makefile");
|
|
|
|
is(pagename("foo/Makefile"), "foo/Makefile");
|