7 my $installed = $ENV{INSTALLED_TESTS};
11 @command = qw(ikiwiki);
14 ok(! system("make -s ikiwiki.out"));
15 @command = qw(perl -I. ./ikiwiki.out
16 --underlaydir=underlays/basewiki
17 --set underlaydirbase=underlays
18 --templatedir=templates);
21 push @command, qw(--set usedirs=0 --plugin inline
22 --url=http://example.com --cgiurl=http://example.com/ikiwiki.cgi
23 --rss --atom t/tmp/in t/tmp/out --verbose);
27 my $add_new_post = gettext("Add a new post titled:");
29 ok(! system("rm -rf t/tmp"));
30 ok(! system("mkdir t/tmp"));
36 writefile($name, "t/tmp/in", $content);
37 ok(utime(333333333, 333333333, "t/tmp/in/$name"));
40 write_old_file("protagonists.mdwn",
41 '[[!inline pages="protagonists/*" rootpage="protagonists/new"]]');
42 write_old_file("friends.mdwn",
43 '[[!inline pages="friends/*" postform=yes sort=title limit=2]]');
44 write_old_file("antagonists.mdwn",
45 '[[!inline pages="antagonists/*"]]');
46 # using old spelling of "limit" ("show") to verify backwards compat
47 write_old_file("enemies.mdwn",
48 '[[!inline pages="enemies/*" postform=no rootpage=enemies sort=title reverse=yes show=2]]');
49 # to test correct processing of ../
50 write_old_file("blah/blah/enemies.mdwn",
51 '[[!inline pages="enemies/*" postform=no rootpage=enemies sort=title reverse=yes show=2]]');
52 foreach my $page (qw(protagonists/shepard protagonists/link
53 antagonists/saren antagonists/ganondorf
54 friends/garrus friends/liara friends/midna friends/telma
55 enemies/benezia enemies/geth enemies/rachni
57 write_old_file("$page.mdwn", "this page is {$page}");
59 # test cross-linking between pages as rendered in RSS
60 write_old_file("enemies/zant.mdwn", "this page is {enemies/zant}\n\n".
61 "Zant hates [[friends/Midna]].");
63 ok(! system(@command));
64 ok(! system(@command, "--refresh"));
66 $blob = readfile("t/tmp/out/protagonists.html");
67 like($blob, qr{\Q$add_new_post\E}, 'rootpage=yes gives postform');
68 like($blob, qr{<input type="hidden" name="from" value="protagonists/new"},
69 'explicit rootpage is /protagonists/new');
71 $blob = readfile("t/tmp/out/friends.html");
72 like($blob, qr{\Q$add_new_post\E}, 'postform=yes forces postform');
73 like($blob, qr{<input type="hidden" name="from" value="friends"},
74 'implicit rootpage is /friends');
75 like($blob, qr[this page is \{friends/garrus}.*this page is \{friends/liara}]s,
76 'first two pages in desired sort order are present');
77 unlike($blob, qr{friends/(?:midna|telma)},
78 'pages excluded by limit should not be present');
80 $blob = readfile("t/tmp/out/antagonists.html");
81 unlike($blob, qr{\Q$add_new_post\E}, 'default is no postform');
83 $blob = readfile("t/tmp/out/enemies.html");
84 unlike($blob, qr{\Q$add_new_post\E}, 'postform=no forces no postform');
85 like($blob, qr[this page is \{enemies/zant}.*this page is \{enemies/rachni}]s,
86 'first two pages in reversed sort order are present');
87 unlike($blob, qr{enemies/(?:benezia|geth)},
88 'pages excluded by show should not be present');
90 $blob = readfile("t/tmp/out/enemies.rss");
91 like($blob, qr[this page is \{enemies/zant}.*this page is \{enemies/rachni}]s,
92 'first two pages in reversed sort order are present');
94 qr[Zant hates <a href=(?:['"]|")http://example\.com/friends/midna.html(?:['"]|")>Midna</a>]s,
95 'link is correctly relative');
97 $blob = readfile("t/tmp/out/blah/blah/enemies.rss");
98 like($blob, qr[this page is \{enemies/zant}.*this page is \{enemies/rachni}]s,
99 'first two pages in reversed sort order are present');
101 qr[Zant hates <a href=(?:['"]|")http://example\.com/friends/midna.html(?:['"]|")>Midna</a>]s,
102 'link is correctly relative');