2014-02-23 17:03:44 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
use Test::More;
|
|
|
|
use IkiWiki;
|
|
|
|
|
2015-11-30 18:33:00 +01:00
|
|
|
my $installed = $ENV{INSTALLED_TESTS};
|
|
|
|
|
|
|
|
my @command;
|
|
|
|
if ($installed) {
|
|
|
|
@command = qw(ikiwiki);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ok(! system("make -s ikiwiki.out"));
|
|
|
|
@command = qw(perl -I. ./ikiwiki.out
|
|
|
|
--underlaydir=underlays/basewiki
|
|
|
|
--set underlaydirbase=underlays
|
|
|
|
--templatedir=templates);
|
|
|
|
}
|
|
|
|
|
|
|
|
push @command, qw(--set usedirs=0 --plugin inline
|
|
|
|
--url=http://example.com --cgiurl=http://example.com/ikiwiki.cgi
|
|
|
|
--rss --atom t/tmp/in t/tmp/out --verbose);
|
|
|
|
|
2014-02-23 17:03:44 +01:00
|
|
|
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:15:27 +02:00
|
|
|
'[[!inline pages="friends/*" postform=yes sort=title limit=2]]');
|
2014-02-23 17:03:44 +01:00
|
|
|
write_old_file("antagonists.mdwn",
|
|
|
|
'[[!inline pages="antagonists/*"]]');
|
2014-09-14 16:15:27 +02:00
|
|
|
# using old spelling of "limit" ("show") to verify backwards compat
|
2014-02-23 17:03:44 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-11-30 18:33:00 +01:00
|
|
|
ok(! system(@command));
|
|
|
|
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)},
|
2014-09-14 16:15:27 +02:00
|
|
|
'pages excluded by limit 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;
|