2014-02-23 17:03:44 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
use Test::More;
|
|
|
|
use IkiWiki;
|
|
|
|
|
|
|
|
my $blob;
|
|
|
|
|
2015-03-01 18:15:13 +01:00
|
|
|
my $add_new_post = gettext("Add a new post titled:");
|
|
|
|
|
2014-02-23 17:03:44 +01:00
|
|
|
ok(! system("rm -rf t/tmp"));
|
|
|
|
ok(! system("mkdir t/tmp"));
|
|
|
|
|
|
|
|
sub write_old_file {
|
|
|
|
my $name = shift;
|
|
|
|
my $content = shift;
|
|
|
|
|
|
|
|
writefile($name, "t/tmp/in", $content);
|
|
|
|
ok(utime(333333333, 333333333, "t/tmp/in/$name"));
|
|
|
|
}
|
|
|
|
|
|
|
|
write_old_file("protagonists.mdwn",
|
|
|
|
'[[!inline pages="protagonists/*" rootpage="protagonists/new"]]');
|
|
|
|
write_old_file("friends.mdwn",
|
2014-09-14 16:14:42 +02:00
|
|
|
'[[!inline pages="friends/*" postform=yes sort=title show=2]]');
|
2014-02-23 17:03:44 +01:00
|
|
|
write_old_file("antagonists.mdwn",
|
|
|
|
'[[!inline pages="antagonists/*"]]');
|
|
|
|
write_old_file("enemies.mdwn",
|
2014-09-14 16:14:42 +02:00
|
|
|
'[[!inline pages="enemies/*" postform=no rootpage=enemies sort=title reverse=yes show=2]]');
|
2014-02-23 17:03:44 +01:00
|
|
|
foreach my $page (qw(protagonists/shepard protagonists/link
|
|
|
|
antagonists/saren antagonists/ganondorf
|
2014-09-14 16:14:42 +02:00
|
|
|
friends/garrus friends/liara friends/midna friends/telma
|
|
|
|
enemies/benezia enemies/geth enemies/rachni
|
|
|
|
enemies/zant)) {
|
|
|
|
write_old_file("$page.mdwn", "this page is {$page}");
|
2014-02-23 17:03:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ok(! system("make -s ikiwiki.out"));
|
|
|
|
|
2015-03-01 17:14:32 +01:00
|
|
|
my $command = "perl -I. ./ikiwiki.out --set usedirs=0 --plugin inline --url=http://example.com --cgiurl=http://example.com/ikiwiki.cgi --rss --atom --underlaydir=underlays/basewiki --set underlaydirbase=underlays --templatedir=templates t/tmp/in t/tmp/out --verbose";
|
2014-02-23 17:03:44 +01:00
|
|
|
|
|
|
|
ok(! system($command));
|
|
|
|
|
2015-03-01 17:14:32 +01:00
|
|
|
ok(! system("$command --refresh"));
|
2014-02-23 17:03:44 +01:00
|
|
|
|
|
|
|
$blob = readfile("t/tmp/out/protagonists.html");
|
2015-03-01 18:15:13 +01:00
|
|
|
like($blob, qr{\Q$add_new_post\E}, 'rootpage=yes gives postform');
|
2014-02-23 17:03:44 +01:00
|
|
|
like($blob, qr{<input type="hidden" name="from" value="protagonists/new"},
|
|
|
|
'explicit rootpage is /protagonists/new');
|
|
|
|
|
|
|
|
$blob = readfile("t/tmp/out/friends.html");
|
2015-03-01 18:15:13 +01:00
|
|
|
like($blob, qr{\Q$add_new_post\E}, 'postform=yes forces postform');
|
2014-02-23 17:03:44 +01:00
|
|
|
like($blob, qr{<input type="hidden" name="from" value="friends"},
|
|
|
|
'implicit rootpage is /friends');
|
2015-06-15 03:35:51 +02:00
|
|
|
like($blob, qr[this page is \{friends/garrus}.*this page is \{friends/liara}]s,
|
2014-09-14 16:14:42 +02:00
|
|
|
'first two pages in desired sort order are present');
|
|
|
|
unlike($blob, qr{friends/(?:midna|telma)},
|
|
|
|
'pages excluded by show should not be present');
|
2014-02-23 17:03:44 +01:00
|
|
|
|
|
|
|
$blob = readfile("t/tmp/out/antagonists.html");
|
2015-03-01 18:15:13 +01:00
|
|
|
unlike($blob, qr{\Q$add_new_post\E}, 'default is no postform');
|
2014-02-23 17:03:44 +01:00
|
|
|
|
|
|
|
$blob = readfile("t/tmp/out/enemies.html");
|
2015-03-01 18:15:13 +01:00
|
|
|
unlike($blob, qr{\Q$add_new_post\E}, 'postform=no forces no postform');
|
2015-06-15 03:35:51 +02:00
|
|
|
like($blob, qr[this page is \{enemies/zant}.*this page is \{enemies/rachni}]s,
|
2014-09-14 16:14:42 +02:00
|
|
|
'first two pages in reversed sort order are present');
|
|
|
|
unlike($blob, qr{enemies/(?:benezia|geth)},
|
|
|
|
'pages excluded by show should not be present');
|
2014-02-23 17:03:44 +01:00
|
|
|
|
|
|
|
done_testing;
|