Written by Tarquin for UnrealWiki.
usage:
?PageName?
Produces a list of all the subpages of PageName?.
This patch extends to WikiPatches/RenameSubpages
diff -r1.23 -r1.22
2772,2784d2771
< # tarq
< sub AllSubPagesList {
< my $GivenPage = shift;
< my @PageList = AllPagesList();
< my @Results;
< foreach ( @PageList ) {
< if (/^$GivenPage\//i) { # BrianHunter
< push @Results, $_;
< }
< }
< return @Results;
< }
<
4373d4359
< print "<tt>?PageName</tt> -- gets list of all subpages of this page\n";#tarq
4382d4367
<
4398,4399c4383
< next if (!(/^[=!|?]/)); # Only valid commands. tarq
< #next if (!(/^[=!|]/)); # Only valid commands.
---
> next if (!(/^[=!|]/)); # Only valid commands.
4407,4409d4390
< } elsif (/^\?(.+)/) {
< print "<b>Subpages of " . $1 . "<BR></b>";
< print join("<br>", AllSubPagesList($1));
4733c4714
<
---
>
First block (2772,2784d2771) can be placed in anywhere (it is the whole subroutine AllSubPagesList?), for example just below subroutine AllPagesList:
sub AllPagesList {
...
}
sub AllSubPagesList {
my $GivenPage = shift;
my @PageList = AllPagesList();
my @Results;
foreach (@PageList) {
if (/^$GivenPage\//i) { # BrianHunter
push @Results, $_;
}
}
return @Results;
}
sub CalcDay {
...
Second block (single line 4373d4359) falls into subroutine DoEditLinks? between these two lines:
print "<p>Enter one command on each line. Commands are:<br>",
"<tt>?PageName</tt> -- gets list of all subpages of this page\n",
"<tt>!PageName</tt> -- deletes the page called PageName<br>\n",
Third block (4382d4367) can be safely ignored.
Fourth block (4398,4399c4383) replaces this line in subroutine UpdateLinksList:
s/\s+$//g;
next if (!(/^[=!|]/)); # Only valid commands.
print "Processing $_<br>\n";
with this line:
s/\s+$//g;
next if (!(/^[=!|?]/)); # Only valid commands.
print "Processing $_<br>\n";
Fifth block (4407,4409d4390) goes under subroutine UpdateLinksList between these lines:
&DeletePage($1, $doRC, $doText);
} elsif (/^\?(.+)/) {
print "<b>Subpages of " . &GetPageLink($1) . "<BR></b>";
print join("<br>", map { &GetPageLink($_) } &AllSubPagesList($1));
print "<br><br>"; # BrianHunter
} elsif (/^\=(?:\[\[)?([^]=]+)(?:\]\])?\=(?:\[\[)?([^]=]+)(?:\]\])?/) {
Sixth block (4733c4714) can be safely ignored.
print "<p>Enter one command on each line. Commands are:<br>",
"<tt>?PageName</tt> -- gets list of all subpages of this page<br>\n",
"<tt>!PageName</tt> -- deletes the page called PageName<br>\n",
-- Ralf Baerwaldt
For better readablity it should be the other way around:
-- Ralf Baerwaldt
The original match found subpages of pages whose name ended with the name of the main page.
e.g. ?Tech would find MyTech/SubPage as well as Tech/SubPage
This does not matter too much on a list BUT had an interesting effect when the WikiPatches/RenameSubpages patch was applied.
A rename of Tech/* to MyTech
=Tech/*=MyTech could be done muliple times. Each time the subpages would have an extra My prefixed to the main page name.
Also, after the line
print join("<br>", map { &GetPageLink($_) } &AllSubPagesList($1));
I've added the line
print "<br><br>";
to Ferdinands mod for an improved format list where multiple commands are issued.